public static void Init(int prefabID = -1) { // Get existing open window or if none, make a new one: window = (UnitCreepEditorWindow)EditorWindow.GetWindow(typeof(UnitCreepEditorWindow), false, "Creep Editor"); window.minSize = new Vector2(420, 300); LoadDB(); InitLabel(); if (prefabID >= 0) { window.selectID = TDEditor.GetCreepIndex(prefabID) - 1; } window.SetupCallback(); }
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); }
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); }