Beispiel #1
0
        public static int GetCostForThing(TowerModel towerModel)
        {
            var cost = Game.instance.model.GetTowerWithName(towerModel.name).cost;

            foreach (var appliedUpgrade in towerModel.GetAppliedUpgrades())
            {
                cost += appliedUpgrade.cost;
            }

            switch (InGame.instance.SelectedDifficulty)
            {
            case "Easy":
                cost *= .85f;
                break;

            case "Hard":
                cost *= 1.08f;
                break;

            case "Impoppable":
                cost *= 1.2f;
                break;
            }

            cost *= 1 - .05f * towerModel.tier;
            return((int)(5 * Math.Round(cost / 5)));
        }
        /// <summary>
        /// Return the UpgradeModel for a specific upgrade path/tier
        /// </summary>
        /// <param name="path"></param>
        /// <param name="tier"></param>
        public static UpgradeModel GetUpgrade(this TowerModel towerModel, int path, int tier)
        {
            if (path < 0 || tier < 0)
            {
                return(null);
            }

            int tier1 = (path == 0) ? tier : 0;
            int tier2 = (path == 1) ? tier : 0;
            int tier3 = (path == 2) ? tier : 0;


            TowerModel tempTower = Game.instance?.model?.GetTower(towerModel.GetBaseId(), tier1, tier2, tier3);

            if (tempTower is null)
            {
                return(null);
            }

            const int           offset          = 1;
            List <UpgradeModel> appliedUpgrades = tempTower.GetAppliedUpgrades();
            UpgradeModel        results         =
                appliedUpgrades.FirstOrDefault(model => model.path == path && model.tier == (tier - offset));

            return(null);
        }
 /// <summary>
 /// Check if an upgrade has been applied
 /// </summary>
 /// <param name="upgradeModel"></param>
 /// <returns></returns>
 public static bool HasUpgrade(this TowerModel towerModel, UpgradeModel upgradeModel)
 {
     return(towerModel.GetAppliedUpgrades().Contains(upgradeModel));
 }
        /// <summary>
        /// Check if a specific upgrade path is being used/ has any upgrades applied to it
        /// </summary>
        /// <param name="path">Upgrade path to check</param>
        public static bool IsUpgradePathUsed(this TowerModel towerModel, int path)
        {
            UpgradeModel result = towerModel.GetAppliedUpgrades().FirstOrDefault(upgrade => upgrade.path == path);

            return(result != null);
        }