示例#1
0
        public static void AddTower(UnitTower tower, BuildPlatform platform = null, int nodeID = -1)
        {
            tower.isPreview = false;

            tower.instanceID       = instance.towerCounter;
            instance.towerCounter += 1;
            instance.activeTowerList.Add(tower);

            if (tower.IsSupport())
            {
                instance.supportTowerList.Add(tower);
            }

            if (platform != null && nodeID >= 0)
            {
                tower.SetBuildPoint(platform, nodeID);
                platform.BuildTower(nodeID, tower);
            }



            //for limiting tower count in the scene according to prefabID
            int idx = instance.towerCounterPrefabID.IndexOf(tower.prefabID);

            if (idx < 0)
            {
                instance.towerCounterPrefabID.Add(tower.prefabID);
                instance.towerCounterList.Add(1);
            }
            else
            {
                instance.towerCounterList[idx] += 1;
            }

            UnitTower.NewTower(tower);

            TDTK.OnNewTower(tower);
        }