Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
            }
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
        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));
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 protected static void UpdateLabel_Creep()
 {
     TDEditor.UpdateLabel_Creep();
 }
        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);
            }
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
 protected static void UpdateLabel_Ability()
 {
     TDEditor.UpdateLabel_Ability();
 }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
        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));
        }
Ejemplo n.º 15
0
 protected static void UpdateLabel_FPSWeapon()
 {
     TDEditor.UpdateLabel_FPSWeapon();
 }
Ejemplo n.º 16
0
        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);
            }
        }
Ejemplo n.º 17
0
        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);
            }
        }
Ejemplo n.º 18
0
 protected static void LoadRsc()
 {
     TDEditor.LoadRsc();
 }
Ejemplo n.º 19
0
 protected static void UpdateLabel_Perk()
 {
     TDEditor.UpdateLabel_Perk();
 }
Ejemplo n.º 20
0
 protected static void LoadPerk()
 {
     TDEditor.LoadPerk();
 }
Ejemplo n.º 21
0
        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);
        }
Ejemplo n.º 22
0
 protected static void UpdateLabel_Tower()
 {
     TDEditor.UpdateLabel_Tower();
 }
Ejemplo n.º 23
0
 protected static void LoadCreep()
 {
     TDEditor.LoadCreep();
 }
Ejemplo n.º 24
0
 protected static void LoadFPSWeapon()
 {
     TDEditor.LoadFPSWeapon();
 }
