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); }
private float DrawSubWaveBlock(float startX, float startY, SubWave subWave, int index, int wIdx) { float spaceX = 60; float cachedY = startY; width -= 10; subWaveBlockWidth = spaceX + width + 5; GUI.Box(new Rect(startX, startY, subWaveBlockWidth, subWaveBlockHeight), ""); startX += 3; startY += 3; //TDE.Label(startX, startY, width, height, "Prefab: ", ""); //subWave.prefab=(UnitCreep)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), subWave.prefab, typeof(UnitCreep), true); startY+=spaceY //int index=subWave.prefab!=null ? TDEditor.GetCreepIndex(subWave.unitC.prefabID) : 0 ; index = CreepDB.GetPrefabIndex(subWave.prefab); TDE.Label(startX, startY, width, height, "Prefab:", "The creep prefab to be spawned"); index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, CreepDB.label); subWave.prefab = CreepDB.GetItem(index); if (subWave.prefab == null) { GUI.Box(new Rect(startX + subWaveBlockWidth - 5 - height * 2, startY + spaceY, height * 2, height * 2), ""); } else { TDE.DrawSprite(new Rect(startX + subWaveBlockWidth - 7 - height * 2, startY + spaceY, height * 2, height * 2), subWave.prefab.icon); } TDE.Label(startX, startY += spaceY, width, height, "Delay: ", "The delay (in second) before the subwave start spawning"); subWave.delay = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.delay); TDE.Label(startX, startY += spaceY, width, height, "Count: ", "How many creep will be spawned for the subwave"); subWave.spawnCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), subWave.spawnCount); TDE.Label(startX, startY += spaceY, width, height, "Spacing: ", "The spawn spacing (in second) between each individual creep"); subWave.spacing = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.spacing); TDE.Label(startX, startY += spaceY, width, height, "Path: ", "OPTIONAL: The path to used for this subwave. If left unassigned, a random path will be used"); subWave.path = (Path)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), subWave.path, typeof(Path), true); if (showOverrideSetting) { TDE.Label(startX, startY += spaceY + 5f, width, height, "Override Setting:", "Attribute on the default prefab that will be overriden", TDE.headerS); spaceX += 10; TDE.Label(startX, startY += spaceY, width, height, " - HitPoint: ", ""); GUI.color = subWave.HP > 0 ? GUI.color : grey; subWave.HP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.HP); GUI.color = white; TDE.Label(startX, startY += spaceY, width, height, " - Shield: ", ""); GUI.color = subWave.SH >= 0 ? GUI.color : grey; subWave.SH = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.SH); GUI.color = white; TDE.Label(startX, startY += spaceY, width, height, " - Speed: ", ""); GUI.color = subWave.speed > 0 ? GUI.color : grey; subWave.speed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.speed); GUI.color = white; TDE.Label(startX, startY += spaceY, width, height, " - Rsc Gain: ", ""); RscManager.MatchRscList(subWave.rscGain, -1); subWave.overrideRscGain = true; for (int i = 0; i < subWave.rscGain.Count; i++) { if (subWave.rscGain[i] < 0) { subWave.overrideRscGain = false; } } float cachedX = startX; //startY+=spaceY; for (int i = 0; i < RscDB.GetCount(); i++) { if (i > 0 && i % 3 == 0) { startX = cachedX - widthS - 2; startY += spaceY; } if (i > 0) { startX += widthS + 2; } TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i)); GUI.color = subWave.overrideRscGain ? GUI.color : grey; subWave.rscGain[i] = EditorGUI.IntField(new Rect(startX + spaceX + height, startY, widthS - height, height), subWave.rscGain[i]); GUI.color = white; if (subWave.rscGain[i] < 0 && subWave.overrideRscGain) { subWave.overrideRscGain = false; } } startX = cachedX; } width += 10; subWaveBlockHeight = startY - cachedY + spaceY + 2; return(startY + spaceY); }
//private static bool fold=false; public static float DrawStats(float startX, float startY, Stats item, _EType type, bool compressWidth = false) { int spaceX = 120; int spaceY = 18; int width = 150; int widthS = 40; int height = 16; int widthL = compressWidth ? 2 + widthS * 2 : width; //string text="Stats "+(!fold ? "(show)" : "(hide)"); //fold=EditorGUI.Foldout(new Rect(startX, startY+=spaceY, width, height), fold, text, foldoutS); //if(fold) return startY; startX += 12; bool start = true; if (IsTower(type) || IsPerk(type)) //cost for ability is drawn separately in AbilityEditor { TDE.Label(startX, startY, width, height, "Cost (Rsc):", "cost of the item"); RscManager.MatchRscList(item.cost, IsPerk(type) ? 1 : 0); float cachedX = startX; for (int i = 0; i < RscDB.GetCount(); i++) { if (i > 0 && i % 2 == 0) { startX = cachedX - widthS - 2; startY += spaceY; } if (i > 0) { startX += widthS + 2; } TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i)); item.cost[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.cost[i]); } startX = cachedX; if (IsTower(type)) { TDE.Label(startX, startY += spaceY, width, height, "Sell Value (Rsc):", "sell value of the item"); RscManager.MatchRscList(item.sellValue, IsPerk(type) ? 1 : 0); cachedX = startX; for (int i = 0; i < RscDB.GetCount(); i++) { if (i > 0 && i % 2 == 0) { startX = cachedX - widthS - 2; startY += spaceY; } if (i > 0) { startX += widthS + 2; } TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i)); item.sellValue[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.sellValue[i]); } startX = cachedX; } if (!IsPerkA(type)) { TDE.Label(startX, startY += spaceY, width, height, "Build Duration:", ""); item.buildDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.buildDuration); TDE.Label(startX, startY += spaceY, width, height, "Sell Duration:", ""); item.sellDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.sellDuration); } start = false; } if (IsEffect(type)) { if (!start) { startY += 5; } if (!IsPerkE(type)) { int damageType = (int)item.damageType; TDE.Label(startX, startY, width, height, "Damage Type:", ""); damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthL, height), damageType, TDE.GetDamageLabel()); item.damageType = damageType; startY += spaceY; } TDE.Label(startX, startY, width, height, "HitPoint Rate:", "hit-point generation/degeneration per second"); item.hpRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.hpRate); TDE.Label(startX, startY += spaceY, width, height, "Shield Rate:", "*shield generation/degeneration per second\nDoes not subject to stagger"); item.shRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shRate); start = false; } if (IsTower(type) || IsCreep(type) || IsPerkT(type) || IsEffect(type)) { if (IsTower(type) || IsPerkT(type) || IsEffect(type)) { startY += spaceY; } if (!start) { startY += 5; } TDE.Label(startX, startY, width, height, "HitPoint:", ""); item.hp = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.hp); TDE.Label(startX, startY += spaceY, width, height, "Shield:", ""); item.sh = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.sh); bool switchColor = false; if (item.sh <= 0 && GUI.color != Color.grey) { GUI.color = Color.grey; switchColor = true; } TDE.Label(startX, startY += spaceY, width, height, " - Regen Rate:", "shield regeneration per second"); if (item.sh > 0) { item.shRegen = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shRegen); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-"); } TDE.Label(startX, startY += spaceY, width, height, " - Stagger Duration:", "shield regeneration will stop for this duration when the unit is hit"); if (item.sh > 0) { item.shStagger = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shStagger); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-"); } if (switchColor) { GUI.color = Color.white; } start = false; } if (IsTower(type) || IsCreep(type) || IsAbility(type)) { if (!start) { startY += 5; } int armorType = (int)item.armorType; int damageType = (int)item.damageType; if (!IsAbility(type)) { TDE.Label(startX, startY += spaceY, width, height, "Armor Type:", ""); armorType = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthL, height), armorType, TDE.GetArmorLabel()); item.armorType = armorType; } if (IsAbility(type) || UseDamage(type)) { TDE.Label(startX, startY += spaceY, width, height, "Damage Type:", ""); damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthL, height), damageType, TDE.GetDamageLabel()); item.damageType = damageType; } else { TDE.Label(startX, startY += spaceY, width, height, "Damage Type:", ""); TDE.Label(startX + spaceX, startY, widthL, height, "-", ""); } } if (IsEffect(type) || IsCreep(type)) { TDE.Label(startX, startY += spaceY + 5, width, height, "Move Speed:", ""); item.speed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.speed); } if (IsEffect(type) || IsTower(type) || IsCreep(type) || IsPerkT(type)) { startY += 5; TDE.Label(startX, startY += spaceY, width, height, "Dodge Chance:", "How likely will the unit dodge an attack\n" + txtTooltipChance); item.dodge = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.dodge); TDE.Label(startX, startY += spaceY, width, height, "Critical Reduc.:", "How likely will the unit negate a cirtical attack\n" + txtTooltipChance); item.critReduc = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.critReduc); TDE.Label(startX, startY += spaceY, width, height, "Damage Reduc.:", "How much incoming damage will be reduced\n" + txtTooltipChance); item.dmgReduc = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.dmgReduc); } if (IsTower(type)) { string text = "Attack Stats"; if (type == _EType.TSupport) { text = "Support Stats"; } else if (type == _EType.TRsc) { text = "Resource Stats"; } else if (type == _EType.TBlock) { return(startY + spaceY); } TDE.Label(startX, startY += spaceY + 5, width, height, text, "", TDE.headerS); } else if (IsCreep(type)) { string text = "Attack Stats"; if (type == _EType.CSupport) { text = "Support Stats"; } else if (type == _EType.CSpawner) { text = "Spawner Stats"; } else if (type == _EType.CDefault) { return(startY + spaceY); } TDE.Label(startX, startY += spaceY + 5, width, height, text, "", TDE.headerS); } else { startY += 5; } if (IsEffect(type) || IsAbility(type) || UseDamage(type) || IsPerk(type)) { TDE.Label(startX, startY += spaceY, width, height, "Damage Min/Max:"); item.damageMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.damageMin); item.damageMax = EditorGUI.FloatField(new Rect(startX + spaceX + widthS + 2, startY, widthS, height), item.damageMax); } if (IsEffect(type) || UseCooldown(type) || IsPerk(type)) //cooldown for ability is drawn separately { TDE.Label(startX, startY += spaceY, width, height, "Cooldown:", ""); item.cooldown = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.cooldown); } if (IsEffect(type) || UseAttackRange(type) || IsPerk(type)) { TDE.Label(startX, startY += spaceY, width, height, "Effective Radius:", ""); item.attackRange = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.attackRange); } if (IsEffect(type) || IsAbility(type) || UseAOERange(type) || IsAbility(type) || IsPerk(type)) { TDE.Label(startX, startY += spaceY, width, height, "AOE Radius:", ""); item.aoeRange = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.aoeRange); } if (IsEffect(type) || UseHitNCrit(type) || IsAbility(type) || IsPerk(type)) { startY += 5; TDE.Label(startX, startY += spaceY, width, height, "Hit Chance:", "How likely will an attack will hit\n" + txtTooltipChance); item.hit = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.hit); TDE.Label(startX, startY += spaceY, width, height, "Critical Chance:", "How likely will an attack will score critical hit, applying critical multiplier to the damage cause\n" + txtTooltipChance); item.critChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.critChance); TDE.Label(startX, startY += spaceY, width, height, "Critical Multiplier:", "The multiplier apply to the damage when an attack crits"); item.critMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.critMultiplier); } if (IsEffect(type) || UseRscGain(type) || IsPerk(type)) { TDE.Label(startX, startY += spaceY, width, height, "Resource Gain:", ""); RscManager.MatchRscList(item.rscGain, (IsEffect(type) || IsPerk(type) ? 1 : 0)); float cachedX = startX; for (int i = 0; i < RscDB.GetCount(); i++) { if (i > 0 && i % 2 == 0) { startX = cachedX; startY += spaceY; } if (i > 0) { startX += widthS + 2; } TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i)); item.rscGain[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.rscGain[i]); } startX = cachedX; } bool useEffOnHit = false; if (!IsEffect(type) && (UseOnHitEffect(type) || IsAbility(type) || IsPerkA(type) || IsPerkT(type))) { startY += 5; bool removeEff = false; TDE.Label(startX, startY += spaceY, width, height, "Effect On Hit:", "Offense/AOE Unit/Ability: The effect applies to target when an attack hit\nSupport Unit: The effect applies to friendly target"); int effIdx = EffectDB.GetPrefabIndex(item.effectOnHitID); if (compressWidth) { effIdx = EditorGUI.Popup(new Rect(startX + spaceX - widthS * 0.5f + 3, startY, widthS * 2.5f, height), effIdx, EffectDB.label); if (GUI.Button(new Rect(startX + spaceX - widthS + 5, startY, height, height), "-")) { item.effectOnHitID = -1; removeEff = true; } } else { effIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effIdx, EffectDB.label); if (GUI.Button(new Rect(startX + spaceX + width + 3, startY, height, height), "-")) { item.effectOnHitID = -1; removeEff = true; } } if (effIdx >= 0 && !removeEff) { item.effectOnHitID = EffectDB.GetItem(effIdx).prefabID; } useEffOnHit = true; } if (UseOnHitEffectChance(type)) { if (!useEffOnHit) { startY += 5; } TDE.Label(startX, startY += spaceY, width, height, "Effect Hit Chance:", "How likely will an attack will hit\n" + txtTooltipChance); if (useEffOnHit && item.effectOnHitID < 0 && !(IsPerkA(type) || IsPerkT(type))) { GUI.color = Color.grey; } item.effectOnHitChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.effectOnHitChance); GUI.color = Color.white; } return(startY + spaceY); }
protected float DrawGeneralSetting(float startX, float startY, UnitCreep unit) { string textF = "General Creep Setting "; //+(!foldBasicSetting ? "(show)" : "(hide)"); foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS); if (!foldBasicSetting) { return(startY); } startX += 12; //~ TDE.Label(startX, startY+=spaceY, width, height, "Flying:", "Check to set the creep as flying unit"); //~ unit.flying=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.flying); //~ 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, "Spawner:", ""); //~ unit.isSpawner=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSpawner); //~ startY+=10; TDE.Label(startX, startY += spaceY, width, height, "Immuned Effect:", "The list of effects the unit is immune to"); for (int i = 0; i < unit.effectImmunityList.Count; i++) { TDE.Label(startX + spaceX - height, startY, width, height, "-"); int effIdx = EffectDB.GetPrefabIndex(unit.effectImmunityList[i]); effIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effIdx, EffectDB.label); if (effIdx >= 0) { int effID = EffectDB.GetItem(effIdx).prefabID; if (effID >= 0 && !unit.effectImmunityList.Contains(effID)) { unit.effectImmunityList[i] = effID; } } if (effIdx < 0 || GUI.Button(new Rect(startX + spaceX + width + 3, startY, height, height), "-")) { unit.effectImmunityList.RemoveAt(i); } startY += spaceY; } int newEffID = -1; newEffID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newEffID, EffectDB.label); if (newEffID >= 0) { newEffID = EffectDB.GetPrefab(newEffID).prefabID; } if (newEffID >= 0 && !unit.effectImmunityList.Contains(newEffID)) { unit.effectImmunityList.Add(newEffID); } startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Life Lost On Dest:", "The amount of life player will lose if the creep reach destination"); unit.lifeLostOnDestination = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeLostOnDestination); unit.lifeLostOnDestination = Mathf.Max(1, unit.lifeLostOnDestination); startY += 5; TDE.Label(startX, startY += spaceY, width, height, "Gain On Destroyed:", ""); TDE.Label(startX, startY += spaceY, width, height, " - Life (chance):", "The amount of life player will gain when the creep is destroyed, subject to a chance (takes value from 0-1 with 0.3 being 30%)"); if (unit.lifeGainedOnDestroyed <= 0) { GUI.color = grey; } unit.lifeGainedOnDestroyed = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeGainedOnDestroyed); GUI.color = white; if (unit.lifeGainedOnDestroyedChance <= 0) { GUI.color = grey; } unit.lifeGainedOnDestroyedChance = EditorGUI.FloatField(new Rect(startX + spaceX + widthS + 2, startY, widthS, height), unit.lifeGainedOnDestroyedChance); GUI.color = white; //TDE.Label(startX, startY+=spaceY, width, height, " - Expericene:", "Check to set the creep as flying unit"); //if(unit.expGainOnDestroyed<=0) GUI.color=grey; //unit.expGainOnDestroyed=EditorGUI.IntField(new Rect(startX+spaceX, startY, widthS, height), unit.expGainOnDestroyed); GUI.color=white; RscManager.MatchRscList(unit.rscGainOnDestroyed, 0); TDE.Label(startX, startY += spaceY, width, height, " - Resource:", "The amount of resource the player will gain when the creep is destroyed"); float cachedX = startX; startX += spaceX; for (int i = 0; i < RscDB.GetCount(); i++) { //if(unit.rscGainOnDestroyed[i]==0) GUI.color=grey; if (i > 0 && i % 2 == 0) { startX = cachedX; startY += spaceY; } if (i > 0) { startX += widthS + 2; } TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i)); unit.rscGainOnDestroyed[i] = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), unit.rscGainOnDestroyed[i]); GUI.color = white; } startX = cachedX; startY += 10; TDE.Label(startX, startY += spaceY, width, height, "SpawnOnDestroyed:", "Creep prefab to be spawn when an instance of this unit is destroyed. Note that the HP of the spawned unit is inherit from the destroyed unit. Use HP-multiplier to specifiy how much of the HP should be carried forward"); int idx = CreepDB.GetPrefabIndex(unit.spawnOnDestroyed); idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, CreepDB.label); unit.spawnOnDestroyed = CreepDB.GetItem(idx); if (unit.spawnOnDestroyed == unit) { unit.spawnOnDestroyed = null; } if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-")) { unit.spawnOnDestroyed = null; } TDE.Label(startX, startY += spaceY, width, height, " - Num to Spawn:", "The amount of SpawnOnDestroyed creep to spawn when this unit is destroyed"); if (unit.spawnOnDestroyed != null) { unit.sodCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.sodCount); } else { TDE.Label(startX + spaceX, startY, widthS, height, "-"); } bool valid = unit.spawnOnDestroyed != null && unit.sodCount > 0; startY = DrawSpawnOverride(startX, startY, unit.sodOverride, valid, foldSodOverride, SetFoldSodOverride); startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Flying:", "Check to set the creep as flying"); unit.flying = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.flying); startY = DrawUnitSetting(startX - 12, startY, unit); return(startY); }
void Start() { rscGainOnWin = RscManager.MatchRscList(rscGainOnWin, 0); }
public override void Awake() { base.Awake(); RscManager.MatchRscList(rscGainOnDestroyed, 0); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (instance == null) { Awake(); return; } GUI.changed = false; Undo.RecordObject(instance, "GameControl"); EditorGUILayout.Space(); cont = new GUIContent("Cap player Life:", "Check to cap player life. Player will always start with full life when life is capped"); instance.capLife = EditorGUILayout.Toggle(cont, instance.capLife); cont = new GUIContent("Player's Life:", "Player Life. When reach 0, game is over"); instance.life = EditorGUILayout.IntField(cont, instance.life); cont = new GUIContent("Player's Life Cap:", "Player Life Capacity. When enabled, player life will never exceed this value"); if (instance.capLife) { instance.lifeCap = EditorGUILayout.IntField(cont, instance.lifeCap); if (!Application.isPlaying) { instance.life = instance.lifeCap; } } else { EditorGUILayout.LabelField("Player's Life Cap:", "-"); } EditorGUILayout.Space(); cont = new GUIContent("Regenerate Life:", "Check to enable regeneration of player life."); instance.regenLife = EditorGUILayout.Toggle(cont, instance.regenLife); cont = new GUIContent("Life Regen Rate:", "The rate at which player life regenerate (in second)"); if (instance.capLife) { instance.lifeRegen = EditorGUILayout.FloatField(cont, instance.lifeRegen); } else { EditorGUILayout.LabelField("Player's Life Cap:", "-"); } EditorGUILayout.Space(); // public List<float> rscGainOnWin=new List<float>(); RscManager.MatchRscList(instance.rscGainOnWin, 0); cont = new GUIContent("Rsc Gain On Win:", "The amount of resource the player will gain when the level is beaten\nUseful for 'Carry Over' option in PerkManager is checked"); EditorGUILayout.LabelField(cont); for (int i = 0; i < RscDB.GetCount(); i++) { GUILayout.BeginHorizontal(); //EditorGUILayout.ObjectField(RscDB.GetIcon(i), typeof(Sprite), true, GUILayout.Width(20), GUILayout.Height(20)); //EditorGUILayout.Box("", GUILayout.Width(20), GUILayout.Height(20)); EditorGUILayout.LabelField(" - ", GUILayout.Width(40), GUILayout.Height(20)); Rect rect = GUILayoutUtility.GetLastRect(); rect.x += 20; rect.width -= 20; TDE.DrawSprite(rect, RscDB.GetIcon(i)); EditorGUIUtility.labelWidth -= 45; instance.rscGainOnWin[i] = EditorGUILayout.FloatField(RscDB.GetName(i), instance.rscGainOnWin[i]); EditorGUIUtility.labelWidth += 45; GUILayout.EndHorizontal(); } cont = new GUIContent("PerkRscGainOnWin:", "The amount of perk resource the player will gain when the level is beaten\nUseful for 'Carry Over' option in PerkManager is checked"); instance.perkRscGainOnWin = EditorGUILayout.IntField(cont, instance.perkRscGainOnWin); EditorGUILayout.Space(); cont = new GUIContent("MainMenu Name:", "Scene's name of the main menu to be loaded when return to menu on UI is called"); instance.mainMenuName = EditorGUILayout.TextField(cont, instance.mainMenuName); cont = new GUIContent("NextScene Name:", "Scene's name to be loaded when this level is completed"); instance.nextLevelName = EditorGUILayout.TextField(cont, instance.nextLevelName); EditorGUILayout.Space(); DefaultInspector(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
protected float DrawBasicSetting(float startX, float startY, Perk item) { //TDE.Label(startX, startY+=spaceY, width, height, "General Setting", "", TDE.headerS); string textF = "General 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, "Gained on Wave:", ""); CheckColor(item.autoUnlockOnWave, -1); //~ item.autoUnlockOnWave=EditorGUI.IntField(new Rect(startX+spaceX, startY, widthS, height), item.autoUnlockOnWave); ResetColor(); //~ startY+=10; TDE.Label(startX, startY += spaceY, width, height, "Cost:", "The cost of PerkManager resource required for the perk\nUsed when 'Use RscManager For Cost' is disabled in PerkManager"); item.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.cost); TDE.Label(startX, startY += spaceY, width, height, "Cost (Rsc):", "The cost of RscManager resource required for the perk\nUsed when 'Use RscManager For Cost' is enabled in PerkManager"); //~ while(item.costRsc.Count<RscDB.GetCount()) item.costRsc.Add(0); //~ while(item.costRsc.Count>RscDB.GetCount()) item.costRsc.RemoveAt(item.costRsc.Count-1); RscManager.MatchRscList(item.costRsc, 0); float cachedX = startX; for (int i = 0; i < RscDB.GetCount(); i++) { if (i > 0 && i % 3 == 0) { startX = cachedX; startY += spaceY; } if (i > 0) { startX += widthS + 2; } TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i)); item.costRsc[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.costRsc[i]); } startX = cachedX; //TDE.Label(startX, startY+=spaceY, width, height, "Repeatabe:", ""); //item.repeatable=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), item.repeatable); startY += 10; TDE.Label(startX, startY += spaceY, width, height, "AutoUnlockOnWave:", "If given a value, the perk will automatically be purchased for the player upon completing the specified wave"); CheckColor(item.autoUnlockOnWave, 0); item.autoUnlockOnWave = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.autoUnlockOnWave); ResetColor(); startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Min Level:", "The minimum level required before the perk becomes available\n\nThis is value of 'Level ID' in GameControl"); CheckColor(item.minLevel, 0); item.minLevel = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minLevel); ResetColor(); TDE.Label(startX, startY += spaceY, width, height, "Min Wave:", "The minimum wave required before the perk becomes available"); CheckColor(item.minWave, 0); item.minWave = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minWave); ResetColor(); TDE.Label(startX, startY += spaceY, width, height, "Min Perk Count:", "The minimum number of perk purchased required before the perk becomes available"); CheckColor(item.minPerkCount, 0); item.minPerkCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minPerkCount); ResetColor(); TDE.Label(startX, startY += spaceY, width, height, "Prereq Perk:", "Perk(s) required to be purchased before the perk becomes available"); for (int i = 0; i < item.prereq.Count; i++) { TDE.Label(startX + spaceX - 20, startY, widthS, height, "-"); int index = PerkDB.GetPrefabIndex(item.prereq[i]); if (index < 0) { item.prereq.RemoveAt(i); i -= 1; continue; } index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label); int prefabID = PerkDB.GetItem(index).prefabID; if (prefabID != item.prefabID && !item.prereq.Contains(prefabID)) { item.prereq[i] = prefabID; } if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-")) { item.prereq.RemoveAt(i); i -= 1; } startY += spaceY; } int newID = -1; CheckColor(item.prereq.Count, 0); newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label); if (newID >= 0 && !item.prereq.Contains(newID)) { item.prereq.Add(newID); } startY += 10; ResetColor(); return(startY); }
public void VerifyRscList(float fillValue) { cost = RscManager.MatchRscList(cost, fillValue); rscGain = RscManager.MatchRscList(rscGain, fillValue); }