Demo build: 150 kg goal, end screen, separate AppId and store assets
GC_DEMO define (ProjectBuilder GC_DEMO=1 / -demo) builds GrassCutterDemo.exe for app 5668050 with its own product name, version 0.1-demo and no achievements. Purchases lock after shipping 150 kg; a goal label and a thanks/wishlist card follow. Menu gets a DEMO badge and wishlist button. Store texts (12 languages) and DEMO-badged capsules for the demo page. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@ -97,7 +97,7 @@ namespace GrassCutter
|
||||
s_next = Time.time + Every;
|
||||
var ts = TeamState.Instance;
|
||||
var me = PlayerAgent.Local;
|
||||
if (!ts || !me) return;
|
||||
if (!ts || !me || Demo.On) return;
|
||||
Read();
|
||||
foreach (var a in All)
|
||||
{
|
||||
|
||||
25
Assets/Scripts/Core/Demo.cs
Normal file
25
Assets/Scripts/Core/Demo.cs
Normal file
@ -0,0 +1,25 @@
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>
|
||||
/// The demo build (built with GC_DEMO): its own Steam app, its own saves (another product name, so another data
|
||||
/// folder and other settings), no achievements, and an end once the crew has shipped <see cref="GoalKg"/>: a thank-you
|
||||
/// screen with the wishlist and feedback links, and nothing more for sale after it.
|
||||
/// </summary>
|
||||
public static class Demo
|
||||
{
|
||||
#if GC_DEMO
|
||||
public const bool On = true;
|
||||
#else
|
||||
public const bool On = false;
|
||||
#endif
|
||||
/// <summary>The full game: what the wishlist and feedback links go to.</summary>
|
||||
public const uint FullAppId = 5551720;
|
||||
public const uint DemoAppId = 5668050;
|
||||
/// <summary>About half an hour for a first-time player: the paced opening ships 178 kg in 30 minutes knowing exactly what to do.</summary>
|
||||
public const double GoalKg = 150;
|
||||
|
||||
public static double Shipped => TeamState.Instance ? TeamState.Instance.Shipped.Value : 0d;
|
||||
/// <summary>The crew has reached the end of the demo.</summary>
|
||||
public static bool Over => On && Shipped >= GoalKg;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Core/Demo.cs.meta
Normal file
2
Assets/Scripts/Core/Demo.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cd1209cf5dfb99e44a1aace34f8042f6
|
||||
44
Assets/Scripts/Core/DemoBot.DemoEnd.cs
Normal file
44
Assets/Scripts/Core/DemoBot.DemoEnd.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace GrassCutter
|
||||
{
|
||||
public partial class DemoBot
|
||||
{
|
||||
/// <summary>
|
||||
/// -demoend (in a GC_DEMO build): the menu with its wishlist button, the goal on screen, the thank-you screen once
|
||||
/// the goal is shipped, and a purchase refused after it.
|
||||
/// </summary>
|
||||
IEnumerator DemoEndDemo()
|
||||
{
|
||||
Log($"demo build: {Demo.On}, app {SteamManager.AppId}, version {NetSession.Version}, data {Application.persistentDataPath}");
|
||||
BotCapture.From = null;
|
||||
yield return new WaitForSeconds(3f);
|
||||
yield return Shot("demo_0_menu");
|
||||
TeamState.DeleteSave();
|
||||
NetSession.Instance.HostLocal();
|
||||
while (!Me || !Ts) yield return null;
|
||||
yield return new WaitForSeconds(3f);
|
||||
Ts.ServerSetMoney(1000d);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
yield return Shot("demo_1_goal");
|
||||
Ts.BuyToolRpc((byte)ToolId.Scythe);
|
||||
yield return new WaitForSeconds(1f);
|
||||
Log($"before the goal: scythe bought {(Me.Owns(ToolId.Scythe) ? "yes" : "NO")}, over {Demo.Over}");
|
||||
Ts.Shipped.Value = Demo.GoalKg + 3;
|
||||
yield return new WaitForSeconds(2f);
|
||||
Log($"at the goal: over {Demo.Over}");
|
||||
yield return Shot("demo_2_end");
|
||||
UIRoot.I.CloseTopModal();
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
double cash = Ts.Money.Value;
|
||||
Ts.BuyToolRpc((byte)ToolId.LongScythe);
|
||||
Ts.BuyBeltSlotRpc();
|
||||
yield return new WaitForSeconds(1f);
|
||||
Log($"after the goal: long scythe {(Me.Owns(ToolId.LongScythe) ? "BOUGHT" : "refused")}, money {cash:0} -> {Ts.Money.Value:0}");
|
||||
yield return Shot("demo_3_refused");
|
||||
Log("demoend done");
|
||||
Application.Quit();
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Core/DemoBot.DemoEnd.cs.meta
Normal file
2
Assets/Scripts/Core/DemoBot.DemoEnd.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1716542de5bb2ed4a8baec5130a35e0e
|
||||
@ -3078,6 +3078,11 @@ namespace GrassCutter
|
||||
yield return gameObject.AddComponent<Trailer>().Shoot(folder);
|
||||
yield break;
|
||||
}
|
||||
if (CommandLine.Has("-demoend"))
|
||||
{
|
||||
yield return DemoEndDemo();
|
||||
yield break;
|
||||
}
|
||||
if (CommandLine.Has("-demoyt"))
|
||||
{
|
||||
yield return TubeDemo();
|
||||
|
||||
@ -58,7 +58,7 @@ namespace GrassCutter
|
||||
var ts = TeamState.Instance;
|
||||
if (!ts || Upgrades == UpgradeKind.None || Tier.Value >= GameDefs.MaxTier) return;
|
||||
double price = GameDefs.UpgradePrice(this, Tier.Value);
|
||||
if (ts.Money.Value < price) { ts.DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
if (ts.Money.Value < price || Demo.Over) { ts.DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
ts.Money.Value -= price;
|
||||
Tier.Value++;
|
||||
UpgradedRpc();
|
||||
|
||||
@ -16,7 +16,7 @@ namespace GrassCutter
|
||||
bool belt = d.id == PieceId.Belt;
|
||||
double price = belt ? GameDefs.BeltPrice(Vector3.Distance(at, to)) : d.price;
|
||||
bool fits = belt ? BuildRules.CanRun(at, to, out _) : BuildRules.CanPlace(d, at, rot, null, out _);
|
||||
if (d.company || !who || !who.Owns(ToolId.Hammer) || Money.Value < price || !fits) { DeniedRpc(sender); return; }
|
||||
if (d.company || !who || !who.Owns(ToolId.Hammer) || Money.Value < price || Demo.Over || !fits) { DeniedRpc(sender); return; }
|
||||
Money.Value -= price;
|
||||
ServerSpawnPiece(d.id, at, belt ? BuildRules.RunRotation(at, to) : rot, to);
|
||||
Save();
|
||||
|
||||
@ -92,7 +92,7 @@ namespace GrassCutter
|
||||
var who = PlayerOf(rpc.Receive.SenderClientId);
|
||||
if (!who || !who.ClaimedSave || kind >= (byte)VehicleKind.Count) return;
|
||||
var d = GameDefs.Vehicle((VehicleKind)kind);
|
||||
if (Money.Value < d.price || Vehicle.Mine(d.kind, who.SaveId)) { DeniedRpc(sender); return; }
|
||||
if (Money.Value < d.price || Demo.Over || Vehicle.Mine(d.kind, who.SaveId)) { DeniedRpc(sender); return; }
|
||||
Money.Value -= d.price;
|
||||
var shed = ShedFor(garage);
|
||||
Vector3 at;
|
||||
@ -131,7 +131,7 @@ namespace GrassCutter
|
||||
int level = v.Level(t);
|
||||
if (level >= GameDefs.Tune(t).prices.Length) { DeniedRpc(sender); return; }
|
||||
double price = GameDefs.TunePrice(v.kind, t, level);
|
||||
if (Money.Value < price) { DeniedRpc(sender); return; }
|
||||
if (Money.Value < price || Demo.Over) { DeniedRpc(sender); return; }
|
||||
Money.Value -= price;
|
||||
v.Tuned[tune] = (byte)(level + 1);
|
||||
Save();
|
||||
|
||||
@ -201,7 +201,7 @@ namespace GrassCutter
|
||||
if (perk < 0 || perk >= (int)PerkId.Count) return;
|
||||
var def = GameDefs.Perk((PerkId)perk);
|
||||
int lvl = Level(def.id);
|
||||
if (lvl >= def.maxLevel || !PerkAvailable(def) || Money.Value < def.PriceFor(lvl)) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
if (lvl >= def.maxLevel || !PerkAvailable(def) || Money.Value < def.PriceFor(lvl) || Demo.Over) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
Money.Value -= def.PriceFor(lvl);
|
||||
Perks[perk] = (byte)(lvl + 1);
|
||||
PurchasedRpc(PlayerName(rpc.Receive.SenderClientId), def.maxLevel > 1 ? Loc.Key(def.nameEn, GameDefs.ToRoman(lvl + 1)) : Loc.Key(def.nameEn));
|
||||
@ -209,7 +209,11 @@ namespace GrassCutter
|
||||
}
|
||||
|
||||
[Rpc(SendTo.SpecifiedInParams)]
|
||||
public void DeniedRpc(RpcParams p = default) { Sfx.Play("error"); }
|
||||
public void DeniedRpc(RpcParams p = default)
|
||||
{
|
||||
Sfx.Play("error");
|
||||
if (Demo.Over) Hud.Toast(Loc.T("That's the end of the demo: the full game has the rest of the planet."), Hud.ToastKind.Warn);
|
||||
}
|
||||
|
||||
[Rpc(SendTo.Everyone)]
|
||||
void PurchasedRpc(FixedString64Bytes who, FixedString64Bytes what) => Purchased?.Invoke(who.ToString(), what.ToString());
|
||||
@ -235,7 +239,7 @@ namespace GrassCutter
|
||||
if (!who || tool >= GameDefs.ToolCount) return;
|
||||
var d = GameDefs.Tool((ToolId)tool);
|
||||
double price = ToolPrice(d);
|
||||
if (who.Owns((ToolId)tool) || Money.Value < price) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
if (who.Owns((ToolId)tool) || Money.Value < price || Demo.Over) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
Money.Value -= price;
|
||||
who.Owned.Value |= (ushort)(1 << tool);
|
||||
SaveCrew(who);
|
||||
@ -247,7 +251,7 @@ namespace GrassCutter
|
||||
var who = PlayerOf(rpc.Receive.SenderClientId);
|
||||
if (!who) return;
|
||||
long price = GameDefs.BeltSlotPrice(who.BeltSlots.Value);
|
||||
if (who.BeltSlots.Value >= GameDefs.MaxBeltSlots || Money.Value < price) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
if (who.BeltSlots.Value >= GameDefs.MaxBeltSlots || Money.Value < price || Demo.Over) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
Money.Value -= price;
|
||||
who.BeltSlots.Value++;
|
||||
SaveCrew(who);
|
||||
@ -259,7 +263,7 @@ namespace GrassCutter
|
||||
var who = PlayerOf(rpc.Receive.SenderClientId);
|
||||
if (!who || gear < (byte)GearId.Jetpack || gear > (byte)GearId.NightVision) return;
|
||||
long price = GameDefs.GearPrice((GearId)gear);
|
||||
if (who.HasGear((GearId)gear) || Money.Value < price) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
if (who.HasGear((GearId)gear) || Money.Value < price || Demo.Over) { DeniedRpc(RpcTarget.Single(rpc.Receive.SenderClientId, RpcTargetUse.Temp)); return; }
|
||||
Money.Value -= price;
|
||||
who.Owned.Value |= (ushort)(1 << gear);
|
||||
SaveCrew(who);
|
||||
|
||||
@ -22,7 +22,7 @@ namespace GrassCutter
|
||||
public class NetSession : MonoBehaviour
|
||||
{
|
||||
public const string GameKey = "grasscutter";
|
||||
public const string Version = "0.1";
|
||||
public const string Version = Demo.On ? "0.1-demo" : "0.1";
|
||||
public const int MaxPlayers = 16;
|
||||
const ushort LocalPort = 7777;
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ namespace GrassCutter
|
||||
[DefaultExecutionOrder(-1000)]
|
||||
public class SteamManager : MonoBehaviour
|
||||
{
|
||||
public const uint AppId = 5551720;
|
||||
public const uint AppId = Demo.On ? Demo.DemoAppId : Demo.FullAppId;
|
||||
|
||||
public static SteamManager Instance { get; private set; }
|
||||
public static bool Initialized { get; private set; }
|
||||
@ -106,15 +106,16 @@ namespace GrassCutter
|
||||
if (Initialized) SteamAPI.RunCallbacks();
|
||||
}
|
||||
|
||||
public static string StoreUrl => $"https://store.steampowered.com/app/{AppId}/";
|
||||
public static string FeedbackUrl => $"https://steamcommunity.com/app/{AppId}/discussions/";
|
||||
// always the full game: the demo has no hub of its own, and its wishlist button is for the game
|
||||
public static string StoreUrl => $"https://store.steampowered.com/app/{Demo.FullAppId}/";
|
||||
public static string FeedbackUrl => $"https://steamcommunity.com/app/{Demo.FullAppId}/discussions/";
|
||||
|
||||
/// <summary>The game's store page (wishlist, follow, review): in the Steam overlay, else the browser.</summary>
|
||||
public static void OpenStore()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Initialized && SteamUtils.IsOverlayEnabled()) { SteamFriends.ActivateGameOverlayToStore(new AppId_t(AppId), EOverlayToStoreFlag.k_EOverlayToStoreFlag_None); return; }
|
||||
if (Initialized && SteamUtils.IsOverlayEnabled()) { SteamFriends.ActivateGameOverlayToStore(new AppId_t(Demo.FullAppId), EOverlayToStoreFlag.k_EOverlayToStoreFlag_None); return; }
|
||||
}
|
||||
catch (Exception) { }
|
||||
Application.OpenURL(StoreUrl);
|
||||
|
||||
63
Assets/Scripts/UI/UIRoot.Demo.cs
Normal file
63
Assets/Scripts/UI/UIRoot.Demo.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace GrassCutter
|
||||
{
|
||||
/// <summary>The demo's goal on screen while it's being played for, and the thank-you screen when it's reached.</summary>
|
||||
public partial class UIRoot
|
||||
{
|
||||
Label _demoGoal;
|
||||
bool _demoEndSeen;
|
||||
|
||||
void TickDemo()
|
||||
{
|
||||
if (!Demo.On) return;
|
||||
if (_demoGoal == null)
|
||||
{
|
||||
_demoGoal = UIK.Text("", "t-small t-outline", _hud, false);
|
||||
_demoGoal.pickingMode = PickingMode.Ignore;
|
||||
_demoGoal.style.position = Position.Absolute;
|
||||
_demoGoal.style.top = 76;
|
||||
_demoGoal.style.left = 0;
|
||||
_demoGoal.style.right = 0;
|
||||
_demoGoal.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
}
|
||||
bool show = _inGame && TeamState.Instance;
|
||||
_demoGoal.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
if (!show) { _demoEndSeen = false; return; }
|
||||
_demoGoal.text = Demo.Over
|
||||
? Loc.T("DEMO COMPLETE · thanks for playing!")
|
||||
: Loc.F("DEMO · goal: ship {0} of {1} kg of grass", Loc.Num(Mathf.Floor((float)Demo.Shipped), "0"), Loc.Num((float)Demo.GoalKg, "0"));
|
||||
if (Demo.Over && !_demoEndSeen && !AnyModal && !Phone.Focused)
|
||||
{
|
||||
_demoEndSeen = true;
|
||||
OpenDemoEnd();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The end of the demo: thanks, the wishlist and feedback, and the choice to stay on this planet or go.</summary>
|
||||
internal void OpenDemoEnd()
|
||||
{
|
||||
Sfx.Play("milestone", 0.8f);
|
||||
OpenModal(layer =>
|
||||
{
|
||||
var card = UIK.El("card", layer);
|
||||
card.pickingMode = PickingMode.Position;
|
||||
card.style.width = 760;
|
||||
card.style.alignItems = Align.Stretch;
|
||||
UIK.Text(Loc.T("THANKS FOR PLAYING THE DEMO!"), "t-h1 t-dark t-center", card);
|
||||
var body = UIK.Text(Loc.F("Your crew shipped {0} kg of grass and reached the end of the demo. In the full game the whole planet is yours: machines, belts, robots, far stations and up to 16 players.", Loc.Num((float)Demo.Shipped, "0")), "t-body t-dark t-center", card, false);
|
||||
body.style.whiteSpace = WhiteSpace.Normal;
|
||||
body.style.marginBottom = 10;
|
||||
var note = UIK.Text(Loc.T("You can keep mowing here, but nothing more is for sale in the demo."), "t-small t-muted t-center", card, false);
|
||||
note.style.whiteSpace = WhiteSpace.Normal;
|
||||
note.style.marginBottom = 16;
|
||||
UIK.Btn(Loc.T("WISHLIST THE FULL GAME"), () => SteamManager.OpenStore(), "btn btn-green", card);
|
||||
UIK.Btn(Loc.T("LEAVE FEEDBACK"), () => SteamManager.OpenWeb(SteamManager.FeedbackUrl), "btn btn-blue", card);
|
||||
UIK.Btn(Loc.T("KEEP MOWING"), () => CloseModal(layer), "btn btn-white", card);
|
||||
UIK.Btn(Loc.T("LEAVE TO MENU"), () => { CloseModal(layer); NetSession.Instance.Leave(); }, "btn btn-red", card);
|
||||
return card;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/UI/UIRoot.Demo.cs.meta
Normal file
2
Assets/Scripts/UI/UIRoot.Demo.cs.meta
Normal file
@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9197efad190236e4ca5f8a292e7c1428
|
||||
@ -120,6 +120,7 @@ namespace GrassCutter
|
||||
Ctl.UIOpen = _modalStack.Count > 0 || !_inGame;
|
||||
if (_inGame) Ctl.SetCursor(!AnyModal && !Phone.Focused && !SteamManager.OverlayActive);
|
||||
Hud?.Tick(_inGame && !AnyModal);
|
||||
TickDemo();
|
||||
Hud?.SetTabList(_inGame && !AnyModal && Ctl.TabHeld);
|
||||
_spinAngle += Time.unscaledDeltaTime * 360f;
|
||||
var sp = _connecting?.Q(className: "spinner");
|
||||
@ -152,6 +153,17 @@ namespace GrassCutter
|
||||
UIK.Btn(Loc.T("SETTINGS"), OpenSettings, "btn btn-white btn-wide", side),
|
||||
UIK.Btn(Loc.T("QUIT"), Quit, "btn btn-red btn-wide", side),
|
||||
};
|
||||
if (Demo.On)
|
||||
{
|
||||
// the demo says so under the logo, and the wishlist sits with the big buttons
|
||||
var badge = UIK.Text(Loc.T("DEMO"), "menu-tagline t-outline", _menu);
|
||||
badge.style.top = Length.Percent(63);
|
||||
badge.style.fontSize = 44;
|
||||
badge.style.color = new Color(1f, 0.83f, 0.25f);
|
||||
var wish = UIK.Btn(Loc.T("WISHLIST THE FULL GAME"), () => SteamManager.OpenStore(), "btn btn-green btn-wide", side);
|
||||
wish.PlaceBehind(buttons[buttons.Count - 1]);
|
||||
buttons.Insert(buttons.Count - 1, wish);
|
||||
}
|
||||
var hint = UIK.Text(Loc.T(SteamManager.Initialized ? Loc.N("PLAY alone, on your LAN, or in a Steam lobby: invite friends with Shift+Tab.") : Loc.N("Steam not running: play alone or on your LAN.")), "t-small t-outline", side, false);
|
||||
hint.style.marginTop = 14;
|
||||
// the language in a click (Chinese above all), the store page and where to tell us what's wrong
|
||||
@ -161,7 +173,7 @@ namespace GrassCutter
|
||||
links.style.marginTop = 18;
|
||||
var langBtn = UIK.Btn(Loc.T("Language") + ": " + Loc.Current.native, OpenLanguages, "btn btn-white btn-small", links);
|
||||
SetLangFont(langBtn, Loc.Current);
|
||||
UIK.Btn(Loc.T("STEAM PAGE"), () => SteamManager.OpenStore(), "btn btn-blue btn-small", links).style.marginLeft = 10;
|
||||
if (!Demo.On) UIK.Btn(Loc.T("STEAM PAGE"), () => SteamManager.OpenStore(), "btn btn-blue btn-small", links).style.marginLeft = 10;
|
||||
UIK.Btn(Loc.T("FEEDBACK"), () => SteamManager.OpenWeb(SteamManager.FeedbackUrl), "btn btn-green btn-small", links).style.marginLeft = 10;
|
||||
|
||||
var footer = UIK.El("menu-footer", _menu);
|
||||
|
||||
Reference in New Issue
Block a user