added a section for active upgrades

This commit is contained in:
Ellpeck 2020-06-03 13:46:20 +02:00
parent 77ed4e05ec
commit a64a9ed886
2 changed files with 38 additions and 24 deletions

View file

@ -6,6 +6,7 @@
"Yes": "Yes", "Yes": "Yes",
"Okay": "Okay", "Okay": "Okay",
"RequiresTickets": "1<i star> requires {0}<i ticket>", "RequiresTickets": "1<i star> requires {0}<i ticket>",
"AppliedUpgrades": "Active Upgrades",
"Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!", "Tutorial1": "Hi! Welcome to Touchy Tickets. To start the game, simply tap the ticket booth to sell a <i ticket>. Start by racking up 50<i ticket>!",
"Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.", "Tutorial2": "Great! Now, you can buy your first attraction. Access the menu on the right by swiping and purchase a carousel.",
"Tutorial3": "This is your park map. The area inside the fence is what belongs to you. Place the carousel by dragging it to the perfect location and then pressing the button below.", "Tutorial3": "This is your park map. The area inside the fence is what belongs to you. Place the carousel by dragging it to the perfect location and then pressing the button below.",

View file

@ -204,30 +204,7 @@ namespace TouchyTickets {
var upgradeList = upgradeUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1, 0.73F), Vector2.Zero, false, true, new Point(10, 30), false) { var upgradeList = upgradeUi.AddChild(new Panel(Anchor.AutoLeft, new Vector2(1, 0.73F), Vector2.Zero, false, true, new Point(10, 30), false) {
ChildPadding = new Padding(5, 15, 5, 5) ChildPadding = new Padding(5, 15, 5, 5)
}); });
foreach (var upgrade in Upgrade.Upgrades.Values) { PopulateUpgradeList(upgradeList);
var button = upgradeList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {
SetHeightBasedOnChildren = true,
PositionOffset = new Vector2(0, 1),
ChildPadding = new Vector2(4),
OnPressed = e => {
GameImpl.Instance.Stars -= upgrade.Price;
GameImpl.Instance.AppliedUpgrades.Add(upgrade);
upgrade.OnApplied();
}
});
button.OnUpdated += (e, time) => {
// we want to hide if we're active, or if we still need a dependency to be active
button.IsHidden = upgrade.IsActive() || upgrade.Dependencies.Any(u => !u.IsActive());
button.IsDisabled = GameImpl.Instance.Stars < upgrade.Price;
};
button.AddChild(new Paragraph(Anchor.TopCenter, 1, Localization.Get(upgrade.Name), true));
button.AddChild(new Image(Anchor.CenterLeft, new Vector2(0.2F, 40), upgrade.Texture) {
Padding = new Vector2(4)
});
var right = button.AddChild(new Group(Anchor.TopRight, new Vector2(0.8F, 1)) {CanBeMoused = false});
right.AddChild(new Paragraph(Anchor.TopRight, 1, p => upgrade.Price + "<i star>", true));
right.AddChild(new Paragraph(Anchor.AutoLeft, 1, Localization.Get(upgrade.Name + "Description"), true) {TextScale = 0.08F});
}
this.uiSystem.Add("Upgrade", upgradeUi); this.uiSystem.Add("Upgrade", upgradeUi);
this.swipeRelations = new Element[] {upgradeUi, main, buyUi}; this.swipeRelations = new Element[] {upgradeUi, main, buyUi};
@ -334,6 +311,42 @@ namespace TouchyTickets {
CoroutineHandler.Start(Impl()); CoroutineHandler.Start(Impl());
} }
private static void PopulateUpgradeList(Element upgradeList) {
upgradeList.RemoveChildren(c => !(c is ScrollBar));
var reachedActive = false;
foreach (var upgrade in Upgrade.Upgrades.Values.OrderBy(u => u.IsActive())) {
// the first active upgrade should be preceded by a section separator paragraph
if (!reachedActive && upgrade.IsActive()) {
reachedActive = true;
upgradeList.AddChild(new Paragraph(Anchor.AutoCenter, 1, Localization.Get("AppliedUpgrades"), true) {
PositionOffset = new Vector2(0, 4)
});
}
var button = upgradeList.AddChild(new Button(Anchor.AutoLeft, new Vector2(1)) {
SetHeightBasedOnChildren = true,
PositionOffset = new Vector2(0, 1),
ChildPadding = new Vector2(4),
OnPressed = e => {
GameImpl.Instance.Stars -= upgrade.Price;
GameImpl.Instance.AppliedUpgrades.Add(upgrade);
upgrade.OnApplied();
PopulateUpgradeList(upgradeList);
}
});
button.OnUpdated += (e, time) => {
button.IsHidden = upgrade.Dependencies.Any(u => !u.IsActive());
button.IsDisabled = upgrade.IsActive() || GameImpl.Instance.Stars < upgrade.Price;
};
button.AddChild(new Paragraph(Anchor.TopCenter, 1, Localization.Get(upgrade.Name), true));
button.AddChild(new Image(Anchor.CenterLeft, new Vector2(0.2F, 40), upgrade.Texture) {
Padding = new Vector2(4)
});
var right = button.AddChild(new Group(Anchor.TopRight, new Vector2(0.8F, 1)) {CanBeMoused = false});
right.AddChild(new Paragraph(Anchor.TopRight, 1, p => upgrade.Price + "<i star>", true));
right.AddChild(new Paragraph(Anchor.AutoLeft, 1, Localization.Get(upgrade.Name + "Description"), true) {TextScale = 0.08F});
}
}
private static IEnumerator<IWait> WobbleElement(CustomDrawGroup element, float intensity = 0.02F) { private static IEnumerator<IWait> WobbleElement(CustomDrawGroup element, float intensity = 0.02F) {
var sin = 0F; var sin = 0F;
while (sin < MathHelper.Pi) { while (sin < MathHelper.Pi) {