Пример #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("");
        }
Пример #3
0
        public void BuildTower(Vector3 pos, UnitTower tower)
        {
            //pathfinding related code, only call if this platform is walkable;
            if(!walkable) return;

            NodeTD node=PathFinder.GetNearestNode(pos, nodeGraph);
            node.walkable=false;
            tower.SetPlatform(this, node);

            //if the node has been check before during CheckForBlock(), just use the altPath
            if(node==nextBuildNode){
                for(int i=0; i<subPathList.Count; i++){
                    if(subPathList[i].IsNodeInPath(node)) subPathList[i].SwitchToSubPath();
                }
                return;
            }

            for(int i=0; i<subPathList.Count; i++){
                if(subPathList[i].IsNodeInPath(node)) subPathList[i].SearchNewPath(nodeGraph);
            }
        }
Пример #4
0
        public void BuildTower(Vector3 pos, UnitTower tower)
        {
            //pathfinding related code, only call if this platform is walkable;
            if (!walkable)
            {
                return;
            }

            if (tower.type != _TowerType.Mine)
            {
                NodeTD node = PathFinder.GetNearestNode(pos, nodeGraph);
                node.walkable = false;
                tower.SetPlatform(this, node);

                //if the node has been check before during CheckForBlock(), just use the altPath
                if (node == nextBuildNode)
                {
                    for (int i = 0; i < subPathList.Count; i++)
                    {
                        if (subPathList[i].IsNodeInPath(node))
                        {
                            subPathList[i].SwitchToSubPath();
                        }
                    }
                    return;
                }

                for (int i = 0; i < subPathList.Count; i++)
                {
                    if (subPathList[i].IsNodeInPath(node))
                    {
                        subPathList[i].SearchNewPath(nodeGraph);
                    }
                }
            }
        }