Ejemplo n.º 25
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake();
            }

            GUI.changed = false;

            EditorGUILayout.Space();



            PrefabType type = PrefabUtility.GetPrefabType(instance);

            if (type == PrefabType.Prefab || type == PrefabType.PrefabInstance)
            {
                bool existInDB = false;
                if (type == PrefabType.PrefabInstance)
                {
                    existInDB = TDEditor.ExistInDB((UnitCreep)PrefabUtility.GetPrefabParent(instance));
                }
                else if (type == PrefabType.Prefab)
                {
                    existInDB = TDEditor.ExistInDB(instance);
                }

                if (!existInDB)
                {
                    EditorGUILayout.Space();

                    EditorGUILayout.HelpBox("This prefab hasn't been added to database hence it won't be accessible to the game.", MessageType.Warning);
                    GUI.color = new Color(1f, 0.7f, .2f, 1f);
                    if (GUILayout.Button("Add Prefab to Database"))
                    {
                        UnitCreepEditorWindow.Init();
                        UnitCreepEditorWindow.NewItem(instance);
                        UnitCreepEditorWindow.Init();                                   //call again to select the instance in editor window
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    EditorGUILayout.HelpBox("Editing creep using Inspector is not recommended.\nPlease use the editor window instead", MessageType.Info);
                    if (GUILayout.Button("Creep Editor Window"))
                    {
                        UnitCreepEditorWindow.Init(instance.prefabID);
                    }
                }

                EditorGUILayout.Space();
            }
            else
            {
                string text = "Creep object won't be available to be deployed to game, or accessible in TDTK editor until it's made a prefab and added to TDTK database.";
                text += "\n\nYou can still edit the creep using default inspector. However it's not recommended";
                EditorGUILayout.HelpBox(text, MessageType.Warning);

                EditorGUILayout.Space();
                if (GUILayout.Button("Creep Editor Window"))
                {
                    UnitCreepEditorWindow.Init(instance.prefabID);
                }
            }


            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        protected float DrawUnitOffensiveStats(float startX, float startY, Unit unit, bool isTower = true)
        {
            //EditorGUI.LabelField(new Rect(startX, startY, width, height), "Offensive Setting", headerStyle);
            string text = "Offensive Setting " + (!foldOffensive ? "(show)" : "(hide)");

            foldOffensive = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldOffensive, text, foldoutStyle);
            if (foldOffensive)
            {
                startX += 15;

                int objID;

                UnitTower tower = isTower ? unit.gameObject.GetComponent <UnitTower>() : null;
                UnitCreep creep = !isTower?unit.gameObject.GetComponent <UnitCreep>() : null;

                //add stop to attack for creep
                if (!isTower)
                {
                    cont = new GUIContent("Stop To Attack:", "Check to have the creep stop moving when there's target to attack");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    creep.stopToAttack = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), creep.stopToAttack);
                }

                //add target mode for tower
                if (isTower)
                {
                    int targetMode = (int)tower.targetMode;
                    cont = new GUIContent("Target Mode:", "Determine which type of unit the tower can target");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    contL = new GUIContent[targetModeLabel.Length];
                    for (int i = 0; i < contL.Length; i++)
                    {
                        contL[i] = new GUIContent(targetModeLabel[i], targetModeTooltip[i]);
                    }
                    targetMode       = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), targetMode, contL);
                    tower.targetMode = (_TargetMode)targetMode;
                }

                cont = new GUIContent("Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.damageType, damageTypeLabel);

                startY += 8;

                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 = unit.shootPoints.Count;
                shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), shootPointCount);

                if (shootPointCount != unit.shootPoints.Count)
                {
                    while (unit.shootPoints.Count < shootPointCount)
                    {
                        unit.shootPoints.Add(null);
                    }
                    while (unit.shootPoints.Count > shootPointCount)
                    {
                        unit.shootPoints.RemoveAt(unit.shootPoints.Count - 1);
                    }
                }

                if (shootPointFoldout)
                {
                    for (int i = 0; i < unit.shootPoints.Count; i++)
                    {
                        objID = GetObjectIDFromHList(unit.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);
                        unit.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                    }
                }

                cont = new GUIContent("Shots delay Between ShootPoint:", "Delay in second between shot fired at each shootPoint. When set to zero all shootPoint fire simulteneously");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 60, height), cont);
                if (unit.shootPoints.Count > 1)
                {
                    unit.delayBetweenShootPoint = EditorGUI.FloatField(new Rect(startX + spaceX + 90, startY - 1, widthS, height - 1), unit.delayBetweenShootPoint);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX + 90, startY - 1, widthS, height - 1), new GUIContent("-", ""));
                }

                startY += 8;

                objID = GetObjectIDFromHList(unit.turretObject, objHList);
                cont  = new GUIContent("TurretObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). When left unassigned, no aiming will be done.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.turretObject = (objHList[objID] == null) ? null : objHList[objID].transform;

                objID = GetObjectIDFromHList(unit.barrelObject, objHList);
                cont  = new GUIContent("BarrelObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). This is only required if the unit barrel and turret rotates independently on different axis");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.barrelObject = (objHList[objID] == null) ? null : objHList[objID].transform;

                startY += 8;

                cont = new GUIContent("Aim Rotate In x-axis:", "Check if the unit turret/barrel can rotate in x-axis (elevation)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.rotateTurretAimInXAxis = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, widthS, height), unit.rotateTurretAimInXAxis);

                cont = new GUIContent("Directional Targeting:", "Check if the unit should only target hostile unit from a fixed direction");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.directionalTargeting = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, widthS, height), unit.directionalTargeting);

                cont = new GUIContent("- FOV:", "Field-Of-View of the directional targeting");
                EditorGUI.LabelField(new Rect(startX + spaceX + 60, startY, width, height), cont);
                if (unit.directionalTargeting)
                {
                    unit.dirScanFOV = EditorGUI.FloatField(new Rect(startX + spaceX + 110, startY, widthS, height), unit.dirScanFOV);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX + 110, startY, widthS, height), "-");
                }

                if (isTower)
                {
                    cont = new GUIContent("- Angle:", "The y-axis angle in clock-wise (from transform local space) which the directional targeting will be aim towards\n0: +ve z-axis\n90: +ve x-axis\n180: -ve z-axis\n270: -ve x-axis");
                    EditorGUI.LabelField(new Rect(startX + spaceX + 60, startY += spaceY, width, height), cont);
                    if (unit.directionalTargeting)
                    {
                        unit.dirScanAngle = EditorGUI.FloatField(new Rect(startX + spaceX + 110, startY, widthS, height), unit.dirScanAngle);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX + 110, startY, widthS, height), "-");
                    }
                }

                //add weapon type for tower
                if (isTower)
                {
                    cont = new GUIContent("Disable FPS:", "Check to disable fps mode for this particular tower");
                    GUI.Label(new Rect(startX, startY += spaceY + 5, width, height), cont);
                    tower.disableFPS = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), tower.disableFPS);

                    cont = new GUIContent("FPS Weapon:", "Weapon tied to this tower when using FPS mode");
                    GUI.Label(new Rect(startX, startY += spaceY, width, height), cont);

                    if (!tower.disableFPS)
                    {
                        int weaponID = TDEditor.GetFPSWeaponIndex(tower.FPSWeaponID);
                        weaponID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponID, fpsWeaponLabel);
                        if (weaponID == 0)
                        {
                            tower.FPSWeaponID = -1;
                        }
                        else
                        {
                            tower.FPSWeaponID = fpsWeaponDB.weaponList[weaponID - 1].prefabID;
                        }
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                    }
                }
            }

            return(startY + spaceY);
        }
Ejemplo n.º 28
0
 protected static void LoadAbility()
 {
     TDEditor.LoadAbility();
 }
