using UnityEngine; using UnityEngine.UIElements; namespace GrassCutter { /// The demo's goal on screen while it's being played for, and the thank-you screen when it's reached. 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(); } } /// The end of the demo: thanks, the wishlist and feedback, and the choice to stay on this planet or go. 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; }); } } }