Esempio n. 1
0
 private void Awake()
 {
     this.NormalInventory  = this.normalInventory.GetComponent <NormalInventory>();
     this.EqInventory      = this.equipmentInventory.GetComponent <EqInventory>();
     this.InGameOptions    = this.optionsMenu.GetComponent <InGameOptions>();
     this.championsButtons = this.teamChoose.GetComponentsInChildren <AvatarButton>();
     this.player           = GameSave.Instance.Player;
 }
        public void VerifyUpgradeCosts(int i_level)
        {
            mUpgrade.Value = i_level;

            NormalInventory inventory = new NormalInventory();

            foreach (KeyValuePair <string, int> cost in mUpgrade.ResourcesToUpgrade)
            {
                int amount = (int)Math.Ceiling(cost.Value * Math.Pow(mUpgrade.UpgradeData.Coefficient, mUpgrade.Value - 1));
                inventory.SetResource(cost.Key, amount);
            }

            bool canAffordUpgrade = mUpgrade.CanAffordUpgrade(inventory);

            Assert.IsTrue(canAffordUpgrade);
        }
Esempio n. 3
0
        public void CanAffordNewTrainer_RealInventory(int i_numTrainers, int i_expectedCostForNextTrainer)
        {
            Dictionary <string, int> trainers = new Dictionary <string, int>();

            trainers.Add(TrainerManager.NORMAL_TRAINERS, i_numTrainers);
            mTrainerData = new TrainerManager(new ViewModel(), CreateTrainerSaveData_WithCounts(trainers), new Dictionary <string, UnitProgress>());

            int             costForNextTrainer = mTrainerData.GetNextTrainerCost();
            NormalInventory realInventory      = new NormalInventory();

            realInventory.SetResource(VirtualCurrencies.GOLD, costForNextTrainer);

            bool canAfford = mTrainerData.CanAffordTrainerPurchase(realInventory);

            Assert.IsTrue(canAfford);
        }
Esempio n. 4
0
        public void VerifyNextTrainerPurchaseSpendsResources(int i_numTrainers, int i_expectedCostForNextTrainer)
        {
            Dictionary <string, int> trainers = new Dictionary <string, int>();

            trainers.Add(TrainerManager.NORMAL_TRAINERS, i_numTrainers);
            mTrainerData = new TrainerManager(new ViewModel(), CreateTrainerSaveData_WithCounts(trainers), new Dictionary <string, UnitProgress>());

            int             costForNextTrainer = mTrainerData.GetNextTrainerCost();
            NormalInventory realInventory      = new NormalInventory();

            realInventory.SetResource(VirtualCurrencies.GOLD, costForNextTrainer);

            mTrainerData.InitiateTrainerPurchase(realInventory);

            Assert.AreEqual(realInventory.GetResourceCount(VirtualCurrencies.GOLD), 0);
        }
        public void VerifyUpgradeSpendDeduction(int i_level)
        {
            mUpgrade.Value = i_level;

            NormalInventory inventory = new NormalInventory();

            foreach (KeyValuePair <string, int> cost in mUpgrade.ResourcesToUpgrade)
            {
                int amount = (int)Math.Ceiling(cost.Value * Math.Pow(mUpgrade.UpgradeData.Coefficient, mUpgrade.Value));
                inventory.SetResource(cost.Key, amount);
            }

            if (mUpgrade.CanUpgrade(inventory))
            {
                mUpgrade.InitiateUpgradeWithResources(inventory);

                foreach (KeyValuePair <string, int> cost in mUpgrade.ResourcesToUpgrade)
                {
                    string resource        = cost.Key;
                    int    remainingAmount = inventory.GetResourceCount(resource);
                    Assert.AreEqual(0, remainingAmount);
                }
            }
        }