65 lines
No EOL
3.1 KiB
C#
65 lines
No EOL
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Microsoft.Xna.Framework;
|
|
using MLEM.Extensions;
|
|
using MLEM.Textures;
|
|
|
|
namespace TouchyTickets {
|
|
public class Upgrade {
|
|
|
|
public static readonly Dictionary<string, Upgrade> Upgrades = new Dictionary<string, Upgrade>();
|
|
public static readonly Upgrade[] MapSize = RegisterTiers("MapSize", 5, 1, 1, new Point(0, 3));
|
|
public static readonly Upgrade[] TapIncrease = RegisterTiers("TapIncrease", 3, 1, 0.5F, new Point(6, 3));
|
|
public static readonly Upgrade[] ModifierIncrease = RegisterTiers("ModifierIncrease", 3, 1, 1.5F, new Point(9, 3));
|
|
public static readonly Upgrade[] AutoPlaceModifiers = RegisterTiers("AutoPlaceModifiers", 2, 6, 1, new Point(10, 3));
|
|
public static readonly Upgrade FerrisWheelModifier = Register(new Upgrade("FerrisWheelModifier", 1, new Point(2, 3)));
|
|
public static readonly Upgrade NatureModifier = Register(new Upgrade("NatureModifier", 1, new Point(8, 3)));
|
|
public static readonly Upgrade FoodCourtModifier = Register(new Upgrade("FoodCourtModifier", 2, new Point(1, 3)));
|
|
public static readonly Upgrade RollerCoasterModifier = Register(new Upgrade("RollerCoasterModifier", 2, new Point(3, 3)));
|
|
public static readonly Upgrade ManualRideModifier = Register(new Upgrade("ManualRideModifier", 2, new Point(4, 3)));
|
|
public static readonly Upgrade SpiralSlideModifier = Register(new Upgrade("SpiralSlideModifier", 2, new Point(5, 3)));
|
|
public static readonly Upgrade HauntedHouseModifier = Register(new Upgrade("HauntedHouseModifier", 2, new Point(7, 3)));
|
|
|
|
public readonly string Name;
|
|
public readonly int Price;
|
|
public readonly Point Texture;
|
|
public readonly Upgrade[] Dependencies;
|
|
|
|
public Upgrade(string name, int price, Point texture, params Upgrade[] dependencies) {
|
|
this.Name = name;
|
|
this.Price = price;
|
|
this.Texture = texture;
|
|
this.Dependencies = dependencies;
|
|
}
|
|
|
|
private static Upgrade[] RegisterTiers(string name, int amount, int startPrice, float priceIncrease, Point texture) {
|
|
var ret = new Upgrade[amount];
|
|
for (var i = 0; i < amount; i++) {
|
|
// every tier except first depends on last tier
|
|
var deps = i == 0 ? Array.Empty<Upgrade>() : new[] {ret[i - 1]};
|
|
var price = (startPrice * (1 + i * priceIncrease)).Floor();
|
|
Register(ret[i] = new Upgrade(name + (i + 1), price, texture, deps));
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
public void OnApplied() {
|
|
// map size upgrades
|
|
if (MapSize.Contains(this)) {
|
|
var oldMap = GameImpl.Instance.Map;
|
|
GameImpl.Instance.Map = oldMap.Copy(oldMap.Width + 10, oldMap.Height + 10);
|
|
}
|
|
}
|
|
|
|
private static Upgrade Register(Upgrade upgrade) {
|
|
Upgrades.Add(upgrade.Name, upgrade);
|
|
return upgrade;
|
|
}
|
|
|
|
public bool IsActive() {
|
|
return GameImpl.Instance.AppliedUpgrades.Contains(this);
|
|
}
|
|
|
|
}
|
|
} |