only show attractions if they're "unlocked"
This commit is contained in:
parent
64cd304878
commit
38f8537408
1 changed files with 16 additions and 6 deletions
|
@ -130,6 +130,7 @@ namespace TouchyTickets {
|
|||
};
|
||||
foreach (var attraction in AttractionType.Attractions) {
|
||||
BigInteger price = 0;
|
||||
var attractionAmount = 0;
|
||||
var button = buyUi.AddChild(new Button(Anchor.AutoLeft, new Vector2(1, 40)) {
|
||||
ChildPadding = new Vector2(4),
|
||||
PositionOffset = new Vector2(0, 1),
|
||||
|
@ -161,19 +162,28 @@ namespace TouchyTickets {
|
|||
},
|
||||
OnAreaUpdated = e => {
|
||||
// only update the price when the area updates, since it won't change while we're in the buy ui
|
||||
var amount = GameImpl.Instance.Map.GetAttractionAmount(attraction.Value);
|
||||
attractionAmount = GameImpl.Instance.Map.GetAttractionAmount(attraction.Value);
|
||||
// yay compound interest
|
||||
price = (attraction.Value.InitialPrice * (float) Math.Pow(1 + 0.1F, amount)).Ceil();
|
||||
price = (attraction.Value.InitialPrice * (float) Math.Pow(1 + 0.1F, attractionAmount)).Ceil();
|
||||
}
|
||||
});
|
||||
button.OnUpdated += (e, time) => button.IsDisabled = GameImpl.Instance.Tickets < price;
|
||||
button.AddChild(new Image(Anchor.CenterLeft, new Vector2(0.2F, 40), attraction.Value.TextureRegion) {
|
||||
var image = button.AddChild(new Image(Anchor.CenterLeft, new Vector2(0.2F, 40), attraction.Value.TextureRegion) {
|
||||
Padding = new Vector2(4)
|
||||
});
|
||||
var right = button.AddChild(new Group(Anchor.TopRight, new Vector2(0.8F, 1), false) {CanBeMoused = false});
|
||||
right.AddChild(new Paragraph(Anchor.TopLeft, 1, Localization.Get(attraction.Key), true));
|
||||
right.AddChild(new Paragraph(Anchor.BottomLeft, 1, p => attraction.Value.GetGenerationRate() + "<i ticket>/s", true) {TextScale = 0.08F});
|
||||
var name = right.AddChild(new Paragraph(Anchor.TopLeft, 1, Localization.Get(attraction.Key), true));
|
||||
var hiddenName = right.AddChild(new Paragraph(Anchor.TopLeft, 1, "?????", true) {TextColor = Color.Gray});
|
||||
var genRate = right.AddChild(new Paragraph(Anchor.BottomLeft, 1, p => attraction.Value.GetGenerationRate() + "<i ticket>/s", true) {TextScale = 0.08F});
|
||||
right.AddChild(new Paragraph(Anchor.BottomRight, 1, p => PrettyPrintNumber(price) + "<i ticket>", true));
|
||||
button.OnUpdated += (e, time) => {
|
||||
button.IsDisabled = GameImpl.Instance.Tickets < price;
|
||||
// we only want to show the info if we have enough tickets or we've placed the thing before
|
||||
var shouldShow = !button.IsDisabled || attractionAmount > 0;
|
||||
image.Color = shouldShow ? Color.White : Color.Black;
|
||||
name.IsHidden = !shouldShow;
|
||||
genRate.IsHidden = !shouldShow;
|
||||
hiddenName.IsHidden = shouldShow;
|
||||
};
|
||||
}
|
||||
this.uiSystem.Add("Buy", buyUi);
|
||||
|
||||
|
|
Loading…
Reference in a new issue