From d34fac03bc8c1c975a45ad1a2aeec1096a779b4b Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 8 Jul 2020 14:36:26 +0200 Subject: [PATCH] added park management page --- Ideas.md | 2 +- .../Content/Localization/Localization.json | 4 ++ TouchyTickets/ParkMap.cs | 10 ++- TouchyTickets/Ui.cs | 63 +++++++++++++++---- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/Ideas.md b/Ideas.md index 361b393..ad63526 100644 --- a/Ideas.md +++ b/Ideas.md @@ -21,7 +21,7 @@ - Advanced version that adds modifiers to each ride automatically, regardless of whether they already contain them # Park management -- Shows statistics on how much each ride type generates in the park +- ~~Shows statistics on how much each ride type generates in the park~~ - Edit park templates - Set the minimum amount of tickets required for auto-buyers of any kind to take effect - Set the amount of time between auto-buy attempts \ No newline at end of file diff --git a/TouchyTickets/Content/Localization/Localization.json b/TouchyTickets/Content/Localization/Localization.json index 77b9442..4512712 100644 --- a/TouchyTickets/Content/Localization/Localization.json +++ b/TouchyTickets/Content/Localization/Localization.json @@ -20,6 +20,10 @@ "KeepScreenOn": "Keep Screen On", "RateInfo": "You've been playing the game for a while now, which probably means you're enjoying it.\nPlease rate the game, it really helps out! Thanks <3", "Rate": "Rate", + "ParkManagement": "Park Management", + "Attractions": "Attractions", + "Modifiers": "Modifiers", + "RideStats": "Sales per Ride", "----- Tutorial -----": "", "Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a . Start by racking up 50!", "Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.", diff --git a/TouchyTickets/ParkMap.cs b/TouchyTickets/ParkMap.cs index 2ed488e..29eacfb 100644 --- a/TouchyTickets/ParkMap.cs +++ b/TouchyTickets/ParkMap.cs @@ -27,6 +27,7 @@ namespace TouchyTickets { private readonly Attraction[,] attractionGrid; public double TicketsPerSecond { get; private set; } + public readonly Dictionary TicketsPerRide = new Dictionary(); public Attraction PlacingAttraction; public AttractionModifier PlacingModifier; public Point PlacingPosition; @@ -68,12 +69,15 @@ namespace TouchyTickets { } public void Update(GameTime time, TimeSpan passed) { - var tickets = 0D; + this.TicketsPerRide.Clear(); + this.TicketsPerSecond = 0; foreach (var (pos, attraction) in this.attractions) { var genPerSecond = attraction.Update(time, passed, this, pos); - tickets += genPerSecond; + // store ride statistics + this.TicketsPerRide.TryGetValue(attraction.Type, out var curr); + this.TicketsPerRide[attraction.Type] = curr + genPerSecond; + this.TicketsPerSecond += genPerSecond; } - this.TicketsPerSecond = tickets; // map movement if (GameImpl.Instance.DrawMap && GameImpl.Instance.UiSystem.Controls.HandleTouch) { diff --git a/TouchyTickets/Ui.cs b/TouchyTickets/Ui.cs index c5dd8cf..5203552 100644 --- a/TouchyTickets/Ui.cs +++ b/TouchyTickets/Ui.cs @@ -141,14 +141,19 @@ namespace TouchyTickets { this.uiSystem.Add("Main", main); // buy ui - var buyUi = new Panel(Anchor.TopLeft, Vector2.One, Vector2.Zero, false, true, new Point(10, 30), false) { - ChildPadding = new Padding(5, 15, 5, 5), - IsHidden = true + var buyUi = new Group(Anchor.TopLeft, Vector2.One, false) { + IsHidden = true, + OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha) }; + buyUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Attractions"), true) {TextScale = 0.15F}); + var buyList = buyUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, new Point(10, 30), false) { + ChildPadding = new Padding(5, 15, 5, 5), + PreventParentSpill = true + }); foreach (var attraction in AttractionType.Attractions) { BigInteger price = 0; var attractionAmount = 0; - var button = buyUi.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 40)) { + var button = buyList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 40)) { ChildPadding = new Vector2(4), PositionOffset = new Vector2(0, 1), OnPressed = e => { @@ -209,12 +214,17 @@ namespace TouchyTickets { this.uiSystem.Add("Buy", buyUi); // modifier ui - var modifierUi = new Panel(Anchor.TopLeft, Vector2.One, Vector2.Zero, false, true, new Point(10, 30), false) { - ChildPadding = new Padding(5, 15, 5, 5), - IsHidden = true + var modifierUi = new Group(Anchor.TopLeft, Vector2.One, false) { + IsHidden = true, + OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha) }; + modifierUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Modifiers"), true) {TextScale = 0.15F}); + var modifierList = modifierUi.AddChild(new Panel(Anchor.AutoLeft, Vector2.One, Vector2.Zero, false, true, new Point(10, 30), false) { + ChildPadding = new Padding(5, 15, 5, 5), + PreventParentSpill = true + }); foreach (var modifier in AttractionModifier.Modifiers.Values) { - var button = modifierUi.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) { + var button = modifierList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) { SetHeightBasedOnChildren = true, PositionOffset = new Vector2(0, 1), ChildPadding = new Vector2(4), @@ -303,9 +313,9 @@ namespace TouchyTickets { desc.IsHidden = !shouldShow; }; } - modifierUi.OnAreaUpdated += e => { + modifierList.OnAreaUpdated += e => { // sort children by whether they should be shown or not - modifierUi.ReorderChildren((e1, e2) => Comparer.Default.Compare(e2.GetData("Show"), e1.GetData("Show"))); + modifierList.ReorderChildren((e1, e2) => Comparer.Default.Compare(e2.GetData("Show"), e1.GetData("Show"))); }; this.uiSystem.Add("Modifiers", modifierUi); @@ -361,7 +371,7 @@ namespace TouchyTickets { IsHidden = true, OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha) }; - optionsUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Options"), true) {TextScale = 0.2F}); + optionsUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("Options"), true) {TextScale = 0.15F}); var optionList = optionsUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1), Vector2.Zero, false, true, new Point(10, 30), false) { ChildPadding = new Padding(5, 15, 5, 5), PreventParentSpill = true @@ -400,7 +410,33 @@ namespace TouchyTickets { }); this.uiSystem.Add("Options", optionsUi); - this.swipeRelations = new Element[] {optionsUi, upgradeUi, main, buyUi, modifierUi}; + var managementUi = new Group(Anchor.TopLeft, Vector2.One, false) { + IsHidden = true, + OnDrawn = (e, time, batch, alpha) => batch.Draw(batch.GetBlankTexture(), e.DisplayArea, ColorExtensions.FromHex(0xff86bccf) * alpha) + }; + managementUi.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("ParkManagement"), true) {TextScale = 0.15F}); + var managementList = managementUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1), Vector2.Zero, false, true, new Point(10, 30), false) { + ChildPadding = new Padding(5, 15, 5, 5), + PreventParentSpill = true + }); + managementList.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("RideStats"), true) { + PositionOffset = new Vector2(0, 4), + TextScale = 0.12F + }); + foreach (var type in AttractionType.Attractions.Values) { + var group = managementList.AddChild(new Group(Anchor.AutoCenter, new Vector2(1)) { + OnUpdated = (e, time) => e.IsHidden = !GameImpl.Instance.Map.TicketsPerRide.ContainsKey(type), + PositionOffset = new Vector2(0, 1) + }); + group.AddChild(new Image(Anchor.AutoLeft, new Vector2(20), Assets.AttractionTexture[type.TextureRegion])); + group.AddChild(new Paragraph(Anchor.CenterLeft, 1, p => { + GameImpl.Instance.Map.TicketsPerRide.TryGetValue(type, out var tickets); + return tickets.ToString("#,0.##") + "/s"; + }, true) {PositionOffset = new Vector2(24, 0)}); + } + this.uiSystem.Add("Management", managementUi); + + this.swipeRelations = new Element[] {optionsUi, upgradeUi, managementUi, main, buyUi, modifierUi}; var swipeTimer = 0D; var swipeInfo = new Group(Anchor.BottomCenter, Vector2.One) { @@ -632,7 +668,8 @@ namespace TouchyTickets { if (!reachedActive && upgrade.IsActive()) { reachedActive = true; upgradeList.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("AppliedUpgrades"), true) { - PositionOffset = new Vector2(0, 4) + PositionOffset = new Vector2(0, 4), + TextScale = 0.12F }); } var button = upgradeList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {