Пример #1
0
        public bool UpgradeToNextTower(int ID = 0)
        {
            UnitTower nextLevelTower = nextLevelTowerList[Mathf.Clamp(ID, 0, nextLevelTowerList.Count)];

            int  cost       = GetCost();
            bool isSuffCost = ResourceManager.HasSufficientResource(cost);

            if (isSuffCost == true)
            {
                ResourceManager.SpendResource(cost);

                GameObject towerObj      = (GameObject)Instantiate(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);
                }
                Destroy(thisObj);
                return(true);
            }
            return(false);
            //"Insufficient Resource";
        }
Пример #2
0
        public string UpgradeToNextTower(int ID = 0)
        {
            UnitTower nextLevelTower = nextLevelTowerList[Mathf.Clamp(ID, 0, nextLevelTowerList.Count)];

            GameObject towerObj      = (GameObject)Instantiate(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(true);
            GameControl.SelectTower(towerInstance);

            Destroy(thisObj);
            return("");
        }