public static void Init() { // Get existing open window or if none, make a new one: window = (AbilityEditorWindow)EditorWindow.GetWindow(typeof(AbilityEditorWindow)); //~ window.minSize=new Vector2(375, 449); //~ window.maxSize=new Vector2(375, 800); prefab = AbilityDB.LoadDB(); abilityList = prefab.abilityList; for (int i = 0; i < abilityList.Count; i++) { //towerList[i].prefabID=i; if (abilityList[i] != null) { abilityIDList.Add(abilityList[i].ID); } else { abilityList.RemoveAt(i); i -= 1; } } InitLabel(); }
public static void AddAbility(int prefabID, int replacePrefabID = -1) //called from perk to add new ability { if (instance == null) { return; } int replaceIdx = -1; if (replacePrefabID >= 0) { for (int i = 0; i < instance.abilityList.Count; i++) { if (instance.abilityList[i].prefabID == replacePrefabID) { replaceIdx = i; break; } } } Ability newAbility = AbilityDB.GetPrefab(prefabID).Clone(); if (replaceIdx < 0) { instance.abilityList.Add(newAbility); newAbility.Init(instance.abilityList.Count - 1, instance.transform); } else { instance.abilityList[replaceIdx] = newAbility; newAbility.Init(replaceIdx, instance.transform); } TDTK.OnNewAbility(newAbility); }
protected override void ShiftItemDown() { if (selectID < AbilityDB.GetList().Count - 1) { ShiftItem(1); } }
void Awake() { instance = this; thisT = transform; List <Ability> dbList = AbilityDB.Load(); abilityList = new List <Ability>(); for (int i = 0; i < dbList.Count; i++) { if (!unavailableIDList.Contains(dbList[i].ID)) { abilityList.Add(dbList[i].Clone()); } } for (int i = 0; i < abilityList.Count; i++) { abilityList[i].ID = i; } if (defaultIndicator) { defaultIndicator = (Transform)Instantiate(defaultIndicator); defaultIndicator.parent = thisT; defaultIndicator.gameObject.SetActive(false); } }
public void _Show(Ability ability, Vector3 pos, int pivotCorner = 2, Vector3 offset = default(Vector3)) { SetPivot(pivotCorner); labelName.text = ability.name; labelDesp.text = ability.desp; labelDesp.enabled = true; if (AbilityManager.UseRscManagerForCost()) { List <float> cost = ability.GetCostRsc(); for (int i = 0; i < RscManager.GetResourceCount(); i++) { rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i); rscItemList[i].lbMain.text = cost[i].ToString("f0"); rscItemList[i].SetActive(true); } } else { rscItemList[0].imgMain.sprite = AbilityDB.GetRscIcon(); rscItemList[0].lbMain.text = ability.GetCost().ToString("f0"); for (int i = 1; i < RscManager.GetResourceCount(); i++) { rscItemList[i].SetActive(false); } } minHeight = 120; rectT.position = pos + offset; canvasGroup.alpha = 1; thisObj.SetActive(true); }
private void ShiftItem(int dir) { Ability item = AbilityDB.GetList()[selectID]; AbilityDB.GetList()[selectID] = AbilityDB.GetList()[selectID + dir]; AbilityDB.GetList()[selectID + dir] = item; selectID += dir; }
private void SelectItem(int newID) { selectID = newID; if (AbilityDB.GetList().Count <= 0) { return; } selectID = Mathf.Clamp(selectID, 0, AbilityDB.GetList().Count - 1); }
public static AbilityDB Init() { if (instance != null) { return(instance); } instance = LoadDB(); return(instance); }
public static void InitDB() { if (init) { return; } init = true; towerDBList = TowerDB.Load(); abilityDBList = AbilityDB.Load(); perkDBList = PerkDB.Load(); fpsWeaponDBList = FPSWeaponDB.Load(); }
public static void Init(int prefabID = -1) { window = (AbilityEditorWindow)EditorWindow.GetWindow(typeof(AbilityEditorWindow), false, "AbilityEditor"); window.minSize = new Vector2(420, 300); TDE.Init(); InitLabel(); if (prefabID >= 0) { window.selectID = AbilityDB.GetPrefabIndex(prefabID); } }
public static List <Ability> Load() { GameObject obj = Resources.Load("DB_TDTK/AbilityDB", typeof(GameObject)) as GameObject; #if UNITY_EDITOR if (obj == null) { obj = CreatePrefab(); } #endif AbilityDB instance = obj.GetComponent <AbilityDB>(); return(instance.abilityList); }
public static List <Ability> LoadClone() { GameObject obj = Resources.Load("DB_TDTK/AbilityDB", typeof(GameObject)) as GameObject; AbilityDB instance = obj.GetComponent <AbilityDB>(); List <Ability> newList = new List <Ability>(); if (instance != null) { for (int i = 0; i < instance.abilityList.Count; i++) { newList.Add(instance.abilityList[i].Clone()); } } return(newList); }
void Awake() { instance = this; List <Ability> dbList = AbilityDB.GetList(); for (int i = 0; i < dbList.Count; i++) { if (!unavailablePrefabIDList.Contains(dbList[i].prefabID) && !dbList[i].hideInInspector) { abilityList.Add(dbList[i].Clone()); } } tgtSelectIndicator = Instantiate(tgtSelectIndicator.gameObject).transform; tgtSelectIndicator.parent = transform; tgtSelectIndicator.gameObject.SetActive(false); pendingTgtAbilityIdx = -1; }
private int _NewItem(int idx = -1) { Ability item = null; if (idx < 0) { item = new Ability(); item.stats.ResetAsBaseStat(); } if (idx >= 0) { item = AbilityDB.GetList()[idx].Clone(); } item.prefabID = TDE.GenerateNewID(AbilityDB.GetPrefabIDList()); AbilityDB.GetList().Add(item); AbilityDB.UpdateLabel(); return(AbilityDB.GetList().Count - 1); }
public static void LoadAbility() { abilityDB = AbilityDB.LoadDB(); for (int i = 0; i < abilityDB.abilityList.Count; i++) { if (abilityDB.abilityList[i] != null) { abilityIDList.Add(abilityDB.abilityList[i].ID); } else { abilityDB.abilityList.RemoveAt(i); i -= 1; } } UpdateLabel_Ability(); TDEditorWindow.SetAbilityDB(abilityDB, abilityIDList, abilityLabel); TDEditorInspector.SetAbilityDB(abilityDB, abilityIDList, abilityLabel); }
private static void LoadAbility() { abilityPrefabDB = AbilityDB.LoadDB(); abilityList = abilityPrefabDB.abilityList; for (int i = 0; i < abilityList.Count; i++) { //abilityList[i].ID=i; if (abilityList[i] != null) { abilityIDList.Add(abilityList[i].ID); } else { abilityList.RemoveAt(i); i -= 1; } } UpdateAbilityNameList(); }
void Awake() { instance = this; thisT = transform; if (startWithFullEnergy) { energy = fullEnergy; } List <Ability> dbList = AbilityDB.Load(); abilityList = new List <Ability>(); for (int i = 0; i < dbList.Count; i++) { if (!unavailableIDList.Contains(dbList[i].ID)) { abilityList.Add(dbList[i].Clone()); } } List <Ability> newList = PerkManager.GetUnlockedAbility(); for (int i = 0; i < newList.Count; i++) { abilityList.Add(newList[i]); } for (int i = 0; i < abilityList.Count; i++) { abilityList[i].ID = i; } if (defaultIndicator) { defaultIndicator = (Transform)Instantiate(defaultIndicator); defaultIndicator.parent = thisT; defaultIndicator.gameObject.SetActive(false); } }
public static void Init () { // Get existing open window or if none, make a new one: window = (AbilityEditorWindow)EditorWindow.GetWindow(typeof (AbilityEditorWindow)); //~ window.minSize=new Vector2(375, 449); //~ window.maxSize=new Vector2(375, 800); prefab=AbilityDB.LoadDB(); abilityList=prefab.abilityList; for(int i=0; i<abilityList.Count; i++){ //towerList[i].prefabID=i; if(abilityList[i]!=null){ abilityIDList.Add(abilityList[i].ID); } else{ abilityList.RemoveAt(i); i-=1; } } InitLabel(); }
public static void Init() { if (init) { return; } init = true; //Debug.Log(" - Init Editor - "); damageTableDB = DamageTableDB.Init(); rscDB = RscDB.Init(); towerDB = TowerDB.Init(); creepDB = CreepDB.Init(); abilityDB = AbilityDB.Init(); perkDB = PerkDB.Init(); effectDB = EffectDB.Init(); DamageTableDB.UpdateLabel(); TowerDB.UpdateLabel(); CreepDB.UpdateLabel(); AbilityDB.UpdateLabel(); PerkDB.UpdateLabel(); EffectDB.UpdateLabel(); }
private float DrawWaveList(float startX, float startY) { maxSubWaveSize = 1; for (int i = 0; i < instance.waveList.Count; i++) { if (waveFoldList.Count <= i) { waveFoldList.Add(true); } if (waveOFoldList.Count <= i) { waveOFoldList.Add(true); } waveFoldList[i] = EditorGUI.Foldout(new Rect(startX, startY, widthS * 2, 15), waveFoldList[i], "Wave - " + (i + 1), TDE.foldoutS); if (removeIdx != i) { if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "remove")) { removeIdx = i; } if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "Insert")) { instance.waveList.Insert(i, new Wave()); } } else { if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "cancel")) { removeIdx = -1; } GUI.color = new Color(1, .2f, .2f, 1f); if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "confirm")) { instance.waveList.RemoveAt(i); removeIdx = -1; i -= 1; continue; } GUI.color = white; } Wave wave = instance.waveList[i]; if (waveFoldList[i]) { startX += 15; TDE.Label(startX, startY += spaceY, width, 15, "SubWave (" + wave.subWaveList.Count + "):"); if (GUI.Button(new Rect(startX + spaceX, startY - 1, widthS, 15), "-1")) { if (wave.subWaveList.Count > 1) { wave.subWaveList.RemoveAt(wave.subWaveList.Count - 1); } } if (GUI.Button(new Rect(startX + spaceX + 50, startY - 1, widthS, 15), "+1")) { wave.subWaveList.Add(new SubWave()); } float cachedY = startY + spaceY; for (int n = 0; n < wave.subWaveList.Count; n++) { startY = DrawSubWaveBlock(startX + (n * (subWaveBlockWidth + 10)), cachedY, wave.subWaveList[n], n, i); } startY += 5; TDE.Label(startX, startY, width, height, "Time to Next Wave: ", "Time in second before next wave is spawned"); wave.timeToNextWave = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), wave.timeToNextWave); float cachedX = startX; //startY+=spaceY; TDE.Label(startX, startY += spaceY, width, height, "Gain On Clear: ", "gain when the wave is cleared", TDE.headerS); TDE.Label(startX += spaceX, startY, width, height, "Rsc: ", "Resource"); startX += 30; RscManager.MatchRscList(wave.rscGainOnCleared, 0); for (int n = 0; n < RscDB.GetCount(); n++) { TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(n), RscDB.GetName(n)); wave.rscGainOnCleared[n] = EditorGUI.FloatField(new Rect(startX + height, startY, widthS - height, height), wave.rscGainOnCleared[n]); startX += widthS + 2; } startX += widthS * .5f; TDE.Label(startX, startY, width, height, "Perk rsc: ", ""); TDE.DrawSprite(new Rect(startX += 55, startY, height, height), PerkDB.GetRscIcon()); wave.perkRscGainOnCleared = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.perkRscGainOnCleared); startX += widthS * 1.5f; TDE.Label(startX, startY, width, height, "Ability rsc: ", ""); TDE.DrawSprite(new Rect(startX += 65, startY, height, height), AbilityDB.GetRscIcon()); wave.abilityRscGainOnCleared = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.abilityRscGainOnCleared); startX = cachedX; startY += spaceY * 2f; startX -= 15; } else { float cachedX = startX; startX += 180 + (removeIdx == i ? widthS * 1.5f : 0); for (int n = 0; n < wave.subWaveList.Count; n++) { if (wave.subWaveList[n].prefab == null) { continue; } TDE.DrawSprite(new Rect(startX, startY, height * 1.5f, height * 1.5f), wave.subWaveList[n].prefab.icon); TDE.Label(startX + height * 1.5f + 2, startY, widthS, height, "x" + wave.subWaveList[n].spawnCount); startX += widthS + height * 1.5f; } startX = cachedX; startY += spaceY * 2f; } maxSubWaveSize = Mathf.Max(waveFoldList[i] ? instance.waveList[i].subWaveList.Count : 1, maxSubWaveSize); } return(startY + spaceY * 2); }
public float DrawGeneratorParameter(float startX, float startY) { instance.UpdateGeneratorUnitList(); SpawnGenerator gen = instance.generator; gen.Init(); startX += 5; spaceX += widthS; TDE.Label(startX, startY, width, height, "Wave Interval (Min/Max):", "The minimum and maximum value of the interval (in second) between two waves"); gen.waveIntervalMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), gen.waveIntervalMin); gen.waveIntervalMax = EditorGUI.FloatField(new Rect(startX + spaceX + widthS, startY, widthS, height), gen.waveIntervalMax); gen.waveIntervalMin = Mathf.Max(0, gen.waveIntervalMin); gen.waveIntervalMin = Mathf.Max(gen.waveIntervalMin, 0); gen.waveIntervalMax = Mathf.Max(0, gen.waveIntervalMax); gen.waveIntervalMax = Mathf.Max(gen.waveIntervalMax, 0); TDE.Label(startX, startY += spaceY, width, height, "Use all path:", "When checked, all available path will be used (provided that there's enough subwave in the wave)"); gen.useAllPath = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.useAllPath); TDE.Label(startX, startY += spaceY, width, height, "One SubWave per path:", "When checked, the total subwave count will be limited to number of path available"); gen.limitSubWaveCountToPath = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.limitSubWaveCountToPath); TDE.Label(startX, startY += spaceY, width, height, "Mirror SubWave:", "When checked, all subwave will be similar except they uses different path"); gen.similarSubWave = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.similarSubWave); spaceX -= widthS; float cachedY = startY += spaceY * 2.5f; float cachedX = startX; TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Wave Setting:", "", TDE.headerS); DrawGenAttribute(startX, cachedY, gen.attSubWaveCount, "SubWave Count:", "", null, 1); startX += genAttBlockWidth + 10; DrawGenAttribute(startX, cachedY, gen.attTotalUnitCount, "Total Unit Count:", "", null, 1); startX += genAttBlockWidth + 10; startX += 15; TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Gain On Wave Cleared:", "", TDE.headerS); DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Life Gain:"); startX += genAttBlockWidth + 10; //cachedY=startY+spaceY; cachedX=startX; for (int i = 0; i < gen.attRscGainOnCleared.Count; i++) { DrawGenAttribute(startX, cachedY, gen.attRscGainOnCleared[i], RscDB.GetName(i), "", RscDB.GetIcon(i)); startX += genAttBlockWidth + 10; } //startY+=genAttBlockHeight+spaceY; startX=cachedX; DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Perk Rsc Gain:", "", PerkDB.GetRscIcon()); startX += genAttBlockWidth + 10; DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Ability Rsc Gain:", "", AbilityDB.GetRscIcon()); startX += genAttBlockWidth + 10; startY += genAttBlockHeight + spaceY * 2; startX = cachedX; for (int i = 0; i < gen.genItemList.Count; i++) { if (gen.genItemList[i].prefab == null) { gen.genItemList.RemoveAt(i); i -= 1; continue; } startY = DrawGenItem(startX, startY, gen.genItemList[i]) + 10; } return(startY + spaceY * 2); }
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); }
public void OnGUI() { TDE.InitGUIStyle(); if (!CheckIsPlaying()) { return; } if (window == null) { Init(); } List <Ability> abilityList = AbilityDB.GetList(); Undo.RecordObject(this, "window"); Undo.RecordObject(AbilityDB.GetDB(), "abilityDB"); if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save")) { TDE.SetDirty(); } if (GUI.Button(new Rect(5, 5, 120, 25), "Create New")) { Select(NewItem()); } if (abilityList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected")) { Select(NewItem(selectID)); } float startX = 5; float startY = 55; if (minimiseList) { if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>")) { minimiseList = false; } } else { if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<")) { minimiseList = true; } } Vector2 v2 = DrawAbilityList(startX, startY, abilityList); startX = v2.x + 25; if (abilityList.Count == 0) { return; } Rect visibleRect = new Rect(startX, startY, window.position.width - startX, window.position.height - startY); Rect contentRect = new Rect(startX, startY, contentWidth, contentHeight); scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect); v2 = DrawAbilityConfigurator(startX, startY, abilityList[selectID]); contentWidth = v2.x - startX; contentHeight = v2.y - 55; GUI.EndScrollView(); if (GUI.changed) { TDE.SetDirty(); } }
public static void SetAbilityDB(AbilityDB db, List <int> IDList, string[] label) { abilityDB = db; abilityIDList = IDList; abilityLabel = label; }
// Use this for initialization void Start() { GameObject lastSpaceObj = null; if (UIControl.IsGameScene()) { lifeItem.Init(); waveItem.Init(); UpdateLifeDisplay(GameControl.GetLife()); UpdateWaveDisplay(1); lastSpaceObj = spaceObjLife; } else { waveItem.rootObj.SetActive(false); spaceObjWave.SetActive(false); lifeItem.rootObj.SetActive(false); spaceObjLife.SetActive(false); } if (UIControl.IsGameScene() || PerkManager.UseRscManagerForCost()) { for (int i = 0; i < RscManager.GetResourceCount(); i++) { if (i > 0) { rscItemList.Add(new UIObject(UI.Clone(rscItemList[0].rootObj))); } rscItemList[i].Init(); rscItemList[i].imgMain.sprite = RscManager.GetRscIcon(i); rscItemList[i].rectT.SetSiblingIndex(rscItemList[0].rectT.GetSiblingIndex() + i); } UpdateResourceDisplay(RscManager.GetResourceList()); lastSpaceObj = spaceObjRsc; } else { rscItemList[0].rootObj.SetActive(false); spaceObjRsc.SetActive(false); } if (!UIControl.IsGameScene() || !AbilityManager.IsEnabled() || AbilityManager.UseRscManagerForCost()) { sliderAbilityRsc.gameObject.SetActive(false); spaceObjAbility.SetActive(false); } else { imgAbilityRsc.sprite = AbilityDB.GetRscIcon(); UpdateAbilityRscDisplay(AbilityManager.GetRsc()); lastSpaceObj = spaceObjAbility; } if (!PerkManager.IsEnabled() || PerkManager.UseRscManagerForCost()) { perkRscItem.rootObj.SetActive(false); //spaceObjPerk.SetActive(false); lastSpaceObj.SetActive(false); } else { perkRscItem.Init(); perkRscItem.imgMain.sprite = PerkDB.GetRscIcon(); UpdatePerkRscDisplay(PerkManager.GetRsc()); } //~ if(!UIControl.DisablePerkScreen()){ //~ buttonPerk.Init(); //~ buttonPerk.SetCallback(null, null, this.OnPerkButton, null); //~ } //~ else{ //~ if(buttonPerk.rootObj!=null) buttonPerk.rootObj.SetActive(false); //~ } //~ buttonFF.Init(); //~ buttonFF.SetCallback(null, null, this.OnFFButton, null); //~ buttonPause.Init(); //~ buttonPause.SetCallback(null, null, this.OnPauseButton, null); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (instance == null) { Awake(); return; } GUI.changed = false; Undo.RecordObject(instance, "AbilityManager"); EditorGUILayout.Space(); EditorGUIUtility.labelWidth += 35; cont = new GUIContent("Use RscManager For Cost:", "Check use the resources in RscManager for ability cost"); instance.useRscManagerForCost = EditorGUILayout.Toggle(cont, instance.useRscManagerForCost); EditorGUIUtility.labelWidth -= 35; EditorGUILayout.Space(); if (!instance.useRscManagerForCost) { GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); EditorGUIUtility.labelWidth += 35; cont = new GUIContent("Full Resource On Start:", "Check to have the resource start at full\nOtherwise it will start at whatever value specified"); instance.startWithFullRsc = EditorGUILayout.Toggle(cont, instance.startWithFullRsc); EditorGUIUtility.labelWidth -= 35; cont = new GUIContent("Resource:", "The resource used to cast ability"); instance.rsc = EditorGUILayout.IntField(cont, instance.rsc); cont = new GUIContent("Resource Cap:", "The resource capacity. Resource cannot exceed this value"); instance.rscCap = EditorGUILayout.IntField(cont, instance.rscCap); if (!Application.isPlaying && instance.startWithFullRsc) { instance.rsc = instance.rscCap; } cont = new GUIContent("Resource Regen Rate:", "The rate at which the resource regenerate (per second)"); instance.rscRegenRate = EditorGUILayout.FloatField(cont, instance.rscRegenRate); GUILayout.EndVertical(); GUILayout.BeginVertical(); EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.Space(); if (!instance.useRscManagerForCost) { Sprite icon = AbilityDB.GetRscIcon(); icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), true, GUILayout.Width(40), GUILayout.Height(40)); AbilityDB.SetRscIcon(icon); } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } else { EditorGUILayout.LabelField("Full Rsc On Start:", "-"); EditorGUILayout.LabelField("Resource:", "-"); EditorGUILayout.LabelField("Resource Cap:", "-"); EditorGUILayout.LabelField("Resource Regen Rate:", "-"); } EditorGUILayout.Space(); cont = new GUIContent("Target Select Indicator:", "the object used to indicate selected position during target selection phase"); instance.tgtSelectIndicator = (Transform)EditorGUILayout.ObjectField(cont, instance.tgtSelectIndicator, typeof(Transform), true); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); showList = EditorGUILayout.Foldout(showList, "Show Ability List"); EditorGUILayout.EndHorizontal(); if (showList) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if (GUILayout.Button("EnableAll") && !Application.isPlaying) { instance.unavailablePrefabIDList = new List <int>(); } if (GUILayout.Button("DisableAll") && !Application.isPlaying) { instance.unavailablePrefabIDList = AbilityDB.GetPrefabIDList(); } EditorGUILayout.Space(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); List <Ability> abilityList = AbilityDB.GetList(); for (int i = 0; i < abilityList.Count; i++) { if (abilityList[i].hideInInspector) { continue; } Ability ability = abilityList[i]; GUILayout.BeginHorizontal(); EditorGUILayout.Space(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); TDE.DrawSprite(GUILayoutUtility.GetLastRect(), ability.icon, ability.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(ability.name, GUILayout.ExpandWidth(false)); EditorGUI.BeginChangeCheck(); bool flag = !instance.unavailablePrefabIDList.Contains(ability.prefabID) ? true : false; flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the ability in this level"), flag); if (!Application.isPlaying && EditorGUI.EndChangeCheck()) { if (!flag && !instance.unavailablePrefabIDList.Contains(ability.prefabID)) { instance.unavailablePrefabIDList.Add(ability.prefabID); } else if (flag) { instance.unavailablePrefabIDList.Remove(ability.prefabID); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } EditorGUILayout.Space(); DefaultInspector(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
protected override void DeleteItem() { AbilityDB.GetList().RemoveAt(deleteID); AbilityDB.UpdateLabel(); }
private static void LoadAbility(){ abilityPrefabDB=AbilityDB.LoadDB(); abilityList=abilityPrefabDB.abilityList; for(int i=0; i<abilityList.Count; i++){ //abilityList[i].ID=i; if(abilityList[i]!=null){ abilityIDList.Add(abilityList[i].ID); } else{ abilityList.RemoveAt(i); i-=1; } } UpdateAbilityNameList(); }
public string _PurchasePerk(Perk perk, bool useRsc = true) { string text = perk.Purchase(useRsc); if (text != "") { return(text); } if (onPerkPurchasedE != null) { onPerkPurchasedE(perk); } //process the prereq for other perk for (int i = 0; i < perkList.Count; i++) { Perk perkTemp = perkList[i]; if (perkTemp.purchased || perkTemp.prereq.Count == 0) { continue; } perkTemp.prereq.Remove(perk.ID); } perkPoint += 1; if (onPerkPointE != null) { onPerkPointE(perkPoint); } if (perk.type == _PerkType.NewTower) { List <UnitTower> towerList = TowerDB.Load(); for (int i = 0; i < towerList.Count; i++) { if (towerList[i].prefabID == perk.itemIDList[0]) { unlockedTower.Add(towerList[i]); BuildManager.AddNewTower(towerList[i]); } } } else if (perk.type == _PerkType.NewAbility) { List <Ability> abilityList = AbilityDB.Load(); for (int i = 0; i < abilityList.Count; i++) { if (abilityList[i].ID == perk.itemIDList[0]) { unlockedAbility.Add(abilityList[i]); AbilityManager.AddNewAbility(abilityList[i]); } } } else if (perk.type == _PerkType.NewFPSWeapon) { List <FPSWeapon> FPSWeaponList = FPSWeaponDB.Load(); for (int i = 0; i < FPSWeaponList.Count; i++) { if (FPSWeaponList[i].prefabID == perk.itemIDList[0]) { unlockedWeapon.Add(FPSWeaponList[i]); FPSControl.AddNewWeapon(FPSWeaponList[i]); } } } else if (perk.type == _PerkType.GainLife) { GameControl.GainLife((int)Random.Range(perk.value, perk.valueAlt)); } else if (perk.type == _PerkType.LifeCap) { lifeCap += (int)perk.value; GameControl.GainLife(0); } else if (perk.type == _PerkType.LifeRegen) { lifeRegen += perk.value; } else if (perk.type == _PerkType.LifeWaveClearedBonus) { lifeWaveClearedBonus += (int)perk.value; } else if (perk.type == _PerkType.GainRsc) { List <int> valueList = new List <int>(); for (int i = 0; i < perk.valueRscList.Count; i++) { valueList.Add((int)perk.valueRscList[i]); } ResourceManager.GainResource(valueList, null, false); //dont pass multiplier and dont use multiplier } else if (perk.type == _PerkType.RscRegen) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscRegen[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscCreepKilledGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscCreepKilledGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscWaveClearedGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscWaveClearedGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.RscResourceTowerGain) { for (int i = 0; i < perk.valueRscList.Count; i++) { rscRscTowerGain[i] += perk.valueRscList[i]; } } else if (perk.type == _PerkType.Tower) { ModifyTowerModifier(globalTowerModifier, perk); } else if (perk.type == _PerkType.TowerSpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = TowerModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkTowerModifier towerModifier = new PerkTowerModifier(); towerModifier.prefabID = perk.itemIDList[i]; towerModifierList.Add(towerModifier); ID = towerModifierList.Count - 1; } ModifyTowerModifierInList(ID, perk); } } else if (perk.type == _PerkType.Ability) { ModifyAbilityModifier(globalAbilityModifier, perk); } else if (perk.type == _PerkType.AbilitySpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = AbilityModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkAbilityModifier abilityModifier = new PerkAbilityModifier(); abilityModifier.abilityID = perk.itemIDList[i]; abilityModifierList.Add(abilityModifier); ID = abilityModifierList.Count - 1; } ModifyAbilityModifierInList(ID, perk); } } else if (perk.type == _PerkType.FPSWeapon) { ModifyFPSWeaponModifier(globalFPSWeaponModifier, perk); } else if (perk.type == _PerkType.FPSWeaponSpecific) { for (int i = 0; i < perk.itemIDList.Count; i++) { int ID = FPSWeaponModifierExist(perk.itemIDList[i]); if (ID == -1) { PerkFPSWeaponModifier weaponModifier = new PerkFPSWeaponModifier(); weaponModifier.prefabID = perk.itemIDList[i]; FPSWeaponModifierList.Add(weaponModifier); ID = FPSWeaponModifierList.Count - 1; } ModifyFPSWeaponModifierInList(ID, perk); } } else if (perk.type == _PerkType.EnergyRegen) { energyRegen += perk.value; } else if (perk.type == _PerkType.EnergyIncreaseCap) { energyCap += perk.value; } else if (perk.type == _PerkType.EnergyCreepKilledBonus) { energyCreepKilledBonus += perk.value; } else if (perk.type == _PerkType.EnergyWaveClearedBonus) { energyWaveClearedBonus += perk.value; } return(""); }