protected float DrawGeneralSetting(float startX, float startY, UnitTower unit) { string textF = "General Tower Setting "; //+(!foldBasicSetting ? "(show)" : "(hide)"); foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS); if (!foldBasicSetting) { return(startY); } startX += 12; //TDE.Label(startX, startY+=spaceY, width, height, "Turret:", ""); //unit.isTurret=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isTurret); //TDE.Label(startX, startY+=spaceY, width, height, "AOE:", ""); //unit.isAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isAOE); //TDE.Label(startX, startY+=spaceY, width, height, "Support:", ""); //unit.isSupport=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSupport); //TDE.Label(startX, startY+=spaceY, width, height, "Resource:", ""); //unit.isResource=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isResource); //TDE.Label(startX, startY+=spaceY, width, height, "Mine:", ""); //unit.isMine=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isMine); ////TDE.Label(startX, startY+=spaceY, width, height, "Turret:", ""); ////unit.isSpawner=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSpawner); //startY+=10; if (unit.IsTurret() || unit.IsAOE() || unit.IsMine()) { int tgtGroup = (int)unit.targetGroup; cont = new GUIContent("Target Group:", "The target group of the tower"); contL = TDE.SetupContL(targetGroupLabel, targetGroupTooltip); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); tgtGroup = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), tgtGroup, contL); unit.targetGroup = (UnitTower._TargetGroup)tgtGroup; } startY = DrawUnitSetting(startX - 12, startY, unit); return(startY); }
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); }
//public bool IsBlocked1(){ return walkable & (occupiedTower==null || occupiedTower.IsMine()); } public bool IsBlocked() { return(!walkable || (occupiedTower != null && !occupiedTower.IsMine())); }