public static void RemoveTower(UnitTower tower) { if (tower.IsSupport()) { for (int i = 0; i < tower.supportTgtList.Count; i++) { tower.SupportUnbuffTower(tower.supportTgtList[i], false); } } else { for (int i = 0; i < tower.supportSrcList.Count; i++) { tower.supportSrcList[i].SupportUnbuffTower(tower); } } }
public static void RemoveTower(UnitTower tower) { instance.activeTowerList.Remove(tower); if (tower.IsSupport()) { instance.supportTowerList.Remove(tower); } UnitTower.RemoveTower(tower); //for limiting tower count in the scene according to prefabID int idx = instance.towerCounterPrefabID.IndexOf(tower.prefabID); if (idx >= 0) { instance.towerCounterList[idx] -= 1; } TDTK.OnNewTower(null); }
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); }
public static void NewTower(UnitTower tower) { if (tower.IsSupport()) { List <UnitTower> allTowerList = TowerManager.GetActiveTowerList(); for (int i = 0; i < allTowerList.Count; i++) { if (allTowerList[i].IsSupport()) { continue; } if (allTowerList[i] == tower) { continue; } float dist = Vector3.Distance(allTowerList[i].GetPos(), tower.GetPos()); if (dist < tower.GetAttackRange()) { tower.SupportBuffTower(allTowerList[i]); } } } else { List <UnitTower> supportTowerList = TowerManager.GetSupportTowerList(); for (int i = 0; i < supportTowerList.Count; i++) { float dist = Vector3.Distance(supportTowerList[i].GetPos(), tower.GetPos()); if (dist < supportTowerList[i].GetAttackRange()) { supportTowerList[i].SupportBuffTower(tower); } } } }
protected float DrawTowerStats(float startX, float startY, UnitTower unit) { string textF = "Tower Stats And Upgrade"; //+(!foldStats ? "(show)" : "(hide)"); foldStats = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldStats, textF, TDE.foldoutS); if (!foldStats) { return(startY); } startX += 15; TDE.Label(startX, startY += spaceY, width, height, "Next Upgrade:", "The tower prefab this tower can be upgraded to"); for (int i = 0; i < unit.upgradeTowerList.Count; i++) { if (unit.upgradeTowerList[i] == null) { unit.upgradeTowerList.RemoveAt(i); i -= 1; continue; } TDE.Label(startX + spaceX - 20, startY, width, height, " - ", ""); int idx = TowerDB.GetPrefabIndex(unit.upgradeTowerList[i]); idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, TowerDB.label); if (TowerDB.GetItem(idx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(idx))) { unit.upgradeTowerList[i] = TowerDB.GetItem(idx); } if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, height, height), "-")) { unit.upgradeTowerList.RemoveAt(i); i -= 1; continue; } startY += spaceY; } int newIdx = -1; if (unit.upgradeTowerList.Count > 0) { TDE.Label(startX + spaceX - 65, startY, width, height, " Add New:", ""); } newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label); if (newIdx >= 0 && TowerDB.GetItem(newIdx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(newIdx))) { Debug.Log("new index " + newIdx + " " + TowerDB.GetItem(newIdx)); unit.upgradeTowerList.Add(TowerDB.GetItem(newIdx)); } startY += 10; //~ if(GUI.Button(new Rect(startX+spaceX+15, startY, width, height), "Add Level")) { if (GUI.Button(new Rect(startX, startY + spaceY, width, height), "Add Level")) { unit.statsList.Add(new Stats()); unit.statsList[unit.statsList.Count - 1].ResetAsBaseStat(); foldStats = true; } startY += spaceY; blockWidth = spaceX + 2 * widthS + 26; float cachedX = startX; float cachedY = (startY += spaceY); for (int i = 0; i < unit.statsList.Count; i++) { GUI.Box(new Rect(startX, cachedY, blockWidth, blockHeight), ""); EditorGUI.LabelField(new Rect(startX + 6, startY += 3, width, height), "Level " + (i + 1), TDE.headerS); GUI.color = new Color(1f, .25f, .25f, 1f); if (GUI.Button(new Rect(startX + blockWidth - 1.5f * widthS - 3, startY, widthS * 1.5f, 14), "remove")) { if (unit.statsList.Count > 1) { unit.statsList.RemoveAt(i); i -= 1; } } GUI.color = Color.white; _EType tType = _EType.TAOE; if (unit.IsTurret()) { tType = _EType.TTurret; } else if (unit.IsSupport()) { tType = _EType.TSupport; } else if (unit.IsResource()) { tType = _EType.TRsc; } else if (unit.IsMine()) { tType = _EType.TMine; } else if (unit.IsBlock()) { tType = _EType.TBlock; } blockHeight = DrawStats(startX, startY + spaceY + 3, unit.statsList[i], tType, true) - cachedY + 5; startY = cachedY; startX += blockWidth + 10; maxX = startX; } startY += blockHeight; startX = cachedX - 15; return(startY); }