private float DrawProceduralUnitSetting(float startX, float startY, ProceduralUnitSetting unitSetting) { if (unitSetting.enabled) { GUI.Box(new Rect(startX, startY, 185 * 4, proUnitItemHeightShow), ""); } else { GUI.Box(new Rect(startX, startY, 185 * 4, proUnitItemHeightHide), ""); } startX += 5; startY += 5; float cachedX = startX; float cachedY = startY; unitSetting.unitC = unitSetting.unit.GetComponent <UnitCreep>(); TDEditor.DrawSprite(new Rect(startX, startY, 30, 30), unitSetting.unitC.iconSprite); EditorGUI.LabelField(new Rect(startX + 32, startY, width, height), unitSetting.unitC.unitName); cont = new GUIContent("enabled: ", "Check to enable unit in the procedural generation otherwise unit will not be considered at all"); EditorGUI.LabelField(new Rect(startX + 32, startY + spaceY - 3, width, height), cont); unitSetting.enabled = EditorGUI.Toggle(new Rect(startX + 32 + 60, startY + spaceY - 3, width, height), unitSetting.enabled); if (!unitSetting.enabled) { proUnitItemHeightHide = startY + 40 - cachedY; return(startY + 35); } cont = new GUIContent("Min Wave:", "The minimum wave in which the creep will start appear in"); EditorGUI.LabelField(new Rect(startX += 185, startY + 5, width, height), cont); unitSetting.minWave = EditorGUI.IntField(new Rect(startX + 70, startY + 5, 40, height), unitSetting.minWave); EditorGUI.LabelField(new Rect(cachedX, startY += 24, 185 * 4 - 10, height), "______________________________________________________________________________________________________________________"); startY += spaceY; startX = cachedX; cont = new GUIContent("HitPoint (HP):"); DrawProceduralVariable(startX, startY, unitSetting.HP, cont); cont = new GUIContent("Shield:"); DrawProceduralVariable(startX += proceduralVariableWidth + 20, startY, unitSetting.shield, cont); cont = new GUIContent("Move Speed:"); DrawProceduralVariable(startX += proceduralVariableWidth + 20, startY, unitSetting.speed, cont); cont = new GUIContent("Spawn Interval:"); startY = DrawProceduralVariable(startX += proceduralVariableWidth + 20, startY, unitSetting.interval, cont); proUnitItemWidth = startX + proceduralVariableWidth + 20; proUnitItemHeightShow = (startY + spaceY + 8) - cachedY; return(startY + spaceY); }
protected float DrawUnitStatsResource(float startX, float startY, UnitStat stat, Unit unit, bool isTower = true) { GUI.Box(new Rect(startX, startY, spaceX + 2 * widthS + 10, statContentHeight), ""); float cachedY = startY; startX += 5; startY += 8; spaceX += 8; widthS -= 5; //width-=10; if (isTower) { startY = DrawUnitStatsTower(startX, startY, stat) + 8; } startY = DrawShootEffectObject(startX, startY + 5, stat, unit, isTower); startY += 5; cont = new GUIContent("Cooldown:", "Duration between each attack"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); stat.cooldown = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), stat.cooldown); startY += 5; if (stat.rscGain.Count != rscDB.rscList.Count) { while (stat.rscGain.Count > rscDB.rscList.Count) { stat.rscGain.RemoveAt(stat.rscGain.Count - 1); } while (stat.rscGain.Count < rscDB.rscList.Count) { stat.rscGain.Add(0); } } cont = new GUIContent("Resource Gain:", "The resource gain by unit at each cooldown interval\nOnly applicable to ResourceTower"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); int count = 0; startY += spaceY; float cachedX = startX; for (int i = 0; i < rscDB.rscList.Count; i++) { TDEditor.DrawSprite(new Rect(startX + 10, startY - 1, 20, 20), rscDB.rscList[i].icon); stat.rscGain[i] = EditorGUI.IntField(new Rect(startX + 30, startY, widthS, height), stat.rscGain[i]); count += 1; startX += 65; if (count == 3) { startY += spaceY; startX = cachedX; } } startX = cachedX; startY += 5; startX -= 5; startY += 5; spaceX -= 8; widthS += 5;//width+=10; statContentHeight = startY + spaceY - cachedY; return(startY + spaceY); }
private void DrawSubWavePreview(float startX, float startY, Wave wave) { for (int i = 0; i < wave.subWaveList.Count; i++) { SubWave subWave = wave.subWaveList[i]; Sprite icon = subWave.unitC == null ? null : subWave.unitC.iconSprite; TDEditor.DrawSprite(new Rect(startX, startY, 30, 30), icon); EditorGUI.LabelField(new Rect(startX + 33, startY + 7, 30, 30), "x" + subWave.count); startX += 70; } }
private Vector2 DrawAbilityConfigurator(float startX, float startY, Ability ability) { TDEditor.DrawSprite(new Rect(startX, startY, 60, 60), ability.icon); startX += 65; cont = new GUIContent("Name:", "The ability name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += spaceY / 2, width, height), cont); ability.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.name); cont = new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ability.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), ability.icon, typeof(Sprite), false); startX -= 65; startY += 10 + spaceY; //cachedY=startY; startY = DrawGeneralSetting(startX, startY + spaceY, ability); startY = DrawVisualSetting(startX, startY + spaceY, ability); startY = DrawStatsSetting(startX, startY + spaceY, ability); startY += 10; cont = new GUIContent("Use Custom Description:", "Enable to add your own runtime description to this ability"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); ability.useCustomDesp = EditorGUI.Toggle(new Rect(startX + spaceX + 25, startY, 40, height), ability.useCustomDesp); if (ability.useCustomDesp) { GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; //cont=new GUIContent(" - Description (to be used in runtime): ", ""); //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, 400, 20), cont); ability.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY, 270, 150), ability.desp, style); startY += 170; } return(new Vector2(startX, startY + 30)); }
protected float DrawUnitStatsTower(float startX, float startY, UnitStat stat) { cont = new GUIContent("Construct Duration:", "The time in second it takes to construct (if this is the first level)/upgrade (if this is not the first level)"); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); stat.buildDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), stat.buildDuration); cont = new GUIContent("Deconstruct Duration:", "The time in second it takes to deconstruct if the unit is in this level"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); stat.unBuildDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), stat.unBuildDuration); startY += 5; if (stat.cost.Count != rscDB.rscList.Count) { while (stat.cost.Count > rscDB.rscList.Count) { stat.cost.RemoveAt(stat.cost.Count - 1); } while (stat.cost.Count < rscDB.rscList.Count) { stat.cost.Add(0); } } cont = new GUIContent("Build/Upgrade Cost:", "The resource required to build/upgrade to this level"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); int count = 0; startY += spaceY; float cachedX = startX; for (int i = 0; i < rscDB.rscList.Count; i++) { TDEditor.DrawSprite(new Rect(startX + 10, startY - 1, 20, 20), rscDB.rscList[i].icon); stat.cost[i] = EditorGUI.IntField(new Rect(startX + 30, startY, widthS, height), stat.cost[i]); count += 1; startX += 65; if (count == 3) { startY += spaceY + 3; startX = cachedX; } } //startX=cachedX; return(startY + spaceY); }
protected float DrawUnitBasicStats(float startX, float startY, Unit unit) { TDEditor.DrawSprite(new Rect(startX, startY, 60, 60), unit.iconSprite); startX += 65; cont = new GUIContent("Name:", "The unit name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += 5, width, height), cont); unit.unitName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), unit.unitName); cont = new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.iconSprite = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.iconSprite, typeof(Sprite), false); cont = new GUIContent("Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.gameObject, typeof(GameObject), false); startX -= 65; startY += spaceY * 2; string text = "HitPoint and Shield " + (!foldHitPoint ? "(show)" : "(hide)"); foldHitPoint = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldHitPoint, text, foldoutStyle); if (foldHitPoint) { float cachedY = startY += spaceY; startX += 15; cont = new GUIContent("HitPoint(HP):", "The unit default's HitPoint.\nThis is the base value to be modified by various in game bonus."); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); unit.defaultHP = EditorGUI.FloatField(new Rect(startX + 80, startY, widthS, height), unit.defaultHP); cont = new GUIContent(" - Regen:", "HP regeneration rate. The amount of HP to be regenerated per second"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.HPRegenRate = EditorGUI.FloatField(new Rect(startX + 80, startY, widthS, height), unit.HPRegenRate); cont = new GUIContent(" - Stagger:", "HP regeneration stagger duration(in second). The duration which the HP regen will be stopped when a unit is hit. Once the duration is passed the HP will start regenerating again"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.HPRegenRate > 0) { unit.HPStaggerDuration = EditorGUI.FloatField(new Rect(startX + 80, startY, widthS, height), unit.HPStaggerDuration); } else { EditorGUI.LabelField(new Rect(startX + 80, startY, 40, height), new GUIContent("-", "")); } startX += 140; startY = cachedY; cont = new GUIContent("Shield:", "The unit default's Shield. Shield can act as a regenerative damage absorber. A unit only be damaged once its shield has been depleted.\nThis is the base value to be modified by various in game bonus."); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); unit.defaultShield = EditorGUI.FloatField(new Rect(startX + 70, startY, widthS, height), unit.defaultShield); cont = new GUIContent(" - Regen:", "Shield regeneration rate. The amount of shield to be regenerated per second"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.defaultShield > 0) { unit.shieldRegenRate = EditorGUI.FloatField(new Rect(startX + 70, startY, widthS, height), unit.shieldRegenRate); } else { EditorGUI.LabelField(new Rect(startX + 70, startY, 40, height), new GUIContent("-", "")); } cont = new GUIContent(" - Stagger:", "Shield regeneration stagger duration(in second). The duration which the shield regen will be stopped when a unit is hit. Once the duration is passed the shield will start regenerating again"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.defaultShield > 0 && unit.shieldRegenRate > 0) { unit.shieldStaggerDuration = EditorGUI.FloatField(new Rect(startX + 70, startY, widthS, height), unit.shieldStaggerDuration); } else { EditorGUI.LabelField(new Rect(startX + 70, startY, 40, height), new GUIContent("-", "")); } } return(startY + spaceY); }
private float DrawSubWave(float startX, float startY, Wave wave) { float cachedY = startY; spaceX -= 20; for (int i = 0; i < wave.subWaveList.Count; i++) { SubWave subWave = wave.subWaveList[i]; startY = cachedY; GUI.Box(new Rect(startX, startY, subWaveBoxWidth, subWaveBoxHeight), ""); startX += 5; startY += 5; if (subWave.unit != null && subWave.unitC == null) { subWave.unitC = subWave.unit.GetComponent <UnitCreep>(); } if (subWave.unitC != null && subWave.unit != subWave.unitC.gameObject) { subWave.unit = subWave.unitC.gameObject; } Sprite icon = subWave.unitC == null ? null : subWave.unitC.iconSprite; TDEditor.DrawSprite(new Rect(startX, startY, 30, 30), icon); int index = subWave.unitC != null?TDEditor.GetCreepIndex(subWave.unitC.prefabID) : 0; cont = new GUIContent("Creep Prefab:", "The creep prefab to be spawned"); EditorGUI.LabelField(new Rect(startX + 32, startY, width, height), cont); index = EditorGUI.Popup(new Rect(startX + 32, startY + spaceY - 4, width, height), index, creepLabel); if (index > 0) { subWave.unitC = creepDB.creepList[index - 1]; } else { subWave.unitC = null; } startY += 35; cont = new GUIContent("Number of Unit:", "Number of unit to be spawned"); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); subWave.count = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), subWave.count); cont = new GUIContent("Start Delay:", "Time delay before the first creep of this subwave start spawn"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); subWave.delay = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.delay); cont = new GUIContent("Spawn Interval:", "The time interval in second between each single individual spawned"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); subWave.interval = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.interval); cont = new GUIContent("Alternate Path:", "The path to use for this subwave, if it's different from the default path. Optional and can be left blank"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); subWave.path = (PathTD)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, widthS + 40, height), subWave.path, typeof(PathTD), true); startY += 5; EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Override:"); GUI.color = subWave.overrideHP >= 0 ? Color.white : Color.grey; cont = new GUIContent(" - HP:", "Override the value of default HP set in CreepEditor. Only valid if value is set to >0"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); subWave.overrideHP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.overrideHP); GUI.color = subWave.overrideShield >= 0 ? Color.white : Color.grey; cont = new GUIContent(" - Shield:", "Override the value of default shield set in CreepEditor. Only valid if value is set to >0"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); subWave.overrideShield = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.overrideShield); GUI.color = subWave.overrideMoveSpd >= 0 ? Color.white : Color.grey; cont = new GUIContent(" - Move Speed:", "Override the value of default MoveSpeed set in CreepEditor. Only valid if value is set to >0"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); subWave.overrideMoveSpd = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.overrideMoveSpd); GUI.color = Color.white; startX += subWaveBoxWidth + 10; subWaveBoxHeight = startY + spaceY + 5 - cachedY; } spaceX += 20; return(cachedY + subWaveBoxHeight); }
private float DrawSpawnInfo(float startX, float startY) { maxSubWaveSize = 1; while (waveFoldList.Count < instance.waveList.Count) { waveFoldList.Add(true); } while (waveFoldList.Count > instance.waveList.Count) { waveFoldList.RemoveAt(waveFoldList.Count - 1); } startY += 5; for (int i = 0; i < instance.waveList.Count; i++) { Wave wave = instance.waveList[i]; if (deleteID == i) { if (GUI.Button(new Rect(startX, startY, 60, 20), "Cancel")) { deleteID = -1; } GUI.color = Color.red; if (GUI.Button(new Rect(startX + 65, startY, 20, 20), "X")) { instance.waveList.RemoveAt(i); i -= 1; deleteID = -1; } GUI.color = Color.white; } else { cont = new GUIContent("X", "Delete wave"); if (GUI.Button(new Rect(startX, startY, 20, 20), cont)) { deleteID = i; } } float offsetX = deleteID == i ? 60 : 0; waveFoldList[i] = EditorGUI.Foldout(new Rect(startX + 25 + offsetX, startY + 3, width, height), waveFoldList[i], "wave " + i, foldoutStyle); if (!waveFoldList[i]) //preview { DrawSubWavePreview(startX + 120, startY - 5, wave); } else //details { startX += 25; startY += 3; cont = new GUIContent("SubWave Size: " + wave.subWaveList.Count, "Number of sub waves in the level"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (GUI.Button(new Rect(startX + spaceX, startY, widthS, height), "-1")) { if (wave.subWaveList.Count > 1) { wave.subWaveList.RemoveAt(wave.subWaveList.Count - 1); } } if (GUI.Button(new Rect(startX + spaceX + 50, startY, widthS, height), "+1")) { wave.subWaveList.Add(new SubWave()); } startY = DrawSubWave(startX, startY + spaceY + 5, wave) + 8; cont = new GUIContent("Time To Next Wave: ", "Time until next wave"); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); if (instance.spawnMode == SpawnManager._SpawnMode.Continous) { wave.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), wave.duration); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-"); } float reqDuration = wave.CalculateSpawnDuration(); EditorGUI.LabelField(new Rect(startX + spaceX + 50, startY, 500, height), "(Time to spawn all units: " + reqDuration.ToString("f1") + "s)"); cont = new GUIContent("Resource Gain:", "The amount of resource player will gain when surviving the wave"); EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont); if (wave.rscGainList.Count < rscDB.rscList.Count) { wave.rscGainList.Add(0); } if (wave.rscGainList.Count > rscDB.rscList.Count) { wave.rscGainList.RemoveAt(wave.rscGainList.Count - 1); } float cachedX = startX; startX += spaceX; for (int n = 0; n < rscDB.rscList.Count; n++) { TDEditor.DrawSprite(new Rect(startX, startY - 2, 20, 20), rscDB.rscList[n].icon); wave.rscGainList[n] = EditorGUI.IntField(new Rect(startX + 20, startY, widthS, height - 2), wave.rscGainList[n]); startX += 75; } startX = cachedX; cont = new GUIContent("Life Gained: ", "The amount of life player will gain when surviving the wave"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); wave.lifeGain = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), wave.lifeGain); cont = new GUIContent("Energy Gained: ", "The amount of energy (for abilities) player will gain when surviving the wave"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); wave.energyGain = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), wave.energyGain); startX -= 25; } startY += spaceY * 2; } return(startY); }
private float DrawProceduralSetting(float startX, float startY) { WaveGenerator waveGen = instance.waveGenerator; float cachedY = startY; float cachedX = startX; cont = new GUIContent("Sub Wave Count:"); startY = DrawProceduralVariable(startX, cachedY, waveGen.subWaveCount, cont); cont = new GUIContent("Total Creep Count:"); startY = DrawProceduralVariable(startX += proceduralVariableWidth + 20, cachedY, waveGen.unitCount, cont); float alignY = startY += spaceY; startY = cachedY; startX += proceduralVariableWidth + 40; cont = new GUIContent("SimilarSubwave:", "Check to have identical subwave for each wave"); EditorGUI.LabelField(new Rect(startX, startY, width, height), cont); waveGen.similarSubWave = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), waveGen.similarSubWave); startY += 5; cont = new GUIContent("Utilise All Path:", "Check to have the generator to use all the path when possible, by assigning different path to each subwave (when there's more path than subwave)"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); waveGen.utiliseAllPath = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), waveGen.utiliseAllPath); showProceduralPathList = EditorGUI.Foldout(new Rect(startX, startY += spaceY, widthS, height), showProceduralPathList, "Path List " + (showProceduralPathList ? "" : "(" + waveGen.pathList.Count + ")")); if (showProceduralPathList) { int count = waveGen.pathList.Count; count = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), count); while (count < waveGen.pathList.Count) { waveGen.pathList.RemoveAt(waveGen.pathList.Count - 1); } while (count > waveGen.pathList.Count) { waveGen.pathList.Add(null); } for (int i = 0; i < waveGen.pathList.Count; i++) { EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Element " + (i + 1)); waveGen.pathList[i] = (PathTD)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), waveGen.pathList[i], typeof(PathTD), true); } startY += spaceY; } startX = cachedX; cachedY = rscDB.rscList.Count > 2 ? Mathf.Max(startY, alignY) : alignY; while (waveGen.rscSettingList.Count < rscDB.rscList.Count) { waveGen.rscSettingList.Add(new ProceduralVariable(0, 0)); } while (waveGen.rscSettingList.Count > rscDB.rscList.Count) { waveGen.rscSettingList.RemoveAt(waveGen.rscSettingList.Count - 1); } for (int i = 0; i < rscDB.rscList.Count; i++) { startY = cachedY + 10; TDEditor.DrawSprite(new Rect(startX, startY - 2, 20, 20), rscDB.rscList[i].icon); cont = new GUIContent(" " + rscDB.rscList[i].name + ":"); startY = DrawProceduralVariable(startX, startY, waveGen.rscSettingList[i], cont); startX += proceduralVariableWidth + 20; } startX = cachedX; startY += spaceY; for (int i = 0; i < waveGen.unitSettingList.Count; i++) { ProceduralUnitSetting unitSetting = waveGen.unitSettingList[i]; startY = DrawProceduralUnitSetting(startX, startY + 12, unitSetting); } return(startY); }
void DrawPerkList() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); showPerkList = EditorGUILayout.Foldout(showPerkList, "Show Perk List"); EditorGUILayout.EndHorizontal(); if (showPerkList) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableAll") && !Application.isPlaying) { instance.unavailableIDList = new List <int>(); } if (GUILayout.Button("DisableAll") && !Application.isPlaying) { instance.purchasedIDList = new List <int>(); instance.unavailableIDList = new List <int>(); for (int i = 0; i < perkDB.perkList.Count; i++) { instance.unavailableIDList.Add(perkDB.perkList[i].ID); } } EditorGUILayout.EndHorizontal(); for (int i = 0; i < perkDB.perkList.Count; i++) { Perk perk = perkDB.perkList[i]; GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); Rect rect = GUILayoutUtility.GetLastRect(); TDEditor.DrawSprite(rect, perk.icon, perk.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(perk.name, GUILayout.ExpandWidth(false)); GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); bool flag = !instance.unavailableIDList.Contains(perk.ID) ? true : false; EditorGUILayout.LabelField(new GUIContent(" - enabled: ", "check to enable the perk in this level"), GUILayout.Width(70)); flag = EditorGUILayout.Toggle(flag); if (!Application.isPlaying && EditorGUI.EndChangeCheck()) { if (!flag && !instance.unavailableIDList.Contains(perk.ID)) { instance.unavailableIDList.Add(perk.ID); } else if (flag) { instance.unavailableIDList.Remove(perk.ID); } } if (!instance.unavailableIDList.Contains(perk.ID)) { flag = instance.purchasedIDList.Contains(perk.ID); EditorGUILayout.LabelField(new GUIContent(" - purchased: ", "check to set the perk as purchased right from the start"), GUILayout.Width(70)); flag = EditorGUILayout.Toggle(flag); if (!Application.isPlaying) { if (flag) { instance.purchasedIDList.Add(perk.ID); } else { instance.purchasedIDList.Remove(perk.ID); } } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } }
public override bool OnGUI() { if (!base.OnGUI()) { return(true); } if (window == null) { Init(); } Undo.RecordObject(this, "window"); Undo.RecordObject(rscDB, "rscDB"); if (GUI.Button(new Rect(window.position.width - 110, 10, 100, 30), "Save")) { SetDirtyTD(); } if (GUI.Button(new Rect(10, 10, 100, 30), "New Resource")) { //EditorDBManager.AddNewRsc(); rscDB.rscList.Add(new Rsc()); } List <Rsc> rscList = rscDB.rscList; if (rscList.Count > 0) { GUI.Box(new Rect(5, 50, 50, 20), "ID"); GUI.Box(new Rect(5 + 50 - 1, 50, 70 + 1, 20), "Texture"); GUI.Box(new Rect(5 + 120 - 1, 50, 150 + 2, 20), "Name"); GUI.Box(new Rect(5 + 270, 50, window.position.width - 280, 20), ""); } int row = 0; for (int i = 0; i < rscDB.rscList.Count; i++) { if (i % 2 == 0) { GUI.color = new Color(.8f, .8f, .8f, 1); } else { GUI.color = Color.white; } GUI.Box(new Rect(5, 75 + i * 49, window.position.width - 10, 50), ""); GUI.color = Color.white; GUI.Label(new Rect(22, 15 + 75 + i * 49, 50, 20), rscList[i].ID.ToString()); TDEditor.DrawSprite(new Rect(12 + 50, 3 + 75 + i * 49, 44, 44), rscList[i].icon); rscList[i].name = EditorGUI.TextField(new Rect(5 + 120, 5 + 75 + i * 49, 150, 18), rscList[i].name); GUI.Label(new Rect(5 + 120, 25 + 75 + i * 49, 120, 18), "Icon: "); rscList[i].icon = (Sprite)EditorGUI.ObjectField(new Rect(45 + 120, 25 + 75 + i * 49, 110, 18), rscList[i].icon, typeof(Sprite), false); if (deleteID != i) { if (GUI.Button(new Rect(window.position.width - 35, 12 + 75 + i * 49, 25, 25), "X")) { deleteID = i; } } else { GUI.color = Color.red; if (GUI.Button(new Rect(window.position.width - 65, 12 + 75 + i * 49, 25, 25), "X")) { //EditorDBManager.RemoveRsc(i); rscList.RemoveAt(deleteID); i -= 1; deleteID = -1; } GUI.color = Color.green; if (GUI.Button(new Rect(window.position.width - 35, 12 + 75 + i * 49, 25, 25), "-")) { deleteID = -1; } GUI.color = Color.white; } row += 1; } if (GUI.changed) { SetDirtyTD(); } return(true); }
protected float DrawCreepSetting(float startX, float startY, UnitCreep unit) { //EditorGUI.LabelField(new Rect(startX, startY, width, height), "Visual Effect", headerStyle); string text = "Basic Creep Setting " + (!foldBasicSetting ? "(show)" : "(hide)"); foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldBasicSetting, text, foldoutStyle); if (foldBasicSetting) { startX += 15; int type = (int)unit.type; cont = new GUIContent("Creep Type:", "Type of the creep. Different type of creep has different capabilities"); EditorGUI.LabelField(new Rect(startX, startY += spaceY + 3, width, height), cont); contL = new GUIContent[creepTypeLabel.Length]; for (int i = 0; i < contL.Length; i++) { contL[i] = new GUIContent(creepTypeLabel[i], creepTypeTooltip[i]); } type = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL); unit.type = (_CreepType)type; startY += 5; cont = new GUIContent("Move Speed:", "Moving speed of the creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.moveSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.moveSpeed); cont = new GUIContent("Life Cost:", "The amont of life taken from player when this creep reach it's destination"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.lifeCost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeCost); startY += 5; cont = new GUIContent("Flying:", "Check to set the creep as flying unit."); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.flying = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.flying); cont = new GUIContent("Face Destination:", "Check to have the target's transform face the traveling direction."); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.rotateTowardsDestination = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.rotateTowardsDestination); cont = new GUIContent("Match Slope:", "Check to have the target's transform rotate (in x-axis) to match the slope they are moving along."); EditorGUI.LabelField(new Rect(startX + spaceX + 50, startY, width, height), cont); if (!unit.rotateTowardsDestination) { EditorGUI.LabelField(new Rect(startX + spaceX * 2 + 10, startY, widthS, height), "-"); } else { unit.rotateTowardsDestinationX = EditorGUI.Toggle(new Rect(startX + spaceX * 2 + 10, startY, widthS, height), unit.rotateTowardsDestinationX); } startY += 5; cont = new GUIContent("Life Gain:", "Life awarded to the player when player successfully destroy this creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.lifeValue = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeValue); cont = new GUIContent("Energy Gain:", "Energy awarded to the player when player successfully destroy this creep"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.valueEnergyGain = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.valueEnergyGain); startY += 5; while (unit.valueRscMin.Count < rscDB.rscList.Count) { unit.valueRscMin.Add(0); } while (unit.valueRscMax.Count < rscDB.rscList.Count) { unit.valueRscMax.Add(0); } while (unit.valueRscMin.Count > rscDB.rscList.Count) { unit.valueRscMin.RemoveAt(unit.valueRscMin.Count - 1); } while (unit.valueRscMax.Count > rscDB.rscList.Count) { unit.valueRscMax.RemoveAt(unit.valueRscMax.Count - 1); } cont = new GUIContent("Resource Gain Upon Destroyed:", "The amont of resource taken from player when this creep reach it's destination"); //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont); rscGainFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), rscGainFoldout, cont); if (rscGainFoldout) { for (int i = 0; i < rscDB.rscList.Count; i++) { TDEditor.DrawSprite(new Rect(startX + 25, startY += spaceY - 2, 20, 20), rscDB.rscList[i].icon); startY += 2; EditorGUI.LabelField(new Rect(startX, startY, width, height), " - min/max"); //+rscList[i].name); unit.valueRscMin[i] = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.valueRscMin[i]); unit.valueRscMax[i] = EditorGUI.IntField(new Rect(startX + spaceX + 40, startY, widthS, height), unit.valueRscMax[i]); } startY += 5; } startY += 5; cont = new GUIContent("SpawnUponDestroyed:", "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"); GUI.Label(new Rect(startX, startY += spaceY, width, height), cont); int ID = unit.spawnUponDestroyed != null?TDEditor.GetCreepIndex(unit.spawnUponDestroyed.prefabID) : 0; ID = EditorGUI.Popup(new Rect(startX + spaceX + 15, startY, width - 15, height), ID, creepLabel); if (ID > 0) { unit.spawnUponDestroyed = creepDB.creepList[ID - 1]; } else if (ID == 0) { unit.spawnUponDestroyed = null; } cont = new GUIContent(" - Num to Spawn:", "The amount of creep to spawn when this unit is destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.spawnUponDestroyed == null) { GUI.Label(new Rect(startX + spaceX + 15, startY, widthS, height), "-"); } else { unit.spawnUponDestroyedCount = EditorGUI.IntField(new Rect(startX + spaceX + 15, startY, widthS, height), unit.spawnUponDestroyedCount); } cont = new GUIContent(" - HP Multiplier:", "The percentage of HP to pass to the next unit. 0.5 being 50% of parent unit's fullHP, 1 being 100% of parent unit's fullHP"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.spawnUponDestroyed == null) { GUI.Label(new Rect(startX + spaceX + 15, startY, widthS, height), "-"); } else { unit.spawnUnitHPMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX + 15, startY, widthS, height), unit.spawnUnitHPMultiplier); } startY += 5; cont = new GUIContent("Destination Effect:", "The effect object to be spawned when the unit reaches its destination\nThis is entirely optional"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); unit.destinationEffObj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), unit.destinationEffObj, typeof(GameObject), false); cont = new GUIContent(" - AutoDestroy:", "Check if the effect object needs to be removed from the game"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.destinationEffObj != null) { unit.autoDestroydestinationEff = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.autoDestroydestinationEff); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", "")); } cont = new GUIContent(" - EffectDuration:", "The delay in seconds before the effect object is destroyed"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); if (unit.destinationEffObj != null && unit.autoDestroydestinationEff) { unit.destinationEffDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.destinationEffDuration); } else { EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), new GUIContent("-", "")); } } return(startY + spaceY); }
Vector2 DrawWeaponConfigurator(float startX, float startY, FPSWeapon weapon) { TDEditor.DrawSprite(new Rect(startX, startY, 60, 60), weapon.icon); startX += 65; cont = new GUIContent("Name:", "The ability name to be displayed in game"); EditorGUI.LabelField(new Rect(startX, startY += 5, width, height), cont); weapon.weaponName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width - 5, height), weapon.weaponName); cont = new GUIContent("Icon:", "The ability icon to be displayed in game, must be a sprite"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); weapon.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), weapon.icon, typeof(Sprite), false); cont = new GUIContent("Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width - 5, height), weapon.gameObject, typeof(GameObject), false); startX -= 65; startY += spaceY; //cachedY=startY; EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Basic Setting", headerStyle); startX += 15; cont = new GUIContent("Damage Type:", "The damage type of the weapon\nDamage type can be configured in Damage Armor Table Editor"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); weapon.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weapon.damageType, damageTypeLabel); cont = new GUIContent("Recoil:", "The recoil force of the weapon"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); weapon.recoil = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), weapon.recoil); cont = new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n"); shootPointFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), shootPointFoldout, cont); int shootPointCount = weapon.shootPoints.Count; shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount); if (shootPointCount != weapon.shootPoints.Count) { while (weapon.shootPoints.Count < shootPointCount) { weapon.shootPoints.Add(null); } while (weapon.shootPoints.Count > shootPointCount) { weapon.shootPoints.RemoveAt(weapon.shootPoints.Count - 1); } } if (shootPointFoldout) { for (int i = 0; i < weapon.shootPoints.Count; i++) { int objID = GetObjectIDFromHList(weapon.shootPoints[i], objHList); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Element " + (i + 1)); objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList); weapon.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform; } } startY += 10; cont = new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned."); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); weapon.stats[0].shootObject = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), weapon.stats[0].shootObject, typeof(ShootObject), false); startY += 5; cont = new GUIContent("ReloadSound:", "The audio-clip to be played when the weapon reloads (optional)"); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); weapon.reloadSound = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), weapon.reloadSound, typeof(AudioClip), false); startX -= 15; startY += 35; if (weapon.stats.Count == 0) { weapon.stats.Add(new UnitStat()); } string text = "Weapon Stats " + (!foldStats ? "(show)" : "(hide)"); foldStats = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldStats, text, foldoutStyle); if (foldStats) { startX += 15; startY = DrawWeaponStat(weapon.stats[0], startX + 15, startY += spaceY); //for(int i=0; i<weapon.stats.Count; i++){ // startY=DrawWeaponStat(weapon.stats[i], startX+15, startY+=spaceY); //} startX -= 15; } startY += 25; GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; cont = new GUIContent("Weapon description (to be used in runtime): ", ""); EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont); weapon.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), weapon.desp, style); return(new Vector2(startX, startY + 170)); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.changed = false; Undo.RecordObject(instance, "PlatformTD"); serializedObject.Update(); EditorGUILayout.Space(); cont = new GUIContent("Gizmo(Show Nodes):", "Check to enable gizmo to show path-finding nodes generated on the grid\nThe gizmo are only visible in runtime and are for debug purpose only"); EditorGUILayout.PropertyField(serializedObject.FindProperty("GizmoShowNodes"), cont); EditorGUILayout.Space(); showTowerList = EditorGUILayout.Foldout(showTowerList, "Show Valid Tower List"); if (showTowerList) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableAll")) { EnableAllTowerOnAll(); } if (GUILayout.Button("DisableAll")) { DisableAllTowerOnAll(); } EditorGUILayout.EndHorizontal(); for (int i = 0; i < towerDB.towerList.Count; i++) { UnitTower tower = towerDB.towerList[i]; //if(tower.disableInBuildManager) continue; GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); Rect rect = GUILayoutUtility.GetLastRect(); TDEditor.DrawSprite(rect, tower.iconSprite, tower.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(tower.name, GUILayout.ExpandWidth(false)); EditorGUI.showMixedValue = !UnavailableListSharesValue(tower.prefabID); EditorGUI.BeginChangeCheck(); bool flag = !instance.unavailableTowerIDList.Contains(tower.prefabID) ? true : false; flag = EditorGUILayout.Toggle(" - enabled:", flag); if (EditorGUI.EndChangeCheck()) { if (flag) { RemoveIDFromList(tower.prefabID); } else { AddIDToList(tower.prefabID); } } EditorGUI.showMixedValue = false; GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } EditorGUILayout.Space(); EditorGUILayout.Space(); DefaultInspector(); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.changed = false; Undo.RecordObject(instance, "BuildManager"); serializedObject.Update(); EditorGUILayout.Space(); srlPpt = serializedObject.FindProperty("buildMode"); EditorGUI.BeginChangeCheck(); cont = new GUIContent("Build Mode:", ""); contL = new GUIContent[buildModeLabel.Length]; for (int i = 0; i < contL.Length; i++) { contL[i] = new GUIContent(buildModeLabel[i], buildModeTooltip[i]); } int type = EditorGUILayout.Popup(cont, srlPpt.enumValueIndex, contL); if (EditorGUI.EndChangeCheck()) { srlPpt.enumValueIndex = type; } EditorGUILayout.Space(); cont = new GUIContent("Grid Size:", "The grid size of the grid on the platform"); EditorGUILayout.PropertyField(serializedObject.FindProperty("gridSize"), cont); cont = new GUIContent("AutoAdjustTextureToGrid:", "Check to let the BuildManager reformat the texture tiling of the platform to fix the gridsize"); EditorGUILayout.PropertyField(serializedObject.FindProperty("autoAdjustTextureToGrid"), cont); EditorGUILayout.Space(); cont = new GUIContent("DisableBuildInPlay:", "When checked, the player cannot build tower when there are active creep in the game"); EditorGUILayout.PropertyField(serializedObject.FindProperty("disableBuildWhenInPlay"), cont); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); showTowerList = EditorGUILayout.Foldout(showTowerList, "Show Tower List"); EditorGUILayout.EndHorizontal(); if (showTowerList) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableAll") && !Application.isPlaying) { instance.unavailableTowerIDList = new List <int>(); } if (GUILayout.Button("DisableAll") && !Application.isPlaying) { instance.unavailableTowerIDList = new List <int>(); for (int i = 0; i < towerDB.towerList.Count; i++) { if (towerDB.towerList[i].disableInBuildManager) { continue; } instance.unavailableTowerIDList.Add(towerDB.towerList[i].prefabID); } } EditorGUILayout.EndHorizontal(); int disableCount = 0; for (int i = 0; i < towerDB.towerList.Count; i++) { UnitTower tower = towerDB.towerList[i]; if (tower.disableInBuildManager) { if (instance.unavailableTowerIDList.Contains(tower.prefabID)) { instance.unavailableTowerIDList.Remove(tower.prefabID); } disableCount += 1; continue; } GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); Rect rect = GUILayoutUtility.GetLastRect(); TDEditor.DrawSprite(rect, tower.iconSprite, tower.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(tower.unitName, GUILayout.ExpandWidth(false)); EditorGUI.BeginChangeCheck(); bool flag = !instance.unavailableTowerIDList.Contains(tower.prefabID) ? true : false; flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the tower in this level"), flag); if (!Application.isPlaying && EditorGUI.EndChangeCheck()) { if (!flag && !instance.unavailableTowerIDList.Contains(tower.prefabID)) { instance.unavailableTowerIDList.Add(tower.prefabID); } else if (flag) { instance.unavailableTowerIDList.Remove(tower.prefabID); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } if (disableCount > 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField(" - " + disableCount + " Towers are disabled in BuildManager"); } } EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Open TowerEditor")) { UnitTowerEditorWindow.Init(); } EditorGUILayout.Space(); DefaultInspector(); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.changed = false; Undo.RecordObject(instance, "FPSControl"); EditorGUILayout.Space(); cont = new GUIContent("Use Tower Weapon:", "Check to have use the assigned weapon of the selected tower. When this is enabled, player cannot switch weapon."); instance.useTowerWeapon = EditorGUILayout.Toggle(cont, instance.useTowerWeapon); cont = new GUIContent("Aim Sensitivity:", "Mouse sensitivity when aiming in fps mode"); instance.aimSensitivity = EditorGUILayout.FloatField(cont, instance.aimSensitivity); cont = new GUIContent("Recoil Mode:", "The way shoot recoil works"); contL = new GUIContent[recoilModeLabel.Length]; for (int i = 0; i < contL.Length; i++) { contL[i] = new GUIContent(recoilModeLabel[i], recoilModeTooltip[i]); } instance.recoilMode = EditorGUILayout.Popup(cont, instance.recoilMode, contL); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); showPivotTransform = EditorGUILayout.Foldout(showPivotTransform, "Show Pivot Transforms & Camera"); EditorGUILayout.EndHorizontal(); if (showPivotTransform) { cont = new GUIContent("Weapon Pivot:", "The pivot transform of the weapon object."); instance.weaponPivot = (Transform)EditorGUILayout.ObjectField(cont, instance.weaponPivot, typeof(Transform), true); cont = new GUIContent("Camera Pivot:", "The pivot transform of the camera"); instance.cameraPivot = (Transform)EditorGUILayout.ObjectField(cont, instance.cameraPivot, typeof(Transform), true); cont = new GUIContent("Camera Transform:", "The transform which contains the fps camera component"); instance.camT = (Transform)EditorGUILayout.ObjectField(cont, instance.camT, typeof(Transform), true); } EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); showWeaponList = EditorGUILayout.Foldout(showWeaponList, "Show Weapon List"); EditorGUILayout.EndHorizontal(); if (showWeaponList) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableAll") && !Application.isPlaying) { instance.unavailableIDList = new List <int>(); } if (GUILayout.Button("DisableAll") && !Application.isPlaying) { instance.unavailableIDList = new List <int>(); for (int i = 0; i < fpsWeaponDB.weaponList.Count; i++) { instance.unavailableIDList.Add(fpsWeaponDB.weaponList[i].prefabID); } } EditorGUILayout.EndHorizontal(); int disableCount = 0; for (int i = 0; i < fpsWeaponDB.weaponList.Count; i++) { FPSWeapon weapon = fpsWeaponDB.weaponList[i]; if (weapon.disableInFPSControl) { if (instance.unavailableIDList.Contains(weapon.prefabID)) { instance.unavailableIDList.Remove(weapon.prefabID); } disableCount += 1; continue; } GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); Rect rect = GUILayoutUtility.GetLastRect(); TDEditor.DrawSprite(rect, weapon.icon, weapon.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(weapon.name, GUILayout.ExpandWidth(false)); EditorGUI.BeginChangeCheck(); bool flag = !instance.unavailableIDList.Contains(weapon.prefabID) ? true : false; flag = EditorGUILayout.Toggle(new GUIContent(" - enabled: ", "check to enable the weapon in this level"), flag); if (!Application.isPlaying && EditorGUI.EndChangeCheck()) { if (!flag && !instance.unavailableIDList.Contains(weapon.prefabID)) { instance.unavailableIDList.Add(weapon.prefabID); } else if (flag) { instance.unavailableIDList.Remove(weapon.prefabID); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); } if (disableCount > 0) { EditorGUILayout.Space(); EditorGUILayout.LabelField(" - " + disableCount + " weapon are disabled in FPSControl"); } } EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Open FPSWeaponEditor")) { FPSWeaponEditorWindow.Init(); } EditorGUILayout.Space(); DefaultInspector(); serializedObject.ApplyModifiedProperties(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
public override void OnInspectorGUI() { base.OnInspectorGUI(); GUI.changed = false; Undo.RecordObject(instance, "AbilityManager"); EditorGUILayout.Space(); cont = new GUIContent("Energy Capacity:", "The maximum amount of energy available to player. Energy is used to cast ability and is recharged overtime"); instance.fullEnergy = EditorGUILayout.FloatField(cont, instance.fullEnergy); cont = new GUIContent("Full Energy Start:", "Check to start the game with full energy"); instance.startWithFullEnergy = EditorGUILayout.Toggle(cont, instance.startWithFullEnergy); cont = new GUIContent(" - Starting Energy:", "The amount of energy player possess at the start of the game"); if (!instance.startWithFullEnergy) { instance.energy = EditorGUILayout.FloatField(cont, instance.energy); } else { EditorGUILayout.LabelField(cont, new GUIContent("-", "")); } EditorGUILayout.Space(); cont = new GUIContent("Energy Rate:", "The amount of energy to be recharged at each second"); instance.energyRate = EditorGUILayout.FloatField(cont, instance.energyRate); //cont=new GUIContent("ChargeBeforeSpawn:", "Check to start energy charging before spawning"); //instance.onlyChargeOnSpawn=EditorGUILayout.Toggle(cont, instance.onlyChargeOnSpawn); EditorGUILayout.Space(); cont = new GUIContent("Default Indicator:", "The default cursor indicator to used for ability target selecting in case the selected ability doesnt have a designated indicator"); instance.defaultIndicator = (Transform)EditorGUILayout.ObjectField(cont, instance.defaultIndicator, typeof(Transform), true); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(10)); showAbilityList = EditorGUILayout.Foldout(showAbilityList, "Show Ability List"); EditorGUILayout.EndHorizontal(); if (showAbilityList) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("EnableAll") && !Application.isPlaying) { instance.unavailableIDList = new List <int>(); } if (GUILayout.Button("DisableAll") && !Application.isPlaying) { instance.unavailableIDList = new List <int>(); for (int i = 0; i < abilityDB.abilityList.Count; i++) { if (abilityDB.abilityList[i].disableInAbilityManager) { continue; } instance.unavailableIDList.Add(abilityDB.abilityList[i].ID); } } EditorGUILayout.EndHorizontal(); for (int i = 0; i < abilityDB.abilityList.Count; i++) { Ability ability = abilityDB.abilityList[i]; if (ability.disableInAbilityManager) { if (instance.unavailableIDList.Contains(ability.ID)) { instance.unavailableIDList.Remove(ability.ID); } continue; } GUILayout.BeginHorizontal(); GUILayout.Box("", GUILayout.Width(40), GUILayout.Height(40)); Rect rect = GUILayoutUtility.GetLastRect(); TDEditor.DrawSprite(rect, ability.icon, ability.desp, false); GUILayout.BeginVertical(); EditorGUILayout.Space(); GUILayout.Label(ability.name, GUILayout.ExpandWidth(false)); GUILayout.BeginHorizontal(); EditorGUI.BeginChangeCheck(); bool flag = !instance.unavailableIDList.Contains(ability.ID) ? 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.unavailableIDList.Contains(ability.ID)) { instance.unavailableIDList.Add(ability.ID); } else if (flag) { instance.unavailableIDList.Remove(ability.ID); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUILayout.EndHorizontal(); } } EditorGUILayout.Space(); EditorGUILayout.Space(); if (GUILayout.Button("Open AbilityEditor")) { AbilityEditorWindow.Init(); } EditorGUILayout.Space(); DefaultInspector(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
protected Vector2 DrawList(float startX, float startY, float winWidth, float winHeight, List <Item> list, bool drawRemove = true, bool shiftItem = true, bool clampSelectID = true) { float width = minimiseList ? 60 : 260; if (!minimiseList && shiftItem) { if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up")) { if (shiftItemUpCallback != null) { shiftItemUpCallback(); } else { Debug.Log("call back is null"); } if (selectID * 35 < scrollPosList.y) { scrollPosList.y = selectID * 35; } } if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down")) { if (shiftItemDownCallback != null) { shiftItemDownCallback(); } else { Debug.Log("call back is null"); } if (visibleRectList.height - 35 < selectID * 35) { scrollPosList.y = (selectID + 1) * 35 - visibleRectList.height + 5; } } } visibleRectList = new Rect(startX, startY, width + 15, winHeight - startY - 5); contentRectList = new Rect(startX, startY, width, list.Count * 35 + 5); GUI.color = new Color(.8f, .8f, .8f, 1f); GUI.Box(visibleRectList, ""); GUI.color = Color.white; scrollPosList = GUI.BeginScrollView(visibleRectList, scrollPosList, contentRectList); startY += 5; startX += 5; for (int i = 0; i < list.Count; i++) { TDEditor.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), list[i].icon); if (minimiseList) { if (selectID == i) { GUI.color = new Color(0, 1f, 1f, 1f); } if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), "")) { Select(i); } GUI.color = Color.white; continue; } if (selectID == i) { GUI.color = new Color(0, 1f, 1f, 1f); } if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150 + (!drawRemove ? 60 : 0), 30), list[i].name)) { Select(i); } GUI.color = Color.white; if (!drawRemove) { continue; } if (deleteID == i) { if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel")) { deleteID = -1; } GUI.color = Color.red; if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm")) { if (selectID >= deleteID) { Select(Mathf.Max(0, selectID - 1)); } if (deleteItemCallback != null) { deleteItemCallback(); } else { Debug.Log("callback is null"); } deleteID = -1; } GUI.color = Color.white; } else { if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove")) { deleteID = i; } } } GUI.EndScrollView(); if (clampSelectID) { selectID = Mathf.Clamp(selectID, 0, list.Count - 1); } return(new Vector2(startX + width + 10, startY)); }