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); }
protected float DrawEffectSetting(float startX, float startY, Perk item) { //TDE.Label(startX, startY, spaceX*2, height, "Perk Effect Attribute", "", TDE.headerS); startY+=spaceY; string text = "Perk Effect Attribute "; //+ (!foldStats ? "(show)" : "(hide)"); foldStats = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldStats, text, TDE.foldoutS); if (!foldStats) { return(startY + spaceY); } startY += spaceY; startX += 12; if (item.type == _PerkType.NewTower) { TDE.Label(startX, startY, width, height, "New Tower:", "The new tower to be added to game"); item.newTowerPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newTowerPID, TowerDB.label); TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting tower that will be replaced"); item.replaceTowerPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceTowerPID, TowerDB.label); } else if (item.type == _PerkType.NewAbility) { TDE.Label(startX, startY, width, height, "New Ability:", "The new ability to be added to game"); item.newAbilityPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newAbilityPID, AbilityDB.label); TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting ability that will be replaced"); item.replaceAbilityPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceAbilityPID, AbilityDB.label); } else if (item.UseGainValue() || item.UseGainList()) { startY = DrawEffectTypeSetting(startX, startY, item); string txtType = item.IsMultiplier() ? "Multiplier:" : "Modifier:"; if (!item.SupportModNMul()) { txtType = "Gain:"; } if (item.UseGainValue()) { string txt = item.UseGainList() ? "Global " : ""; TDE.Label(startX, startY, width, height, txt + txtType); //"Gain Value:", ""); item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain); startY += spaceY; } if (item.UseGainList()) { if (item.gainList.Count < RscDB.GetCount()) { item.gainList.Add(0); } if (item.gainList.Count > RscDB.GetCount()) { item.gainList.Remove(item.gainList.Count - 1); } for (int i = 0; i < item.gainList.Count; i++) { TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(i)); TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i)); //" - "+txtType, ""); item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gainList[i]); if (i < item.gainList.Count - 1) { startY += spaceY; } } } else { startY -= spaceY; } } else if (item.UseStats()) { string textItem = ""; if (item.type == _PerkType.ModifyTower) { textItem = "towers"; } if (item.type == _PerkType.ModifyAbility) { textItem = "abilities"; } if (item.type == _PerkType.ModifyEffect) { textItem = "effects"; } TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all " + textItem); item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll); if (!item.applyToAll) { startY += spaceY; if (item.type == _PerkType.ModifyTower) { TDE.Label(startX, startY, width, height, "Target Tower:", "The target towers which this perk should be applied to"); for (int i = 0; i < item.towerPIDList.Count; i++) { if (item.towerPIDList[i] < 0) { item.towerPIDList.RemoveAt(i); i -= 1; continue; } int index = TowerDB.GetPrefabIndex(item.towerPIDList[i]); index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, TowerDB.label); int prefabID = TowerDB.GetItem(index).prefabID; if (prefabID != item.prefabID && !item.towerPIDList.Contains(prefabID)) { item.towerPIDList[i] = prefabID; } if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-")) { item.towerPIDList.RemoveAt(i); i -= 1; } startY += spaceY; } int newIdx = -1; newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label); if (newIdx >= 0 && !item.towerPIDList.Contains(TowerDB.GetItem(newIdx).prefabID)) { item.towerPIDList.Add(TowerDB.GetItem(newIdx).prefabID); } } if (item.type == _PerkType.ModifyAbility) { TDE.Label(startX, startY, width, height, "Target Ability:", "The target abilities which this perk should be applied to"); for (int i = 0; i < item.abilityPIDList.Count; i++) { int index = AbilityDB.GetPrefabIndex(item.abilityPIDList[i]); index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, AbilityDB.label); int prefabID = AbilityDB.GetItem(index).prefabID; if (prefabID != item.prefabID && !item.abilityPIDList.Contains(prefabID)) { item.abilityPIDList[i] = prefabID; } if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-")) { item.abilityPIDList.RemoveAt(i); i -= 1; } startY += spaceY; } int newIdx = -1; newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, AbilityDB.label); if (newIdx >= 0 && !item.abilityPIDList.Contains(AbilityDB.GetItem(newIdx).prefabID)) { item.abilityPIDList.Add(AbilityDB.GetItem(newIdx).prefabID); } } if (item.type == _PerkType.ModifyEffect) { TDE.Label(startX, startY, width, height, "Target Effect:", "The target effects which this perk should be applied to"); for (int i = 0; i < item.effectPIDList.Count; i++) { int index = EffectDB.GetPrefabIndex(item.effectPIDList[i]); index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, EffectDB.label); int prefabID = EffectDB.GetItem(index).prefabID; if (prefabID != item.prefabID && !item.effectPIDList.Contains(prefabID)) { item.effectPIDList[i] = prefabID; } if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-")) { item.effectPIDList.RemoveAt(i); i -= 1; } startY += spaceY; } int newIdx = -1; newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, EffectDB.label); if (newIdx >= 0 && !item.effectPIDList.Contains(EffectDB.GetItem(newIdx).prefabID)) { item.effectPIDList.Add(EffectDB.GetItem(newIdx).prefabID); } } } startY += spaceY + 10; startY = DrawEffectTypeSetting(startX, startY, item) - spaceY; startY += spaceY; _EType eType = _EType.PerkT; if (item.type == _PerkType.ModifyAbility) { eType = _EType.PerkA; TDE.Label(startX, startY, width, height, "Use Limit:", "Modify the use limit of the ability"); if (item.effType == Perk._EffType.Multiplier) { TDE.Label(startX + spaceX, startY, widthS, height, "-"); } else { item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain); } TDE.Label(startX, startY += spaceY, width, height, "Cost:", "Modify/Multiply the activation cost of the ability"); item.costMul = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.costMul); startY += spaceY; } else if (item.type == _PerkType.ModifyEffect) { eType = _EType.PerkE; TDE.Label(startX, startY, width, height, "Duration:", "Modify the duration of the effect"); item.effect.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.effect.duration); TDE.Label(startX, startY += spaceY + 5, width, height, "Stun:", "Check to enable the effec to stun. This will only override the default value if it's set to true"); item.effect.stun = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), item.effect.stun); startY += spaceY; } startY = DrawStats(startX - 12, startY, item.effect.stats, eType) - spaceY; } else if (item.IsForPerk()) { TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all perk"); item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll); if (!item.applyToAll) { TDE.Label(startX, startY += spaceY, width, height, "Target Perk:", "The target perk which this perk affect should be applied to"); for (int i = 0; i < item.perkPIDList.Count; i++) { int index = PerkDB.GetPrefabIndex(item.perkPIDList[i]); index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label); int prefabID = PerkDB.GetItem(index).prefabID; if (prefabID != item.prefabID && !item.perkPIDList.Contains(prefabID)) { item.perkPIDList[i] = prefabID; } if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-")) { item.perkPIDList.RemoveAt(i); i -= 1; } startY += spaceY; } int newID = -1; newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label); if (newID >= 0 && !item.perkPIDList.Contains(newID)) { item.perkPIDList.Add(newID); } startY += spaceY + 10; } TDE.Label(startX, startY, width, height, "Perk Rsc Multiplier:", "Modify/Multiply the purchase cost of the ability"); item.costMul = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.costMul); if (item.gainList.Count < RscDB.GetCount()) { item.gainList.Add(0); } if (item.gainList.Count > RscDB.GetCount()) { item.gainList.Remove(item.gainList.Count - 1); } for (int i = 0; i < item.gainList.Count; i++) { TDE.DrawSprite(new Rect(startX, startY += spaceY, height, height), RscDB.GetIcon(i)); TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i) + ":", ""); item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.gainList[i]); } } return(startY + spaceY); }