diff --git a/ThemeParkClicker/Attractions/Attraction.cs b/ThemeParkClicker/Attractions/Attraction.cs index 9a0fb16..72fe77e 100644 --- a/ThemeParkClicker/Attractions/Attraction.cs +++ b/ThemeParkClicker/Attractions/Attraction.cs @@ -32,10 +32,6 @@ namespace ThemeParkClicker.Attractions { } } - public long GetPrice() { - return this.Type.InitialPrice; - } - public void Update(GameTime time, TimeSpan passed) { this.ticketPercentage += this.Type.GenerationPerSecond * (float) passed.TotalSeconds; var amount = this.ticketPercentage.Floor(); diff --git a/ThemeParkClicker/ParkMap.cs b/ThemeParkClicker/ParkMap.cs index 824ac38..1649417 100644 --- a/ThemeParkClicker/ParkMap.cs +++ b/ThemeParkClicker/ParkMap.cs @@ -108,5 +108,9 @@ namespace ThemeParkClicker { return null; } + public int GetAttractionAmount(AttractionType type) { + return this.attractions.Count(a => a.Item2.Type == type); + } + } } \ No newline at end of file diff --git a/ThemeParkClicker/Ui.cs b/ThemeParkClicker/Ui.cs index 2634ede..c11313d 100644 --- a/ThemeParkClicker/Ui.cs +++ b/ThemeParkClicker/Ui.cs @@ -108,7 +108,7 @@ namespace ThemeParkClicker { IsHidden = true }; foreach (var attraction in AttractionType.Attractions) { - var instance = attraction.Value.Create(); + BigInteger price = 0; var button = buyUi.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 40)) { ChildPadding = new Vector2(4), Padding = new Padding(0, 0, 0, 4), @@ -125,7 +125,7 @@ namespace ThemeParkClicker { }); yesNoUi.AddChild(new Button(Anchor.AutoInlineIgnoreOverflow, new Vector2(0.5F, 40), "Place") { OnPressed = e2 => { - GameImpl.Instance.Tickets -= map.PlacingAttraction.GetPrice(); + GameImpl.Instance.Tickets -= price; map.Place(map.PlacingPosition, map.PlacingAttraction); this.FadeUi(false, () => this.uiSystem.Remove(e2.Root.Name)); }, @@ -135,19 +135,24 @@ namespace ThemeParkClicker { this.uiSystem.Add("PlacingYesNo", yesNoUi).Priority = -100; this.FadeUi(true); + }, + OnAreaUpdated = e => { + // only update the price when the area updates, since it won't change while we're in the buy ui + var markup = GameImpl.Instance.Map.GetAttractionAmount(attraction.Value) * 0.05F; + price = (attraction.Value.InitialPrice * (1 + markup)).Ceil(); } }); button.OnUpdated += (e, time) => { - button.IsDisabled = GameImpl.Instance.Tickets < instance.GetPrice(); + button.IsDisabled = GameImpl.Instance.Tickets < price; }; var center = button.AddChild(new Group(Anchor.Center, new Vector2(0.8F, 1), false) {CanBeMoused = false}); center.AddChild(new Paragraph(Anchor.AutoCenter, 1, attraction.Key, true)); - center.AddChild(new Paragraph(Anchor.AutoCenter, 1, instance.Type.GenerationPerSecond + "/s", true) {TextScale = 0.08F}); - var image = button.AddChild(new Image(Anchor.CenterLeft, new Vector2(1), instance.Type.TextureRegion) { + center.AddChild(new Paragraph(Anchor.AutoCenter, 1, attraction.Value.GenerationPerSecond + "/s", true) {TextScale = 0.08F}); + var image = button.AddChild(new Image(Anchor.CenterLeft, new Vector2(1), attraction.Value.TextureRegion) { Padding = new Vector2(4) }); button.OnAreaUpdated += e => image.Size = new Vector2(e.DisplayArea.Height / e.Scale); - button.AddChild(new Paragraph(Anchor.CenterRight, 1, p => instance.GetPrice() + "", true)); + button.AddChild(new Paragraph(Anchor.CenterRight, 1, p => price + "", true)); } this.uiSystem.Add("Buy", buyUi);