public static void Init(int prefabID = -1) { // Get existing open window or if none, make a new one: window = (UnitTowerEditorWindow)EditorWindow.GetWindow(typeof(UnitTowerEditorWindow), false, "Tower Editor"); window.minSize = new Vector2(420, 300); LoadDB(); InitLabel(); if (prefabID >= 0) { window.selectID = TDEditor.GetTowerIndex(prefabID) - 1; } window.SetupCallback(); }
protected float DrawTowerUpgradeSetting(float startX, float startY, UnitTower tower) { //EditorGUI.LabelField(new Rect(startX, startY, width, height), "Upgrade Setting", headerStyle); string text = "Upgrade Setting " + (!foldUpgrade ? "(show)" : "(hide)"); foldUpgrade = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldUpgrade, text, foldoutStyle); if (foldUpgrade) { startX += 15; int ID = 0; cont = new GUIContent("Prev lvl Tower:", "Tower prefab which this current selected tower is upgrade from. If blank then this is the base tower (level 1). "); GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont); if (tower.prevLevelTower != null) { GUI.Label(new Rect(startX + spaceX, startY, 105, height), tower.prevLevelTower.unitName); if (GUI.Button(new Rect(startX + spaceX + width, startY, 48, 15), "Select")) { SelectItem(TDEditor.GetTowerIndex(tower.prevLevelTower.prefabID)); } } else { GUI.Label(new Rect(startX + spaceX, startY, 105, height), "-"); } startY += 5; cont = new GUIContent("level within Prefab:", "How many level the prefab can be upgrade before switching to next level tower"); GUI.Label(new Rect(startX, startY += spaceY, width, height), cont); if (GUI.Button(new Rect(startX + spaceX, startY, widthS, 15), "-1")) { if (tower.stats.Count > 1) { tower.stats.RemoveAt(tower.stats.Count - 1); } } if (GUI.Button(new Rect(startX + spaceX + widthS + 5, startY, widthS, 15), "+1")) { tower.stats.Add(tower.stats[tower.stats.Count - 1].Clone()); } startY += 5; //if(tower.nextLevelTowerList.Count==0) tower.nextLevelTowerList.Add(null); while (tower.nextLevelTowerList.Count < 2) { tower.nextLevelTowerList.Add(null); } while (tower.nextLevelTowerList.Count > 2) { tower.nextLevelTowerList.RemoveAt(tower.nextLevelTowerList.Count - 1); } cont = new GUIContent("Next level Tower 1:", "Tower prefab to be used beyond the stats level specified for this prefab"); GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont); ID = tower.nextLevelTowerList[0] != null?TDEditor.GetTowerIndex(tower.nextLevelTowerList[0].prefabID) : 0; ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), ID, towerLabel); if (ID > 0 && towerDB.towerList[ID - 1] != tower && !tower.nextLevelTowerList.Contains(towerDB.towerList[ID - 1])) { tower.nextLevelTowerList[0] = towerDB.towerList[ID - 1]; } else if (ID == 0) { if (tower.nextLevelTowerList[1] != null) { tower.nextLevelTowerList[0] = tower.nextLevelTowerList[1]; tower.nextLevelTowerList[1] = null; } else { tower.nextLevelTowerList[0] = null; } } if (tower.nextLevelTowerList[0] != null) { if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, widthS + 10, 15), "Select")) { if (tower.nextLevelTowerList[0] != null) { SelectItem(ID - 1); } } } cont = new GUIContent("Next level Tower 2:", "Tower prefab to be used beyond the stats level specified for this prefab"); GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont); if (tower.nextLevelTowerList[0] != null) { ID = tower.nextLevelTowerList[1] != null?TDEditor.GetTowerIndex(tower.nextLevelTowerList[1].prefabID) : 0; ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), ID, towerLabel); if (ID > 0 && towerDB.towerList[ID - 1] != tower && !tower.nextLevelTowerList.Contains(towerDB.towerList[ID - 1])) { tower.nextLevelTowerList[1] = towerDB.towerList[ID - 1]; } else if (ID == 0) { tower.nextLevelTowerList[1] = null; } if (tower.nextLevelTowerList[1] != null) { if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, widthS + 10, 15), "Select")) { if (tower.nextLevelTowerList[1] != null) { SelectItem(ID - 1); } } } } else { GUI.Label(new Rect(startX + spaceX, startY, width, height), "-"); } } return(startY + spaceY); }