Ejemplo n.º 29
0
        protected float DrawTowerUpgradeSetting(float startX, float startY, UnitTower tower)
        {
            //EditorGUI.LabelField(new Rect(startX, startY, width, height), "Upgrade Setting", headerStyle);
            string text = "Upgrade Setting " + (!foldUpgrade ? "(show)" : "(hide)");

            foldUpgrade = EditorGUI.Foldout(new Rect(startX, startY, width, height), foldUpgrade, text, foldoutStyle);
            if (foldUpgrade)
            {
                startX += 15;

                int ID = 0;

                cont = new GUIContent("Prev lvl Tower:", "Tower prefab which this current selected tower is upgrade from. If blank then this is the base tower (level 1). ");
                GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
                if (tower.prevLevelTower != null)
                {
                    GUI.Label(new Rect(startX + spaceX, startY, 105, height), tower.prevLevelTower.unitName);
                    if (GUI.Button(new Rect(startX + spaceX + width, startY, 48, 15), "Select"))
                    {
                        SelectItem(TDEditor.GetTowerIndex(tower.prevLevelTower.prefabID));
                    }
                }
                else
                {
                    GUI.Label(new Rect(startX + spaceX, startY, 105, height), "-");
                }

                startY += 5;

                cont = new GUIContent("level within Prefab:", "How many level the prefab can be upgrade before switching to next level tower");
                GUI.Label(new Rect(startX, startY += spaceY, width, height), cont);
                if (GUI.Button(new Rect(startX + spaceX, startY, widthS, 15), "-1"))
                {
                    if (tower.stats.Count > 1)
                    {
                        tower.stats.RemoveAt(tower.stats.Count - 1);
                    }
                }
                if (GUI.Button(new Rect(startX + spaceX + widthS + 5, startY, widthS, 15), "+1"))
                {
                    tower.stats.Add(tower.stats[tower.stats.Count - 1].Clone());
                }

                startY += 5;

                //if(tower.nextLevelTowerList.Count==0) tower.nextLevelTowerList.Add(null);
                while (tower.nextLevelTowerList.Count < 2)
                {
                    tower.nextLevelTowerList.Add(null);
                }
                while (tower.nextLevelTowerList.Count > 2)
                {
                    tower.nextLevelTowerList.RemoveAt(tower.nextLevelTowerList.Count - 1);
                }

                cont = new GUIContent("Next level Tower 1:", "Tower prefab to be used beyond the stats level specified for this prefab");
                GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
                ID = tower.nextLevelTowerList[0] != null?TDEditor.GetTowerIndex(tower.nextLevelTowerList[0].prefabID) : 0;

                ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), ID, towerLabel);
                if (ID > 0 && towerDB.towerList[ID - 1] != tower && !tower.nextLevelTowerList.Contains(towerDB.towerList[ID - 1]))
                {
                    tower.nextLevelTowerList[0] = towerDB.towerList[ID - 1];
                }
                else if (ID == 0)
                {
                    if (tower.nextLevelTowerList[1] != null)
                    {
                        tower.nextLevelTowerList[0] = tower.nextLevelTowerList[1];
                        tower.nextLevelTowerList[1] = null;
                    }
                    else
                    {
                        tower.nextLevelTowerList[0] = null;
                    }
                }

                if (tower.nextLevelTowerList[0] != null)
                {
                    if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, widthS + 10, 15), "Select"))
                    {
                        if (tower.nextLevelTowerList[0] != null)
                        {
                            SelectItem(ID - 1);
                        }
                    }
                }


                cont = new GUIContent("Next level Tower 2:", "Tower prefab to be used beyond the stats level specified for this prefab");
                GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);

                if (tower.nextLevelTowerList[0] != null)
                {
                    ID = tower.nextLevelTowerList[1] != null?TDEditor.GetTowerIndex(tower.nextLevelTowerList[1].prefabID) : 0;

                    ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), ID, towerLabel);
                    if (ID > 0 && towerDB.towerList[ID - 1] != tower && !tower.nextLevelTowerList.Contains(towerDB.towerList[ID - 1]))
                    {
                        tower.nextLevelTowerList[1] = towerDB.towerList[ID - 1];
                    }
                    else if (ID == 0)
                    {
                        tower.nextLevelTowerList[1] = null;
                    }

                    if (tower.nextLevelTowerList[1] != null)
                    {
                        if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, widthS + 10, 15), "Select"))
                        {
                            if (tower.nextLevelTowerList[1] != null)
                            {
                                SelectItem(ID - 1);
                            }
                        }
                    }
                }
                else
                {
                    GUI.Label(new Rect(startX + spaceX, startY, width, height), "-");
                }
            }

            return(startY + spaceY);
        }
Ejemplo n.º 30
0
 protected static void LoadTower()
 {
     TDEditor.LoadTower();
 }