Vector2 DrawAbilityConfigurator(float startX, float startY, Ability item) { float maxX = startX; startY = TDE.DrawBasicInfo(startX, startY, item); TDE.Label(startX, startY += spaceY, width, height, "Hide In Inspector:", ""); item.hideInInspector = EditorGUI.Toggle(new Rect(startX + width, startY, width, height), item.hideInInspector); startY = DrawGeneralSetting(startX, startY + 10, item); startY += spaceY * 2; string text = "Ability Stats "; //+(!foldStats ? "(show)" : "(hide)"); foldStats = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldStats, text, TDE.foldoutS); if (foldStats) { int effType = (int)item.effectType; TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Type:", "Indicate what does the ability do"); contL = TDE.SetupContL(effTypeLabel, effTypeTooltip); effType = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), effType, contL); item.effectType = (Ability._EffectType)effType; startY += 10; if (item.effectType != Ability._EffectType.Default || item.effectDelay <= 0) { GUI.color = Color.grey; } TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Delay:", "Delay in second before the effects apply to target\n\nFor any visual effect to play out"); item.effectDelay = EditorGUI.FloatField(new Rect(startX + spaceX + 12, startY, widthS, height), item.effectDelay); GUI.color = item.effectType == Ability._EffectType.Default ? Color.white : Color.grey; startY = DrawStats(startX, startY, item.stats, _EType.Ability); GUI.color = Color.white; } else { startY += spaceY; } startY = DrawVisualSetting(startX, startY, item) + spaceY; startY += spaceY; GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; cont = new GUIContent("Unit description (for runtime and editor): ", ""); EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont); item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style); return(new Vector2(maxX, startY + 170)); }
protected float DrawVisualObject(float startX, float startY, VisualObject vo, string label, string tooltip) { TDE.Label(startX, startY, width, height, label, tooltip); vo.obj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), vo.obj, typeof(GameObject), true); TDE.Label(startX, startY += spaceY, width, height, " - Auto Destroy:", "Check if the spawned effect should be destroyed automatically"); if (vo.obj != null) { vo.autoDestroy = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), vo.autoDestroy); } else { TDE.Label(startX + spaceX, startY, width, height, "-"); } TDE.Label(startX, startY += spaceY, width, height, " - Effect Duration:", "How long before the spawned effect object is destroyed"); if (vo.obj != null && vo.autoDestroy) { vo.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, width, height), vo.duration); } else { TDE.Label(startX + spaceX, startY, width, height, "-"); } return(startY); }
protected float DrawCreepVisualEffect(float startX, float startY, UnitCreep creep) { string textF = "Visual Setting "; //+(!foldVisual ? "(show)" : "(hide)"); foldVisual = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldVisual, textF, TDE.foldoutS); if (!foldVisual) { return(startY); } startX += 12; startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectSpawn, "Spawn Effect", "OPTIONAL: The effect object to spawn when the creep is spawned"); startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectDestroyed, "Destroyed Effect", "OPTIONAL: The effect object to spawn when the creep is destroyed"); startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectDestination, "Destination Effect", "OPTIONAL: The effect object to spawn when the creep reach the destination"); TDE.Label(startX, startY += spaceY, width, height, "Sound-Spawn:", "OPTIONAL - The audio clip to play when the unit is spawned"); creep.soundSpawn = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundSpawn, typeof(AudioClip), true); TDE.Label(startX, startY += spaceY, width, height, "Sound -Destination:", "OPTIONAL - The audio clip to play when the unit reaches destination"); creep.soundDestination = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundDestination, typeof(AudioClip), true); TDE.Label(startX, startY += spaceY, width, height, "Sound-Destroyed:", "OPTIONAL - The audio clip to play when the unit is destroyed"); creep.soundDestroyed = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundDestroyed, typeof(AudioClip), true); return(startY); }
//protected float DrawTowerVisualEffect(float startX, float startY, UnitTower tower){ protected float DrawUnitAnimation(float startX, float startY, Unit item) { string textF = "Animation Setting "; //+(!foldVisual ? "(show)" : "(hide)"); foldAnimation = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldAnimation, textF, TDE.foldoutS); if (!foldAnimation) { return(startY); } startX += 12; int objIdx = GetIndexFromHierarchy(item.animatorT, objHierarchyList); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Animator Object:", "The transform object which contain the Animator component"); objIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel); item.animatorT = objHierarchyList[objIdx]; startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Clip Idle:", "The animation clip to play when the unit is idle"); item.clipIdle = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipIdle, typeof(AnimationClip), true); TDE.Label(startX, startY += spaceY, width, height, "Clip Hit:", "The animation clip to play when the unit is hit by an attack"); item.clipHit = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipHit, typeof(AnimationClip), true); TDE.Label(startX, startY += spaceY, width, height, "Clip Idle:", "The animation clip to play when the unit is destroyed"); item.clipDestroyed = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipDestroyed, typeof(AnimationClip), true); TDE.Label(startX, startY += spaceY, width, height, "Clip Attack:", "The animation clip to play when the unit attacks"); item.clipAttack = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipAttack, typeof(AnimationClip), true); TDE.Label(startX, startY += spaceY, width, height, " - delay:", "Unit's active target field-of-view in angle"); item.animationAttackDelay = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.animationAttackDelay); startY += 10; if (item.IsCreep()) { TDE.Label(startX, startY += spaceY, width, height, "Clip Move:", "The animation clip to play when the unit is moving"); item.clipMove = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipMove, typeof(AnimationClip), true); TDE.Label(startX, startY += spaceY, width, height, "Clip Spawn:", "The animation clip to play when the unit is spawned"); item.clipSpawn = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipSpawn, typeof(AnimationClip), true); TDE.Label(startX, startY += spaceY, width, height, "Clip Destination:", "The animation clip to play when the unit reaches destination"); item.clipDestination = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipDestination, typeof(AnimationClip), true); } if (item.IsTower()) { TDE.Label(startX, startY += spaceY, width, height, "Clip Construct:", "The animation clip to play when the unit is constructing"); item.clipConstruct = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipConstruct, typeof(AnimationClip), true); TDE.Label(startX, startY += spaceY, width, height, "Clip Deconstruct:", "The animation clip to play when the unit is deconstructing"); item.clipDeconstruct = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipDeconstruct, typeof(AnimationClip), true); } return(startY); }
public float DrawEffectTypeSetting(float startX, float startY, Perk item) { if (!item.SupportModNMul()) { return(startY); } int type = (int)item.effType; contL = TDE.SetupContL(effTypeLabel, effTypeTooltip); TDE.Label(startX, startY, width, height, "Effect Type:", "", TDE.headerS); type = EditorGUI.Popup(new Rect(startX + spaceX, startY, 2 * widthS + 3, height), new GUIContent(""), type, contL); item.effType = (Perk._EffType)type; item.effect.effType = (Effect._EffType)type; if (GUI.Button(new Rect(startX + spaceX + 2 * widthS + 5, startY, widthS * 2 - 12, height), "Reset")) { if (item.effType == Perk._EffType.Modifier) { item.gain = 0; for (int i = 0; i < item.gainList.Count; i++) { item.gainList[i] = 0; } if (item.type == _PerkType.ModifyAbility) { item.costMul = 0; } if (item.type == _PerkType.ModifyEffect) { item.effect.duration = 0; } } if (item.effType == Perk._EffType.Multiplier) { item.gain = 1; for (int i = 0; i < item.gainList.Count; i++) { item.gainList[i] = 1; } if (item.type == _PerkType.ModifyAbility) { item.costMul = 1; } if (item.type == _PerkType.ModifyEffect) { item.effect.duration = 1; } } item.effect.Reset(); } return(startY + spaceY); }
protected float DrawSpawnOverride(float startX, float startY, UnitCreep.SubUnitOverride ovrr, bool valid, bool fold, foldCallback callback) { string text = "Show Override Setting "; //+(!fold ? "(show)" : "(hide)"); fold = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), fold, text); callback(fold); if (fold) { startX += 12; spaceX += 30; width += 20; GUI.color = ovrr.mulHP <= 0 ? grey : white; TDE.Label(startX, startY += spaceY, width, height, " - HP Multiplier:", "Set >0 to enable override of the spawned unit HP\n\nThe override value is determined by applying this multiplier value to the parent unit HP"); if (valid) { ovrr.mulHP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulHP); } else { TDE.Label(startX + spaceX, startY, widthS, height, "-"); } GUI.color = white; GUI.color = ovrr.mulSH <= 0 ? grey : white; TDE.Label(startX, startY += spaceY, width, height, " - Shield Multiplier:", "Set >0 to enable override of the spawned unit shield\n\nThe override value is determined by applying this multiplier value to the parent unit shield"); if (valid) { ovrr.mulSH = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulSH); } else { TDE.Label(startX + spaceX, startY, widthS, height, "-"); } GUI.color = white; GUI.color = ovrr.mulSpd <= 0 ? grey : white; TDE.Label(startX, startY += spaceY, width, height, " - Speed Multiplier:", "Set >0 to enable override of the spawned unit speed\n\nThe override value is determined by applying this multiplier value to the parent unit speed"); if (valid) { ovrr.mulSpd = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulSpd); } else { TDE.Label(startX + spaceX, startY, widthS, height, "-"); } GUI.color = white; GUI.color = ovrr.mulRsc <= 0 ? grey : white; TDE.Label(startX, startY += spaceY, width, height, " - Rsc Gain Multiplier:", "Set >0 to enable override of the spawned unit resource gain on destroyed\n\nThe override value is determined by applying this multiplier value to the parent unit resource gain on destroyed"); if (valid) { ovrr.mulRsc = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulRsc); } else { TDE.Label(startX + spaceX, startY, widthS, height, "-"); } GUI.color = white; startX -= 12; spaceX -= 30; width -= 20; } return(startY); }
public static void Init(int prefabID = -1) { window = (PerkEditorWindow)EditorWindow.GetWindow(typeof(PerkEditorWindow), false, "PerkEditor"); window.minSize = new Vector2(420, 300); TDE.Init(); InitLabel(); //if(prefabID>=0) window.selectID=PerkDB.GetPrefabIDIndex(prefabID); }
Vector2 DrawEffectConfigurator(float startX, float startY, Effect item) { float maxX = startX; startY = TDE.DrawBasicInfo(startX, startY, item); spaceX += 12; TDE.Label(startX, startY += spaceY, width, height, "Stackable:", "Check if the effect can stack if apply on a same unit with repeatably"); item.stackable = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.stackable); TDE.Label(startX, startY += spaceY, width, height, "Duration:", "The long the effect will last (in second)"); item.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.duration); startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Effect Attributes:", "", TDE.headerS); startX += 12; spaceX -= 12; if (GUI.Button(new Rect(startX + spaceX, startY, widthS * 2, height), "Reset")) { item.Reset(); } TDE.Label(startX, startY += spaceY, width, height, "Stun Target:", "Check if the effect effect will stun its target"); item.stun = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.stun); startY += 10; startX -= 12; spaceX -= 12; int type = (int)item.effType; contL = TDE.SetupContL(effTypeLabel, effTypeTooltip); TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Type:", "", TDE.headerS); type = EditorGUI.Popup(new Rect(startX + spaceX + 23, startY, 2 * widthS + 3, height), new GUIContent(""), type, contL); item.effType = (Effect._EffType)type; if (GUI.Button(new Rect(startX + spaceX + 23 + 2 * widthS + 5, startY, widthS * 2 - 12, height), "Reset")) { item.Reset(); } //TDE.Label(startX, startY+=spaceY, width, height, "Multipliers:", "", TDE.headerS); startY = DrawStats(startX, startY += spaceY, item.stats, _EType.Effect); startY += spaceY; GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; cont = new GUIContent("Unit description (for runtime and editor): ", ""); EditorGUI.LabelField(new Rect(startX, startY, 400, height), cont); item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style); return(new Vector2(maxX, startY + 170)); }
private Vector2 DrawUnitConfigurator(float startX, float startY, UnitTower unit) { startY = TDE.DrawBasicInfo(startX, startY, unit); TDE.Label(startX + 12, startY, width, height, "Hide In Inspector:", "Check to hide the tower in Inspector (It won't be showing up in TowerManager)"); unit.hideInInspector = EditorGUI.Toggle(new Rect(startX + spaceX + 12, startY, width, height), unit.hideInInspector); int type = (int)unit.towerType; cont = new GUIContent("Tower Type:", "Type of the tower. Each type of tower serve a different function"); contL = TDE.SetupContL(towerTypeLabel, towerTypeTooltip); EditorGUI.LabelField(new Rect(startX + 12, startY += spaceY, width, height), cont); type = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), type, contL); unit.towerType = (UnitTower._TowerType)type; showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 12, startY, width, 20), "Show Description", showTypeDesp); if (showTypeDesp) { EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), towerTypeTooltip[(int)unit.towerType], MessageType.Info); startY += 45 - height; } cont = new GUIContent("MaxCount In Scene:", "The maximum number of this tower prefab is allowed in any particular scene.\nSet to >0 to take effect"); EditorGUI.LabelField(new Rect(startX + 12, startY += spaceY, width, height), cont); GUI.color = unit.limitInScene > 0 ? Color.white : Color.grey; unit.limitInScene = EditorGUI.IntField(new Rect(startX + spaceX + 12, startY, widthS, height), unit.limitInScene); GUI.color = Color.white; startY = DrawGeneralSetting(startX, startY + 10, unit); if (unit.statsList.Count == 0) { unit.statsList.Add(new Stats()); } startY = DrawTowerStats(startX, startY + spaceY, unit); startY = DrawTowerVisualEffect(startX, startY + spaceY, unit) + spaceY; startY = DrawUnitAnimation(startX, startY, unit) + spaceY; startY += spaceY; GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; cont = new GUIContent("Unit description (for runtime and editor): ", ""); EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont); unit.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style); return(new Vector2(maxX, startY + 170)); }
private int _NewItem(UnitTower tower) { if (TowerDB.GetList().Contains(tower)) { return(selectID); } tower.prefabID = TDE.GenerateNewID(TowerDB.GetPrefabIDList()); TowerDB.GetList().Add(tower); TowerDB.UpdateLabel(); return(TowerDB.GetList().Count - 1); }
private int _NewItem(UnitCreep creep) { if (CreepDB.GetList().Contains(creep)) { return(selectID); } creep.prefabID = TDE.GenerateNewID(CreepDB.GetPrefabIDList()); CreepDB.GetList().Add(creep); CreepDB.UpdateLabel(); return(CreepDB.GetList().Count - 1); }
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 void Init(SpawnManager smInstance = null) { // Get existing open window or if none, make a new one: window = (SpawnEditorWindow)EditorWindow.GetWindow(typeof(SpawnEditorWindow), false, "SpawnEditor"); window.minSize = new Vector2(500, 300); TDE.Init(); InitLabel(); if (smInstance != null) { instance = smInstance; } }
public static void Init(int prefabID = -1) { window = (UnitTowerEditorWindow)EditorWindow.GetWindow(typeof(UnitTowerEditorWindow), false, "TowerEditor"); window.minSize = new Vector2(420, 300); TDE.Init(); InitLabel(); if (prefabID >= 0) { window.selectID = TowerDB.GetPrefabIndex(prefabID); } window.SelectItem(window.selectID); }
//static int spaceX=120; static int spaceY=18; static int width=150; static int widthS=40; static int height=16; public static float DrawBasicInfo(float startX, float startY, TDItem item) { int spaceX = 120; int spaceY = 18; int width = 150; int height = 16; TDE.DrawSprite(new Rect(startX, startY, 60, 60), item.icon); startX += 65; TDE.Label(startX, startY += 5, width, height, "TypeID:", "The item name to be displayed in game"); item.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), item.name); TDE.Label(startX, startY += spaceY, width, height, "Icon:", "The item icon to be displayed in game, must be a sprite"); item.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), item.icon, typeof(Sprite), false); TDE.Label(startX, startY += spaceY, width, height, "PrefabID: " + item.prefabID.ToString()); //TDE.Label(startX+spaceX-65, startY, width, height, item.prefabID.ToString(), ""); return(startY + spaceY); }
public static float DrawBasicInfo(float startX, float startY, Unit unit) { int spaceX = 120; int spaceY = 18; int width = 150; int height = 16; TDE.DrawSprite(new Rect(startX, startY, 60, 60), unit.icon); startX += 65; TDE.Label(startX, startY += 5, width, height, "TypeID:", "The item name to be displayed in game"); unit.unitName = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), unit.unitName); TDE.Label(startX, startY += spaceY, width, height, "Icon:", "The item icon to be displayed in game, must be a sprite"); unit.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.icon, typeof(Sprite), false); TDE.Label(startX, startY += spaceY, width, height, "Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab"); EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.gameObject, typeof(GameObject), false); return(startY + spaceY * 2); }
public float DrawGenAttribute(float startX, float startY, GenAttribute att, string label = "", string tooltip = "", Sprite icon = null, float limit = -1) { float cachedY = startY; spaceX -= 30; //GUI.Box(new Rect(startX, startY, genAttBlockWidth, genAttBlockHeight), ""); if (icon != null) { TDE.DrawSprite(new Rect(startX + 12, startY, height, height), icon); } if (label != "") { TDE.Label(startX + 12 + (icon != null ? height + 3 : 0), startY, width, height, label, tooltip, TDE.headerS); } TDE.Label(startX, startY += spaceY, width, height, " - Start Value:", "The starting value at wave 1 (StartValue)+wave*IncRate"); att.startValue = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.startValue); TDE.Label(startX, startY += spaceY, width, height, " - Inc Rate:", "How much the value increase over each wave"); att.incrementRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.incrementRate); TDE.Label(startX, startY += spaceY, width, height, " - Deviation:", "Randomization range for multiplier of the final value (0.2 means +/-20%, .5 means +/-50% and so on"); att.deviation = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.deviation); TDE.Label(startX, startY += spaceY, width, height, " - Limit (Min):", "The minimum value of the attribute"); GUI.color = att.limitMin > 0 ? white : grey; att.limitMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.limitMin); GUI.color = white; TDE.Label(startX, startY += spaceY, width, height, " - Limit (Max):", "The maximum value of the attribute"); GUI.color = att.limitMax > 0 ? white : grey; att.limitMax = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.limitMax); GUI.color = white; if (limit > -1) { att.limitMin = Mathf.Max(att.limitMin, limit); } genAttBlockWidth = spaceX + widthS; genAttBlockHeight = startY - cachedY; spaceX += 30; return(startY += spaceY); }
protected float DrawGeneralSetting(float startX, float startY, UnitTower unit) { string textF = "General Tower Setting "; //+(!foldBasicSetting ? "(show)" : "(hide)"); foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS); if (!foldBasicSetting) { return(startY); } startX += 12; //TDE.Label(startX, startY+=spaceY, width, height, "Turret:", ""); //unit.isTurret=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isTurret); //TDE.Label(startX, startY+=spaceY, width, height, "AOE:", ""); //unit.isAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isAOE); //TDE.Label(startX, startY+=spaceY, width, height, "Support:", ""); //unit.isSupport=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSupport); //TDE.Label(startX, startY+=spaceY, width, height, "Resource:", ""); //unit.isResource=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isResource); //TDE.Label(startX, startY+=spaceY, width, height, "Mine:", ""); //unit.isMine=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isMine); ////TDE.Label(startX, startY+=spaceY, width, height, "Turret:", ""); ////unit.isSpawner=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSpawner); //startY+=10; if (unit.IsTurret() || unit.IsAOE() || unit.IsMine()) { int tgtGroup = (int)unit.targetGroup; cont = new GUIContent("Target Group:", "The target group of the tower"); contL = TDE.SetupContL(targetGroupLabel, targetGroupTooltip); EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); tgtGroup = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), tgtGroup, contL); unit.targetGroup = (UnitTower._TargetGroup)tgtGroup; } startY = DrawUnitSetting(startX - 12, startY, unit); return(startY); }
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); }
private int _NewItem(int idx = -1) { Effect item = null; if (idx < 0) { item = new Effect(); item.Reset(); } if (idx >= 0) { item = EffectDB.GetList()[idx].Clone(); } item.prefabID = TDE.GenerateNewID(EffectDB.GetPrefabIDList()); EffectDB.GetList().Add(item); EffectDB.UpdateLabel(); return(EffectDB.GetList().Count - 1); }
private int _NewItem(int idx = -1) { Perk item = null; if (idx < 0) { item = new Perk(); item.effect.Reset(); } if (idx >= 0) { item = PerkDB.GetList()[idx].Clone(); } item.prefabID = TDE.GenerateNewID(PerkDB.GetPrefabIDList()); PerkDB.GetList().Add(item); PerkDB.UpdateLabel(); return(PerkDB.GetList().Count - 1); }
Vector2 DrawPerkConfigurator(float startX, float startY, Perk item) { float maxX = startX; startY = TDE.DrawBasicInfo(startX, startY, item); int type = (int)item.type; contL = TDE.SetupContL(perkTypeLabel, perkTypeTooltip); TDE.Label(startX, startY += spaceY + 5, width, height, "Perk Type:", "Specify what the perk do"); type = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL); item.type = (_PerkType)type; showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 2, startY, width, 20), "Show Description", showTypeDesp); if (showTypeDesp) { EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), perkTypeTooltip[(int)item.type], MessageType.Info); startY += 45 - height; } startY += 10; startY = DrawBasicSetting(startX, startY, item) + 10; startY = DrawEffectSetting(startX, startY, item); startY += spaceY; GUIStyle style = new GUIStyle("TextArea"); style.wordWrap = true; cont = new GUIContent("Perk description (for runtime and editor): ", ""); EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont); item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style); return(new Vector2(maxX, startY + 170)); }
protected float DrawVisualSetting(float startX, float startY, Ability item) { string textF = "Visual and Audio Setting "; //+(!foldVisual ? "(show)" : "(hide)"); foldVisual = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldVisual, textF, TDE.foldoutS); if (!foldVisual) { return(startY); } startX += 12; startY = DrawVisualObject(startX, startY += spaceY, item.effectOnActivate, "On Activate Effect:", "OPTIONAL: The effect object to spawn when the ability is activated\nYou can also add custom script on this object to have your own custom ability effect"); startY = DrawVisualObject(startX, startY += spaceY, item.effectOnTarget, "On Target Effect:", "OPTIONAL: The effect object to spawn when on each individual target of the ability\nYou can also add custom script on this object to have your own custom ability effect"); startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Sound On Activate:", "OPTIONAL - The audio clip to play when the ability is activated"); item.soundOnActivate = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.soundOnActivate, typeof(AudioClip), true); return(startY); }
protected float DrawTowerVisualEffect(float startX, float startY, UnitTower tower) { string textF = "Visual and Audio Setting "; //+(!foldVisual ? "(show)" : "(hide)"); foldVisual = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldVisual, textF, TDE.foldoutS); if (!foldVisual) { return(startY); } startX += 12; startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectBuilding, "Building Effect", "OPTIONAL: The effect object to spawn when the tower is entering building/upgrading/selling state"); startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectBuilt, "Built Effect", "OPTIONAL: The effect object to spawn when the tower has complete a building/upgrading process"); startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectBuilt, "Sold Effect", "OPTIONAL: The effect object to spawn when the tower has been sold"); startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectDestroyed, "Destroyed Effect", "OPTIONAL: The effect object to spawn when the tower has been sold"); startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Sound-Building:", "OPTIONAL - The audio clip to play when the tower starts building"); tower.soundBuilding = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundBuilding, typeof(AudioClip), true); TDE.Label(startX, startY += spaceY, width, height, "Sound-Built:", "OPTIONAL - The audio clip to play when the tower finishes building"); tower.soundBuilt = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundBuilt, typeof(AudioClip), true); TDE.Label(startX, startY += spaceY, width, height, "Sound-Upgrading:", "OPTIONAL - The audio clip to play when the tower starts upgrading"); tower.soundUpgrading = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundUpgrading, typeof(AudioClip), true); TDE.Label(startX, startY += spaceY, width, height, "Sound-Upgraded:", "OPTIONAL - The audio clip to play when the tower finishes upgraded"); tower.soundUpgraded = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundUpgraded, typeof(AudioClip), true); TDE.Label(startX, startY += spaceY, width, height, "Sound-Sold:", "OPTIONAL - The audio clip to play when the tower is sold"); tower.soundSold = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundSold, typeof(AudioClip), true); TDE.Label(startX, startY += spaceY, width, height, "Sound-Destroyed:", "OPTIONAL - The audio clip to play when the tower is destroyed"); tower.soundDestroyed = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundDestroyed, typeof(AudioClip), true); return(startY); }
public override void OnInspectorGUI() { TDE.InitGUIStyle(); }
public virtual void Awake() { TDE.Init(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (instance == null) { Awake(); return; } GUI.changed = false; Undo.RecordObject(instance, "SpawnManager"); EditorGUILayout.Space(); cont = new GUIContent("Endless Mode:", "Check to enable endless mode"); instance.endlessMode = EditorGUILayout.Toggle(cont, instance.endlessMode); cont = new GUIContent("Generate On Start:", "Check to have the waves regenerated at the start of game. All preset setting will be overwritten."); if (instance.endlessMode) { EditorGUILayout.LabelField("Generate On Start:", "-"); } else { instance.genWaveOnStart = EditorGUILayout.Toggle(cont, instance.genWaveOnStart); } int spawnCDType = (int)instance.spawnCDType; cont = new GUIContent("Spawn CD Type:", "Spawn CD Type used in this level"); contL = TDE.SetupContL(spawnCDTypeLabel, spawnCDTypeTooltip); spawnCDType = EditorGUILayout.Popup(cont, spawnCDType, contL); instance.spawnCDType = (SpawnManager._SpawnCDType)spawnCDType; cont = new GUIContent("Skippable:", "Allow player to skip ahead and spawn the next wave"); if (instance.spawnCDType == SpawnManager._SpawnCDType.None) { EditorGUILayout.LabelField("Skippable:", "-"); } else { instance.skippable = EditorGUILayout.Toggle(cont, instance.skippable); } cont = new GUIContent("Auto Start:", "Check to start the game on a timer instead of waiting for player initiation"); instance.autoStart = EditorGUILayout.Toggle(cont, instance.autoStart); cont = new GUIContent(" - Start Timer:", "Delay in second before the spawn start automatically"); if (!instance.autoStart) { EditorGUILayout.LabelField(" - Start Timer:", "-"); } else { instance.startTimer = EditorGUILayout.FloatField(cont, instance.startTimer); } EditorGUILayout.Space(); EditorGUILayout.HelpBox("Editing wave Information using Inspector is not recommended.\nPlease use SpawnEditorWindow instead", MessageType.Info); if (GUILayout.Button("Open SpawnEditorWindow")) { SpawnEditorWindow.Init(); } EditorGUILayout.Space(); DefaultInspector(); if (GUI.changed) { EditorUtility.SetDirty(instance); } }
public void OnGUI() { TDE.InitGUIStyle(); if (!CheckIsPlaying()) { return; } if (window == null) { Init(); } List <UnitTower> towerList = TowerDB.GetList(); Undo.RecordObject(this, "window"); Undo.RecordObject(TowerDB.GetDB(), "towerDB"); if (towerList.Count > 0) { Undo.RecordObject(towerList[selectID], "tower"); } if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save")) { TDE.SetDirty(); } UnitTower newTower = null; TDE.Label(5, 7, 150, 17, "Add New Tower:", "Drag tower prefab to this slot to add it to the list"); newTower = (UnitTower)EditorGUI.ObjectField(new Rect(115, 7, 150, 17), newTower, typeof(UnitTower), false); if (newTower != null) { Select(NewItem(newTower)); } 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 = DrawTowerList(startX, startY, towerList); startX = v2.x + 25; if (towerList.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 = DrawUnitConfigurator(startX, startY, towerList[selectID]); contentWidth = v2.x - startX; contentHeight = v2.y - 55; GUI.EndScrollView(); if (GUI.changed) { TDE.SetDirty(); } }
public void OnGUI() { TDE.InitGUIStyle(); //if(!CheckIsPlaying()) return; if (window == null) { Init(); } if (instance == null && !GetSpawnManager()) { return; } Undo.RecordObject(this, "window"); Undo.RecordObject(instance, "SpawnManager"); //if(GUI.Button(new Rect(window.position.width-130, 5, 125, 25), "Save")) TDE.SetDirty(); if (GUI.Button(new Rect(window.position.width - 130, 5, 125, 25), "Creep Editor")) { UnitCreepEditorWindow.Init(); } //if(GUI.Button(new Rect(window.position.width-130, 35, 125, 25), "Generate")) instance.GenerateWave(); if (!instance.endlessMode && !instance.genWaveOnStart) { string text = configureGenerator ? "Wave List" : "Configure"; if (GUI.Button(new Rect(window.position.width - 130, 35, 125, 25), text)) { configureGenerator = !configureGenerator; } } else { configureGenerator = false; } float startX = 5; float startY = 5; width = 150; startY = DrawGeneralSetting(startX, startY) + 5; Rect visibleRect = new Rect(startX, startY, window.position.width - startX * 2, window.position.height - (startY + 5)); Rect contentRect = new Rect(startX, startY, contentWidth - 20, contentHeight); GUI.color = new Color(.85f, .85f, .85f, 1f); GUI.Box(visibleRect, ""); GUI.color = white; scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect); if (!instance.endlessMode && !instance.genWaveOnStart && !configureGenerator) { startY = DrawWaveList(startX, startY + 5); contentWidth = (subWaveBlockWidth + 10) * maxSubWaveSize + 20; } else { startY = DrawGeneratorParameter(startX, startY + 5); contentWidth = (RscDB.GetCount() + 5) * (genAttBlockWidth + 10) + 75; } contentHeight = startY - visibleRect.y - spaceY * 2; GUI.EndScrollView(); if (GUI.changed) { EditorUtility.SetDirty(instance); } if (GUI.changed) { TDE.SetDirty(); } }
protected float DrawTowerStats(float startX, float startY, UnitTower unit) { string textF = "Tower Stats And Upgrade"; //+(!foldStats ? "(show)" : "(hide)"); foldStats = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldStats, textF, TDE.foldoutS); if (!foldStats) { return(startY); } startX += 15; TDE.Label(startX, startY += spaceY, width, height, "Next Upgrade:", "The tower prefab this tower can be upgraded to"); for (int i = 0; i < unit.upgradeTowerList.Count; i++) { if (unit.upgradeTowerList[i] == null) { unit.upgradeTowerList.RemoveAt(i); i -= 1; continue; } TDE.Label(startX + spaceX - 20, startY, width, height, " - ", ""); int idx = TowerDB.GetPrefabIndex(unit.upgradeTowerList[i]); idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, TowerDB.label); if (TowerDB.GetItem(idx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(idx))) { unit.upgradeTowerList[i] = TowerDB.GetItem(idx); } if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, height, height), "-")) { unit.upgradeTowerList.RemoveAt(i); i -= 1; continue; } startY += spaceY; } int newIdx = -1; if (unit.upgradeTowerList.Count > 0) { TDE.Label(startX + spaceX - 65, startY, width, height, " Add New:", ""); } newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label); if (newIdx >= 0 && TowerDB.GetItem(newIdx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(newIdx))) { Debug.Log("new index " + newIdx + " " + TowerDB.GetItem(newIdx)); unit.upgradeTowerList.Add(TowerDB.GetItem(newIdx)); } startY += 10; //~ if(GUI.Button(new Rect(startX+spaceX+15, startY, width, height), "Add Level")) { if (GUI.Button(new Rect(startX, startY + spaceY, width, height), "Add Level")) { unit.statsList.Add(new Stats()); unit.statsList[unit.statsList.Count - 1].ResetAsBaseStat(); foldStats = true; } startY += spaceY; blockWidth = spaceX + 2 * widthS + 26; float cachedX = startX; float cachedY = (startY += spaceY); for (int i = 0; i < unit.statsList.Count; i++) { GUI.Box(new Rect(startX, cachedY, blockWidth, blockHeight), ""); EditorGUI.LabelField(new Rect(startX + 6, startY += 3, width, height), "Level " + (i + 1), TDE.headerS); GUI.color = new Color(1f, .25f, .25f, 1f); if (GUI.Button(new Rect(startX + blockWidth - 1.5f * widthS - 3, startY, widthS * 1.5f, 14), "remove")) { if (unit.statsList.Count > 1) { unit.statsList.RemoveAt(i); i -= 1; } } GUI.color = Color.white; _EType tType = _EType.TAOE; if (unit.IsTurret()) { tType = _EType.TTurret; } else if (unit.IsSupport()) { tType = _EType.TSupport; } else if (unit.IsResource()) { tType = _EType.TRsc; } else if (unit.IsMine()) { tType = _EType.TMine; } else if (unit.IsBlock()) { tType = _EType.TBlock; } blockHeight = DrawStats(startX, startY + spaceY + 3, unit.statsList[i], tType, true) - cachedY + 5; startY = cachedY; startX += blockWidth + 10; maxX = startX; } startY += blockHeight; startX = cachedX - 15; return(startY); }