Esempio n. 1
0
        protected void AddUpgradeButton(GuiList buildingActions, string unitToUpgrade, int tier, Player player)
        {
            StringBuilder buttonText = new StringBuilder();

            buttonText.Append("Upgrade to tier ").Append(tier + 1).Append(": (");
            buttonText.Append(SoldierRegistry.GetUpgradeCost(unitToUpgrade, player.soldierTiers[unitToUpgrade])).Append("G): "); // Soldier ('cost'G)
            buildingActions.addElement(ElementBuildButton.CreateBuildButton(buildingActions.Bounds.Location, buttonText.ToString(), () => { TryUpgradeUnit(unitToUpgrade); }, "Upgrade"));
        }
Esempio n. 2
0
        protected void TryUpgradeUnit(string soldierType)
        {
            int cost = SoldierRegistry.GetUpgradeCost(soldierType, owner.soldierTiers[soldierType]);

            if (!owner.CanAfford(cost))
            {
                return;
            }
            owner.Buy(cost);
            owner.soldierTiers[soldierType] += 1;
        }