Example #1
0
        public string UpgradeToNextTower(int ID = 0)
        {
            UnitTower nextLevelTower = nextLevelTowerList[Mathf.Clamp(ID, 0, nextLevelTowerList.Count)];

            List <int> cost     = GetCost();
            int        suffCost = ResourceManager.HasSufficientResource(cost);

            if (suffCost == -1)
            {
                ResourceManager.SpendResource(cost);

                GameObject towerObj      = (GameObject)ObjectPoolManager.Spawn(nextLevelTower.gameObject, thisT.position, thisT.rotation);
                UnitTower  towerInstance = towerObj.GetComponent <UnitTower>();
                towerInstance.InitTower(instanceID);
                towerInstance.SetPlatform(occupiedPlatform, occupiedNode);
                towerInstance.AddValue(value);
                towerInstance.SetLevel(level + 1);
                towerInstance.Build();
                GameControl.SelectTower(towerInstance);

                if (onUpgradedE != null)
                {
                    onUpgradedE(towerInstance);
                }

                ObjectPoolManager.Unspawn(thisObj);

                return("");
            }
            return("Insufficient Resource");
        }