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); }
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 Vector2 DrawUnitConfigurator(float startX, float startY, UnitCreep unit) { float maxX = startX; startY = TDE.DrawBasicInfo(startX, startY, unit); int type = (int)unit.creepType; cont = new GUIContent("Creep Type:", "Type of the creep. Each type of creep serve a different function"); contL = TDE.SetupContL(creepTypeLabel, creepTypeTooltip); EditorGUI.LabelField(new Rect(startX + 12, startY, width, height), cont); type = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), type, contL); unit.creepType = (UnitCreep._CreepType)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), creepTypeTooltip[(int)unit.creepType], MessageType.Info); startY += 45 - height; } startY = DrawGeneralSetting(startX, startY + spaceY + 10, unit); startY = DrawMovementSetting(startX, startY + spaceY, unit); startY += spaceY * 2; _EType cType = _EType.CDefault; if (unit.IsTurret()) { cType = _EType.CTurret; } else if (unit.IsAOE()) { cType = _EType.CAOE; } else if (unit.IsSupport()) { cType = _EType.CSupport; } else if (unit.IsSpawner()) { cType = _EType.CSpawner; } string text = "Unit Stats "; //+ !foldStats ? "(show)" : "(hide)" ; foldStats = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldStats, text, TDE.foldoutS); if (foldStats) { startY = DrawStats(startX, startY + spaceY, unit.statsList[0], cType) - spaceY; if (unit.IsSpawner()) { startX += 12; startY += 10; TDE.Label(startX, startY += spaceY, width, height, "Spawn Prefab:", "Creep prefab to be spawned"); int idx = CreepDB.GetPrefabIndex(unit.spawnerPrefab); idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, CreepDB.label); unit.spawnerPrefab = CreepDB.GetItem(idx); if (unit.spawnerPrefab == unit) { unit.spawnerPrefab = 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.spawnerPrefab != null) { unit.spawnerCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.spawnerCount); } else { TDE.Label(startX + spaceX, startY, widthS, height, "-"); } bool valid = unit.spawnerPrefab != null && unit.spawnerCount > 0; startY = DrawSpawnOverride(startX, startY, unit.spawnerOverride, valid, foldSpawnerOverride, SetFoldSpawnerOverride); startX -= 12; } } startY = DrawCreepVisualEffect(startX, startY + spaceY, unit); startY = DrawUnitAnimation(startX, startY + spaceY, unit); 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 += spaceY, 400, 20), cont); unit.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style); return(new Vector2(maxX, startY + 170)); }