示例#1
0
        private float DrawSubWaveBlock(float startX, float startY, SubWave subWave, int index, int wIdx)
        {
            float spaceX = 60;        float cachedY = startY;           width -= 10;

            subWaveBlockWidth = spaceX + width + 5;
            GUI.Box(new Rect(startX, startY, subWaveBlockWidth, subWaveBlockHeight), "");

            startX += 3; startY += 3;

            //TDE.Label(startX, startY, width, height, "Prefab: ", "");
            //subWave.prefab=(UnitCreep)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), subWave.prefab, typeof(UnitCreep), true);	startY+=spaceY

            //int index=subWave.prefab!=null ? TDEditor.GetCreepIndex(subWave.unitC.prefabID) : 0 ;
            index = CreepDB.GetPrefabIndex(subWave.prefab);
            TDE.Label(startX, startY, width, height, "Prefab:", "The creep prefab to be spawned");
            index          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, CreepDB.label);
            subWave.prefab = CreepDB.GetItem(index);

            if (subWave.prefab == null)
            {
                GUI.Box(new Rect(startX + subWaveBlockWidth - 5 - height * 2, startY + spaceY, height * 2, height * 2), "");
            }
            else
            {
                TDE.DrawSprite(new Rect(startX + subWaveBlockWidth - 7 - height * 2, startY + spaceY, height * 2, height * 2), subWave.prefab.icon);
            }


            TDE.Label(startX, startY += spaceY, width, height, "Delay: ", "The delay (in second) before the subwave start spawning");
            subWave.delay             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.delay);

            TDE.Label(startX, startY += spaceY, width, height, "Count: ", "How many creep will be spawned for the subwave");
            subWave.spawnCount        = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), subWave.spawnCount);

            TDE.Label(startX, startY += spaceY, width, height, "Spacing: ", "The spawn spacing (in second) between each individual creep");
            subWave.spacing           = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.spacing);

            TDE.Label(startX, startY += spaceY, width, height, "Path: ", "OPTIONAL: The path to used for this subwave. If left unassigned, a random path will be used");
            subWave.path              = (Path)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), subWave.path, typeof(Path), true);


            if (showOverrideSetting)
            {
                TDE.Label(startX, startY += spaceY + 5f, width, height, "Override Setting:", "Attribute on the default prefab that will be overriden", TDE.headerS);        spaceX += 10;

                TDE.Label(startX, startY += spaceY, width, height, " - HitPoint: ", "");  GUI.color = subWave.HP > 0 ? GUI.color : grey;
                subWave.HP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.HP);   GUI.color = white;

                TDE.Label(startX, startY += spaceY, width, height, " - Shield: ", "");    GUI.color = subWave.SH >= 0 ? GUI.color : grey;
                subWave.SH = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.SH);   GUI.color = white;

                TDE.Label(startX, startY += spaceY, width, height, " - Speed: ", "");     GUI.color = subWave.speed > 0 ? GUI.color : grey;
                subWave.speed             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.speed);     GUI.color = white;


                TDE.Label(startX, startY += spaceY, width, height, " - Rsc Gain: ", "");

                RscManager.MatchRscList(subWave.rscGain, -1);

                subWave.overrideRscGain = true;
                for (int i = 0; i < subWave.rscGain.Count; i++)
                {
                    if (subWave.rscGain[i] < 0)
                    {
                        subWave.overrideRscGain = false;
                    }
                }

                float cachedX = startX;                 //startY+=spaceY;
                for (int i = 0; i < RscDB.GetCount(); i++)
                {
                    if (i > 0 && i % 3 == 0)
                    {
                        startX = cachedX - widthS - 2; startY += spaceY;
                    }
                    if (i > 0)
                    {
                        startX += widthS + 2;
                    }

                    TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                    GUI.color          = subWave.overrideRscGain ? GUI.color : grey;
                    subWave.rscGain[i] = EditorGUI.IntField(new Rect(startX + spaceX + height, startY, widthS - height, height), subWave.rscGain[i]);
                    GUI.color          = white;

                    if (subWave.rscGain[i] < 0 && subWave.overrideRscGain)
                    {
                        subWave.overrideRscGain = false;
                    }
                }
                startX = cachedX;
            }

            width += 10;
            subWaveBlockHeight = startY - cachedY + spaceY + 2;

            return(startY + spaceY);
        }
示例#2
0
        public float DrawGenItem(float startX, float startY, GenItem item)
        {
            if (item.enabled)
            {
                GUI.Box(new Rect(startX, startY, genItemBlockWidth, genItemBlockHeight), "");
            }
            else
            {
                GUI.color = grey; GUI.Box(new Rect(startX, startY, genItemBlockWidth, 6 + spaceY * 2), "");     GUI.color = white;
            }

            startX += 3; startY += 3;

            float cachedX = startX;   startX += scrollPos.x;

            item.enabled = EditorGUI.Toggle(new Rect(startX, startY, height, height), item.enabled);

            TDE.DrawSprite(new Rect(startX += height, startY, 2 * height, 2 * height), item.prefab.icon);
            TDE.Label(startX += 2 * height + 5, startY, width, height, item.prefab.unitName, "", TDE.headerS);

            if (item.enabled)
            {
                TDE.Label(startX, startY += spaceY, width, height, "Wave (Min/Max):", "The minimum/maximum wave in which the prefab will be spawned");
                item.minWave              = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minWave);
                item.maxWave              = EditorGUI.IntField(new Rect(startX + spaceX + widthS, startY, widthS, height), item.maxWave);

                startX = cachedX;


                startY += spaceY; float cachedY = startY;
                DrawGenAttribute(startX, cachedY, item.attOdds, "Odds:", "How likely the prefab will be used in a subwave in relative to other prefab (odds/sum of all odds)");         startX += genAttBlockWidth + 10;
                DrawGenAttribute(startX, cachedY, item.attInterval, "Interval", "The spawn interval of the unit in second");    startX += genAttBlockWidth + 10;

                startX += 15;

                item.enableHPOverride = EditorGUI.Toggle(new Rect(startX + spaceX - 5, startY, height, height), item.enableHPOverride);
                GUI.color             = item.enableHPOverride ? white : grey;
                DrawGenAttribute(startX, cachedY, item.attHP, "HitPoint", "The hit-point of the unit\nUncheck to disable override");            startX += genAttBlockWidth + 10;    GUI.color = white;

                item.enableSHOverride = EditorGUI.Toggle(new Rect(startX + spaceX - 5, startY, height, height), item.enableSHOverride);
                GUI.color             = item.enableSHOverride ? white : grey;
                DrawGenAttribute(startX, cachedY, item.attSH, "Shield:", "The shield of the unit\nUncheck to disable override");                        startX += genAttBlockWidth + 10;    GUI.color = white;

                item.enableSpeedOverride = EditorGUI.Toggle(new Rect(startX + spaceX - 5, startY, height, height), item.enableSpeedOverride);
                GUI.color = item.enableSpeedOverride ? white : grey;
                DrawGenAttribute(startX, cachedY, item.attSpeed, "Speed:", "The speed of the unit\nUncheck to disable override");               startX += genAttBlockWidth + 10;    GUI.color = white;

                startX += 15;
                for (int i = 0; i < item.attRscGain.Count; i++)
                {
                    GUI.color = item.enableRscOverride ? white : grey;
                    DrawGenAttribute(startX, cachedY, item.attRscGain[i], RscDB.GetName(i), RscDB.GetName(i) + " gain on destroyed\nUncheck to disable override", RscDB.GetIcon(i));
                    if (i < item.attRscGain.Count - 1)
                    {
                        startX += genAttBlockWidth + 10;
                    }
                    GUI.color = white;
                }

                item.enableRscOverride = EditorGUI.Toggle(new Rect(startX + spaceX - 5, startY, height, height), item.enableRscOverride);

                startY += genAttBlockHeight + spaceY;

                genItemBlockWidth  = 3 + startX + genAttBlockWidth;
                genItemBlockHeight = 5 + startY - cachedY + spaceY * 2;

                //~ start
                //~ max
            }
            else
            {
                TDE.Label(startX, startY += spaceY, width, height, " - Disabled", "");
                startY += spaceY;
            }

            return(startY);
        }
示例#3
0
        private float DrawWaveList(float startX, float startY)
        {
            maxSubWaveSize = 1;

            for (int i = 0; i < instance.waveList.Count; i++)
            {
                if (waveFoldList.Count <= i)
                {
                    waveFoldList.Add(true);
                }
                if (waveOFoldList.Count <= i)
                {
                    waveOFoldList.Add(true);
                }

                waveFoldList[i] = EditorGUI.Foldout(new Rect(startX, startY, widthS * 2, 15), waveFoldList[i], "Wave - " + (i + 1), TDE.foldoutS);

                if (removeIdx != i)
                {
                    if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "remove"))
                    {
                        removeIdx = i;
                    }
                    if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "Insert"))
                    {
                        instance.waveList.Insert(i, new Wave());
                    }
                }
                else
                {
                    if (GUI.Button(new Rect(startX + widthS * 2 + 10, startY, widthS * 1.5f, 15), "cancel"))
                    {
                        removeIdx = -1;
                    }
                    GUI.color = new Color(1, .2f, .2f, 1f);
                    if (GUI.Button(new Rect(startX + widthS * 3.5f + 12, startY, widthS * 1.5f, 15), "confirm"))
                    {
                        instance.waveList.RemoveAt(i);
                        removeIdx = -1;   i -= 1; continue;
                    }
                    GUI.color = white;
                }

                Wave wave = instance.waveList[i];

                if (waveFoldList[i])
                {
                    startX += 15;

                    TDE.Label(startX, startY += spaceY, width, 15, "SubWave (" + wave.subWaveList.Count + "):");
                    if (GUI.Button(new Rect(startX + spaceX, startY - 1, widthS, 15), "-1"))
                    {
                        if (wave.subWaveList.Count > 1)
                        {
                            wave.subWaveList.RemoveAt(wave.subWaveList.Count - 1);
                        }
                    }
                    if (GUI.Button(new Rect(startX + spaceX + 50, startY - 1, widthS, 15), "+1"))
                    {
                        wave.subWaveList.Add(new SubWave());
                    }

                    float cachedY = startY + spaceY;
                    for (int n = 0; n < wave.subWaveList.Count; n++)
                    {
                        startY = DrawSubWaveBlock(startX + (n * (subWaveBlockWidth + 10)), cachedY, wave.subWaveList[n], n, i);
                    }

                    startY += 5;

                    TDE.Label(startX, startY, width, height, "Time to Next Wave: ", "Time in second before next wave is spawned");
                    wave.timeToNextWave = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), wave.timeToNextWave);

                    float cachedX = startX;                     //startY+=spaceY;

                    TDE.Label(startX, startY += spaceY, width, height, "Gain On Clear: ", "gain when the wave is cleared", TDE.headerS);
                    TDE.Label(startX         += spaceX, startY, width, height, "Rsc: ", "Resource");          startX += 30;

                    RscManager.MatchRscList(wave.rscGainOnCleared, 0);

                    for (int n = 0; n < RscDB.GetCount(); n++)
                    {
                        TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(n), RscDB.GetName(n));
                        wave.rscGainOnCleared[n] = EditorGUI.FloatField(new Rect(startX + height, startY, widthS - height, height), wave.rscGainOnCleared[n]);
                        startX += widthS + 2;
                    }

                    startX += widthS * .5f;
                    TDE.Label(startX, startY, width, height, "Perk rsc: ", "");
                    TDE.DrawSprite(new Rect(startX += 55, startY, height, height), PerkDB.GetRscIcon());
                    wave.perkRscGainOnCleared       = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.perkRscGainOnCleared);

                    startX += widthS * 1.5f;
                    TDE.Label(startX, startY, width, height, "Ability rsc: ", "");
                    TDE.DrawSprite(new Rect(startX += 65, startY, height, height), AbilityDB.GetRscIcon());
                    wave.abilityRscGainOnCleared    = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), wave.abilityRscGainOnCleared);

                    startX = cachedX;

                    startY += spaceY * 2f;
                    startX -= 15;
                }
                else
                {
                    float cachedX = startX;   startX += 180 + (removeIdx == i ? widthS * 1.5f : 0);

                    for (int n = 0; n < wave.subWaveList.Count; n++)
                    {
                        if (wave.subWaveList[n].prefab == null)
                        {
                            continue;
                        }
                        TDE.DrawSprite(new Rect(startX, startY, height * 1.5f, height * 1.5f), wave.subWaveList[n].prefab.icon);
                        TDE.Label(startX + height * 1.5f + 2, startY, widthS, height, "x" + wave.subWaveList[n].spawnCount);
                        startX += widthS + height * 1.5f;
                    }

                    startX = cachedX;

                    startY += spaceY * 2f;
                }

                maxSubWaveSize = Mathf.Max(waveFoldList[i] ? instance.waveList[i].subWaveList.Count : 1, maxSubWaveSize);
            }

            return(startY + spaceY * 2);
        }
示例#4
0
        protected float DrawGeneralSetting(float startX, float startY, Ability item)
        {
            string textF = "General Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }

            startX += 12;

            TDE.Label(startX, startY += spaceY, width, height, "Cost:", "The cost of AbilityManager resource required for the ability\nUsed when 'Use RscManager For Cost' is disabled in AbilityManager");
            item.cost = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.cost);

            TDE.Label(startX, startY += spaceY, width, height, "Cost (Rsc):", "The cost of RscManager resource required for the ability\nUsed when 'Use RscManager For Cost' is enabled in AbilityManager");
            while (item.stats.cost.Count < RscDB.GetCount())
            {
                item.stats.cost.Add(0);
            }
            while (item.stats.cost.Count > RscDB.GetCount())
            {
                item.stats.cost.RemoveAt(item.stats.cost.Count - 1);
            }

            float cachedX = startX;

            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                if (i > 0 && i % 3 == 0)
                {
                    startX = cachedX; startY += spaceY;
                }
                if (i > 0)
                {
                    startX += widthS + 2;
                }
                TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                item.stats.cost[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.stats.cost[i]);
            }
            startX = cachedX;


            TDE.Label(startX, startY += spaceY, width, height, "Use Limit:", "How many time the ability can be used in a single level");
            if (item.useLimit <= 0)
            {
                GUI.color = Color.grey;
            }
            item.useLimit = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.useLimit);
            GUI.color     = Color.white;

            TDE.Label(startX, startY += spaceY, width, height, "Cooldown:", "The ability cooldown in second");
            item.stats.cooldown       = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.stats.cooldown);


            int targetType = (int)item.targetType;            contL = TDE.SetupContL(targetTypeLabel, targetTypeTooltip);

            TDE.Label(startX, startY += spaceY + 10, width, height, "Target Type:", "The type of unit affected by the ability");
            targetType      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), targetType, contL);
            item.targetType = (Ability._TargetType)targetType;


            TDE.Label(startX, startY   += spaceY, width, height, "Require Target:", "Check if the ability require the player to specify a target/position");
            item.requireTargetSelection = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.requireTargetSelection);

            TDE.Label(startX, startY += spaceY, width, height, " - Unit As Target:", "Check if the ability require the player to select a specific unit as the target");
            if (!item.requireTargetSelection)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
            }
            else
            {
                item.requireUnitAsTarget = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.requireUnitAsTarget);
            }

            TDE.Label(startX, startY += spaceY, width, height, " - Select Indicator:", "OPTIONAL - The object used to indicate the target area during the target select phase\nIf left empty, the default indicator in AbilityManager will be used instead");
            if (!item.requireTargetSelection)
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
            }
            else
            {
                item.tgtSelectIndicator = (Transform)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.tgtSelectIndicator, typeof(Transform), true);
            }


            return(startY);
        }
示例#5
0
        public float DrawGeneratorParameter(float startX, float startY)
        {
            instance.UpdateGeneratorUnitList();

            SpawnGenerator gen = instance.generator;  gen.Init();

            startX += 5;              spaceX += widthS;

            TDE.Label(startX, startY, width, height, "Wave Interval (Min/Max):", "The minimum and maximum value of the interval (in second) between two waves");
            gen.waveIntervalMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), gen.waveIntervalMin);
            gen.waveIntervalMax = EditorGUI.FloatField(new Rect(startX + spaceX + widthS, startY, widthS, height), gen.waveIntervalMax);

            gen.waveIntervalMin = Mathf.Max(0, gen.waveIntervalMin);          gen.waveIntervalMin = Mathf.Max(gen.waveIntervalMin, 0);
            gen.waveIntervalMax = Mathf.Max(0, gen.waveIntervalMax);  gen.waveIntervalMax = Mathf.Max(gen.waveIntervalMax, 0);

            TDE.Label(startX, startY += spaceY, width, height, "Use all path:", "When checked, all available path will be used (provided that there's enough subwave in the wave)");
            gen.useAllPath            = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.useAllPath);

            TDE.Label(startX, startY   += spaceY, width, height, "One SubWave per path:", "When checked, the total subwave count will be limited to number of path available");
            gen.limitSubWaveCountToPath = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.limitSubWaveCountToPath);

            TDE.Label(startX, startY += spaceY, width, height, "Mirror SubWave:", "When checked, all subwave will be similar except they uses different path");
            gen.similarSubWave        = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), gen.similarSubWave);

            spaceX -= widthS;


            float cachedY = startY += spaceY * 2.5f;      float cachedX = startX;

            TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Wave Setting:", "", TDE.headerS);
            DrawGenAttribute(startX, cachedY, gen.attSubWaveCount, "SubWave Count:", "", null, 1);  startX         += genAttBlockWidth + 10;
            DrawGenAttribute(startX, cachedY, gen.attTotalUnitCount, "Total Unit Count:", "", null, 1);     startX += genAttBlockWidth + 10;

            startX += 15;

            TDE.Label(startX + 12, startY - spaceY, width * 2, height, "Gain On Wave Cleared:", "", TDE.headerS);
            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Life Gain:");              startX += genAttBlockWidth + 10;


            //cachedY=startY+spaceY;	cachedX=startX;
            for (int i = 0; i < gen.attRscGainOnCleared.Count; i++)
            {
                DrawGenAttribute(startX, cachedY, gen.attRscGainOnCleared[i], RscDB.GetName(i), "", RscDB.GetIcon(i));
                startX += genAttBlockWidth + 10;
            }
            //startY+=genAttBlockHeight+spaceY; startX=cachedX;

            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Perk Rsc Gain:", "", PerkDB.GetRscIcon());         startX         += genAttBlockWidth + 10;
            DrawGenAttribute(startX, cachedY, gen.attLifeGainOnCleared, "Ability Rsc Gain:", "", AbilityDB.GetRscIcon());           startX += genAttBlockWidth + 10;

            startY += genAttBlockHeight + spaceY * 2;     startX = cachedX;

            for (int i = 0; i < gen.genItemList.Count; i++)
            {
                if (gen.genItemList[i].prefab == null)
                {
                    gen.genItemList.RemoveAt(i);    i -= 1;
                    continue;
                }
                startY = DrawGenItem(startX, startY, gen.genItemList[i]) + 10;
            }

            return(startY + spaceY * 2);
        }
示例#6
0
        protected float DrawGeneralSetting(float startX, float startY, UnitCreep unit)
        {
            string textF = "General Creep Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }

            startX += 12;

            //~ TDE.Label(startX, startY+=spaceY, width, height, "Flying:", "Check to set the creep as flying unit");
            //~ unit.flying=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.flying);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "Turret:", "");
            //~ unit.isTurret=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isTurret);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "AOE:", "");
            //~ unit.isAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isAOE);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "Support:", "");
            //~ unit.isSupport=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSupport);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "Spawner:", "");
            //~ unit.isSpawner=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSpawner);

            //~ startY+=10;

            TDE.Label(startX, startY += spaceY, width, height, "Immuned Effect:", "The list of effects the unit is immune to");
            for (int i = 0; i < unit.effectImmunityList.Count; i++)
            {
                TDE.Label(startX + spaceX - height, startY, width, height, "-");

                int effIdx = EffectDB.GetPrefabIndex(unit.effectImmunityList[i]);
                effIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effIdx, EffectDB.label);
                if (effIdx >= 0)
                {
                    int effID = EffectDB.GetItem(effIdx).prefabID;
                    if (effID >= 0 && !unit.effectImmunityList.Contains(effID))
                    {
                        unit.effectImmunityList[i] = effID;
                    }
                }

                if (effIdx < 0 || GUI.Button(new Rect(startX + spaceX + width + 3, startY, height, height), "-"))
                {
                    unit.effectImmunityList.RemoveAt(i);
                }

                startY += spaceY;
            }

            int newEffID = -1;

            newEffID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newEffID, EffectDB.label);
            if (newEffID >= 0)
            {
                newEffID = EffectDB.GetPrefab(newEffID).prefabID;
            }
            if (newEffID >= 0 && !unit.effectImmunityList.Contains(newEffID))
            {
                unit.effectImmunityList.Add(newEffID);
            }


            startY += 10;


            TDE.Label(startX, startY  += spaceY, width, height, "Life Lost On Dest:", "The amount of life player will lose if the creep reach destination");
            unit.lifeLostOnDestination = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeLostOnDestination);
            unit.lifeLostOnDestination = Mathf.Max(1, unit.lifeLostOnDestination);

            startY += 5;

            TDE.Label(startX, startY += spaceY, width, height, "Gain On Destroyed:", "");

            TDE.Label(startX, startY += spaceY, width, height, " - Life (chance):", "The amount of life player will gain when the creep is destroyed, subject to a chance (takes value from 0-1 with 0.3 being 30%)");
            if (unit.lifeGainedOnDestroyed <= 0)
            {
                GUI.color = grey;
            }
            unit.lifeGainedOnDestroyed = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeGainedOnDestroyed);     GUI.color = white;
            if (unit.lifeGainedOnDestroyedChance <= 0)
            {
                GUI.color = grey;
            }
            unit.lifeGainedOnDestroyedChance = EditorGUI.FloatField(new Rect(startX + spaceX + widthS + 2, startY, widthS, height), unit.lifeGainedOnDestroyedChance);      GUI.color = white;

            //TDE.Label(startX, startY+=spaceY, width, height, " - Expericene:", "Check to set the creep as flying unit");
            //if(unit.expGainOnDestroyed<=0) GUI.color=grey;
            //unit.expGainOnDestroyed=EditorGUI.IntField(new Rect(startX+spaceX, startY, widthS, height), unit.expGainOnDestroyed);	GUI.color=white;

            RscManager.MatchRscList(unit.rscGainOnDestroyed, 0);

            TDE.Label(startX, startY += spaceY, width, height, " - Resource:", "The amount of resource the player will gain when the creep is destroyed");
            float cachedX = startX;   startX += spaceX;

            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                //if(unit.rscGainOnDestroyed[i]==0) GUI.color=grey;

                if (i > 0 && i % 2 == 0)
                {
                    startX = cachedX; startY += spaceY;
                }
                if (i > 0)
                {
                    startX += widthS + 2;
                }
                TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                unit.rscGainOnDestroyed[i] = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), unit.rscGainOnDestroyed[i]);      GUI.color = white;
            }
            startX = cachedX;

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "SpawnOnDestroyed:", "Creep prefab to be spawn when an instance of this unit is destroyed. Note that the HP of the spawned unit is inherit from the destroyed unit. Use HP-multiplier to specifiy how much of the HP should be carried forward");
            int idx = CreepDB.GetPrefabIndex(unit.spawnOnDestroyed);

            idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, CreepDB.label);
            unit.spawnOnDestroyed = CreepDB.GetItem(idx);
            if (unit.spawnOnDestroyed == unit)
            {
                unit.spawnOnDestroyed = null;
            }

            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
            {
                unit.spawnOnDestroyed = null;
            }

            TDE.Label(startX, startY += spaceY, width, height, " - Num to Spawn:", "The amount of SpawnOnDestroyed creep to spawn when this unit is destroyed");
            if (unit.spawnOnDestroyed != null)
            {
                unit.sodCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.sodCount);
            }
            else
            {
                TDE.Label(startX + spaceX, startY, widthS, height, "-");
            }

            bool valid = unit.spawnOnDestroyed != null && unit.sodCount > 0;

            startY = DrawSpawnOverride(startX, startY, unit.sodOverride, valid, foldSodOverride, SetFoldSodOverride);


            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Flying:", "Check to set the creep as flying");
            unit.flying = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.flying);

            startY = DrawUnitSetting(startX - 12, startY, unit);

            return(startY);
        }
示例#7
0
        //private static bool fold=false;
        public static float DrawStats(float startX, float startY, Stats item, _EType type, bool compressWidth = false)
        {
            int spaceX = 120; int spaceY = 18; int width = 150; int widthS = 40; int height = 16;
            int widthL = compressWidth ? 2 + widthS * 2 : width;

            //string text="Stats "+(!fold ? "(show)" : "(hide)");
            //fold=EditorGUI.Foldout(new Rect(startX, startY+=spaceY, width, height), fold, text, foldoutS);
            //if(fold) return startY;

            startX += 12;

            bool start = true;

            if (IsTower(type) || IsPerk(type))                  //cost for ability is drawn separately in AbilityEditor
            {
                TDE.Label(startX, startY, width, height, "Cost (Rsc):", "cost of the item");

                RscManager.MatchRscList(item.cost, IsPerk(type) ? 1 : 0);

                float cachedX = startX;
                for (int i = 0; i < RscDB.GetCount(); i++)
                {
                    if (i > 0 && i % 2 == 0)
                    {
                        startX = cachedX - widthS - 2; startY += spaceY;
                    }
                    if (i > 0)
                    {
                        startX += widthS + 2;
                    }
                    TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                    item.cost[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.cost[i]);
                }
                startX = cachedX;


                if (IsTower(type))
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Sell Value (Rsc):", "sell value of the item");

                    RscManager.MatchRscList(item.sellValue, IsPerk(type) ? 1 : 0);

                    cachedX = startX;
                    for (int i = 0; i < RscDB.GetCount(); i++)
                    {
                        if (i > 0 && i % 2 == 0)
                        {
                            startX = cachedX - widthS - 2; startY += spaceY;
                        }
                        if (i > 0)
                        {
                            startX += widthS + 2;
                        }
                        TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                        item.sellValue[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.sellValue[i]);
                    }
                    startX = cachedX;
                }


                if (!IsPerkA(type))
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Build Duration:", "");
                    item.buildDuration        = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.buildDuration);
                    TDE.Label(startX, startY += spaceY, width, height, "Sell Duration:", "");
                    item.sellDuration         = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.sellDuration);
                }

                start = false;
            }

            if (IsEffect(type))
            {
                if (!start)
                {
                    startY += 5;
                }

                if (!IsPerkE(type))
                {
                    int damageType = (int)item.damageType;
                    TDE.Label(startX, startY, width, height, "Damage Type:", "");
                    damageType      = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthL, height), damageType, TDE.GetDamageLabel());
                    item.damageType = damageType;

                    startY += spaceY;
                }

                TDE.Label(startX, startY, width, height, "HitPoint Rate:", "hit-point generation/degeneration per second");
                item.hpRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.hpRate);

                TDE.Label(startX, startY += spaceY, width, height, "Shield Rate:", "*shield generation/degeneration per second\nDoes not subject to stagger");
                item.shRate = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shRate);

                start = false;
            }


            if (IsTower(type) || IsCreep(type) || IsPerkT(type) || IsEffect(type))
            {
                if (IsTower(type) || IsPerkT(type) || IsEffect(type))
                {
                    startY += spaceY;
                }

                if (!start)
                {
                    startY += 5;
                }

                TDE.Label(startX, startY, width, height, "HitPoint:", "");
                item.hp = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.hp);

                TDE.Label(startX, startY += spaceY, width, height, "Shield:", "");
                item.sh = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.sh);

                bool switchColor = false;
                if (item.sh <= 0 && GUI.color != Color.grey)
                {
                    GUI.color = Color.grey; switchColor = true;
                }
                TDE.Label(startX, startY += spaceY, width, height, " - Regen Rate:", "shield regeneration per second");
                if (item.sh > 0)
                {
                    item.shRegen = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shRegen);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                }
                TDE.Label(startX, startY += spaceY, width, height, " - Stagger Duration:", "shield regeneration will stop for this duration when the unit is hit");
                if (item.sh > 0)
                {
                    item.shStagger = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shStagger);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                }
                if (switchColor)
                {
                    GUI.color = Color.white;
                }

                start = false;
            }


            if (IsTower(type) || IsCreep(type) || IsAbility(type))
            {
                if (!start)
                {
                    startY += 5;
                }

                int armorType = (int)item.armorType;      int damageType = (int)item.damageType;
                if (!IsAbility(type))
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Armor Type:", "");
                    armorType      = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthL, height), armorType, TDE.GetArmorLabel());
                    item.armorType = armorType;
                }

                if (IsAbility(type) || UseDamage(type))
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Damage Type:", "");
                    damageType      = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthL, height), damageType, TDE.GetDamageLabel());
                    item.damageType = damageType;
                }
                else
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Damage Type:", "");
                    TDE.Label(startX + spaceX, startY, widthL, height, "-", "");
                }
            }


            if (IsEffect(type) || IsCreep(type))
            {
                TDE.Label(startX, startY += spaceY + 5, width, height, "Move Speed:", "");
                item.speed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.speed);
            }


            if (IsEffect(type) || IsTower(type) || IsCreep(type) || IsPerkT(type))
            {
                startY += 5;

                TDE.Label(startX, startY += spaceY, width, height, "Dodge Chance:", "How likely will the unit dodge an attack\n" + txtTooltipChance);
                item.dodge = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.dodge);

                TDE.Label(startX, startY += spaceY, width, height, "Critical Reduc.:", "How likely will the unit negate a cirtical attack\n" + txtTooltipChance);
                item.critReduc            = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.critReduc);

                TDE.Label(startX, startY += spaceY, width, height, "Damage Reduc.:", "How much incoming damage will be reduced\n" + txtTooltipChance);
                item.dmgReduc             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.dmgReduc);
            }


            if (IsTower(type))
            {
                string text = "Attack Stats";
                if (type == _EType.TSupport)
                {
                    text = "Support Stats";
                }
                else if (type == _EType.TRsc)
                {
                    text = "Resource Stats";
                }
                else if (type == _EType.TBlock)
                {
                    return(startY + spaceY);
                }

                TDE.Label(startX, startY += spaceY + 5, width, height, text, "", TDE.headerS);
            }
            else if (IsCreep(type))
            {
                string text = "Attack Stats";
                if (type == _EType.CSupport)
                {
                    text = "Support Stats";
                }
                else if (type == _EType.CSpawner)
                {
                    text = "Spawner Stats";
                }
                else if (type == _EType.CDefault)
                {
                    return(startY + spaceY);
                }

                TDE.Label(startX, startY += spaceY + 5, width, height, text, "", TDE.headerS);
            }
            else
            {
                startY += 5;
            }


            if (IsEffect(type) || IsAbility(type) || UseDamage(type) || IsPerk(type))
            {
                TDE.Label(startX, startY += spaceY, width, height, "Damage Min/Max:");
                item.damageMin            = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.damageMin);
                item.damageMax            = EditorGUI.FloatField(new Rect(startX + spaceX + widthS + 2, startY, widthS, height), item.damageMax);
            }


            if (IsEffect(type) || UseCooldown(type) || IsPerk(type))                    //cooldown for ability is drawn separately
            {
                TDE.Label(startX, startY += spaceY, width, height, "Cooldown:", "");
                item.cooldown             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.cooldown);
            }

            if (IsEffect(type) || UseAttackRange(type) || IsPerk(type))
            {
                TDE.Label(startX, startY += spaceY, width, height, "Effective Radius:", "");
                item.attackRange          = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.attackRange);
            }

            if (IsEffect(type) || IsAbility(type) || UseAOERange(type) || IsAbility(type) || IsPerk(type))
            {
                TDE.Label(startX, startY += spaceY, width, height, "AOE Radius:", "");
                item.aoeRange             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.aoeRange);
            }


            if (IsEffect(type) || UseHitNCrit(type) || IsAbility(type) || IsPerk(type))
            {
                startY += 5;

                TDE.Label(startX, startY += spaceY, width, height, "Hit Chance:", "How likely will an attack will hit\n" + txtTooltipChance);
                item.hit = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.hit);

                TDE.Label(startX, startY += spaceY, width, height, "Critical Chance:", "How likely will an attack will score critical hit, applying critical multiplier to the damage cause\n" + txtTooltipChance);
                item.critChance           = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.critChance);
                TDE.Label(startX, startY += spaceY, width, height, "Critical Multiplier:", "The multiplier apply to the damage when an attack crits");
                item.critMultiplier       = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.critMultiplier);
            }


            if (IsEffect(type) || UseRscGain(type) || IsPerk(type))
            {
                TDE.Label(startX, startY += spaceY, width, height, "Resource Gain:", "");

                RscManager.MatchRscList(item.rscGain, (IsEffect(type) || IsPerk(type) ? 1 : 0));

                float cachedX = startX;
                for (int i = 0; i < RscDB.GetCount(); i++)
                {
                    if (i > 0 && i % 2 == 0)
                    {
                        startX = cachedX; startY += spaceY;
                    }
                    if (i > 0)
                    {
                        startX += widthS + 2;
                    }
                    TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                    item.rscGain[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.rscGain[i]);
                }
                startX = cachedX;
            }


            bool useEffOnHit = false;

            if (!IsEffect(type) && (UseOnHitEffect(type) || IsAbility(type) || IsPerkA(type) || IsPerkT(type)))
            {
                startY += 5;

                bool removeEff = false;

                TDE.Label(startX, startY += spaceY, width, height, "Effect On Hit:", "Offense/AOE Unit/Ability: The effect applies to target when an attack hit\nSupport Unit: The effect applies to friendly target");
                int effIdx = EffectDB.GetPrefabIndex(item.effectOnHitID);

                if (compressWidth)
                {
                    effIdx = EditorGUI.Popup(new Rect(startX + spaceX - widthS * 0.5f + 3, startY, widthS * 2.5f, height), effIdx, EffectDB.label);
                    if (GUI.Button(new Rect(startX + spaceX - widthS + 5, startY, height, height), "-"))
                    {
                        item.effectOnHitID = -1; removeEff = true;
                    }
                }
                else
                {
                    effIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effIdx, EffectDB.label);
                    if (GUI.Button(new Rect(startX + spaceX + width + 3, startY, height, height), "-"))
                    {
                        item.effectOnHitID = -1; removeEff = true;
                    }
                }

                if (effIdx >= 0 && !removeEff)
                {
                    item.effectOnHitID = EffectDB.GetItem(effIdx).prefabID;
                }

                useEffOnHit = true;
            }

            if (UseOnHitEffectChance(type))
            {
                if (!useEffOnHit)
                {
                    startY += 5;
                }
                TDE.Label(startX, startY += spaceY, width, height, "Effect Hit Chance:", "How likely will an attack will hit\n" + txtTooltipChance);
                if (useEffOnHit && item.effectOnHitID < 0 && !(IsPerkA(type) || IsPerkT(type)))
                {
                    GUI.color = Color.grey;
                }
                item.effectOnHitChance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.effectOnHitChance);   GUI.color = Color.white;
            }

            return(startY + spaceY);
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            Undo.RecordObject(instance, "GameControl");

            EditorGUILayout.Space();

            cont             = new GUIContent("Cap player Life:", "Check to cap player life. Player will always start with full life when life is capped");
            instance.capLife = EditorGUILayout.Toggle(cont, instance.capLife);

            cont          = new GUIContent("Player's Life:", "Player Life. When reach 0, game is over");
            instance.life = EditorGUILayout.IntField(cont, instance.life);

            cont = new GUIContent("Player's Life Cap:", "Player Life Capacity. When enabled, player life will never exceed this value");
            if (instance.capLife)
            {
                instance.lifeCap = EditorGUILayout.IntField(cont, instance.lifeCap);
                if (!Application.isPlaying)
                {
                    instance.life = instance.lifeCap;
                }
            }
            else
            {
                EditorGUILayout.LabelField("Player's Life Cap:", "-");
            }

            EditorGUILayout.Space();

            cont = new GUIContent("Regenerate Life:", "Check to enable regeneration of player life.");
            instance.regenLife = EditorGUILayout.Toggle(cont, instance.regenLife);

            cont = new GUIContent("Life Regen Rate:", "The rate at which player life regenerate (in second)");
            if (instance.capLife)
            {
                instance.lifeRegen = EditorGUILayout.FloatField(cont, instance.lifeRegen);
            }
            else
            {
                EditorGUILayout.LabelField("Player's Life Cap:", "-");
            }

            EditorGUILayout.Space();

            //		public List<float> rscGainOnWin=new List<float>();

            RscManager.MatchRscList(instance.rscGainOnWin, 0);

            cont = new GUIContent("Rsc Gain On Win:", "The amount of resource the player will gain when the level is beaten\nUseful for 'Carry Over' option in PerkManager is checked");
            EditorGUILayout.LabelField(cont);
            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                GUILayout.BeginHorizontal();

                //EditorGUILayout.ObjectField(RscDB.GetIcon(i), typeof(Sprite), true, GUILayout.Width(20), GUILayout.Height(20));
                //EditorGUILayout.Box("", GUILayout.Width(20), GUILayout.Height(20));

                EditorGUILayout.LabelField(" - ", GUILayout.Width(40), GUILayout.Height(20));
                Rect rect = GUILayoutUtility.GetLastRect();       rect.x += 20;     rect.width -= 20;
                TDE.DrawSprite(rect, RscDB.GetIcon(i));

                EditorGUIUtility.labelWidth -= 45;

                instance.rscGainOnWin[i]     = EditorGUILayout.FloatField(RscDB.GetName(i), instance.rscGainOnWin[i]);
                EditorGUIUtility.labelWidth += 45;

                GUILayout.EndHorizontal();
            }

            cont = new GUIContent("PerkRscGainOnWin:", "The amount of perk resource the player will gain when the level is beaten\nUseful for 'Carry Over' option in PerkManager is checked");
            instance.perkRscGainOnWin = EditorGUILayout.IntField(cont, instance.perkRscGainOnWin);

            EditorGUILayout.Space();

            cont = new GUIContent("MainMenu Name:", "Scene's name of the main menu to be loaded when return to menu on UI is called");
            instance.mainMenuName = EditorGUILayout.TextField(cont, instance.mainMenuName);
            cont = new GUIContent("NextScene Name:", "Scene's name to be loaded when this level is completed");
            instance.nextLevelName = EditorGUILayout.TextField(cont, instance.nextLevelName);

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
示例#9
0
        protected float DrawEffectSetting(float startX, float startY, Perk item)
        {
            //TDE.Label(startX, startY, spaceX*2, height, "Perk Effect Attribute", "", TDE.headerS);	startY+=spaceY;
            string text = "Perk Effect Attribute ";          //+ (!foldStats ? "(show)" : "(hide)");

            foldStats = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldStats, text, TDE.foldoutS);
            if (!foldStats)
            {
                return(startY + spaceY);
            }

            startY += spaceY; startX += 12;

            if (item.type == _PerkType.NewTower)
            {
                TDE.Label(startX, startY, width, height, "New Tower:", "The new tower to be added to game");
                item.newTowerPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newTowerPID, TowerDB.label);

                TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting tower that will be replaced");
                item.replaceTowerPID      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceTowerPID, TowerDB.label);
            }

            else if (item.type == _PerkType.NewAbility)
            {
                TDE.Label(startX, startY, width, height, "New Ability:", "The new ability to be added to game");
                item.newAbilityPID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.newAbilityPID, AbilityDB.label);

                TDE.Label(startX, startY += spaceY, width, height, " - Replacing:", "OPTIONAL - exiting ability that will be replaced");
                item.replaceAbilityPID    = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), item.replaceAbilityPID, AbilityDB.label);
            }

            else if (item.UseGainValue() || item.UseGainList())
            {
                startY = DrawEffectTypeSetting(startX, startY, item);

                string txtType = item.IsMultiplier() ? "Multiplier:" : "Modifier:";
                if (!item.SupportModNMul())
                {
                    txtType = "Gain:";
                }

                if (item.UseGainValue())
                {
                    string txt = item.UseGainList() ? "Global " : "";

                    TDE.Label(startX, startY, width, height, txt + txtType);                  //"Gain Value:", "");
                    item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain);
                    startY   += spaceY;
                }

                if (item.UseGainList())
                {
                    if (item.gainList.Count < RscDB.GetCount())
                    {
                        item.gainList.Add(0);
                    }
                    if (item.gainList.Count > RscDB.GetCount())
                    {
                        item.gainList.Remove(item.gainList.Count - 1);
                    }

                    for (int i = 0; i < item.gainList.Count; i++)
                    {
                        TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(i));
                        TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i));                   //" - "+txtType, "");
                        item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gainList[i]);
                        if (i < item.gainList.Count - 1)
                        {
                            startY += spaceY;
                        }
                    }
                }
                else
                {
                    startY -= spaceY;
                }
            }

            else if (item.UseStats())
            {
                string textItem = "";
                if (item.type == _PerkType.ModifyTower)
                {
                    textItem = "towers";
                }
                if (item.type == _PerkType.ModifyAbility)
                {
                    textItem = "abilities";
                }
                if (item.type == _PerkType.ModifyEffect)
                {
                    textItem = "effects";
                }

                TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all " + textItem);
                item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll);

                if (!item.applyToAll)
                {
                    startY += spaceY;
                    if (item.type == _PerkType.ModifyTower)
                    {
                        TDE.Label(startX, startY, width, height, "Target Tower:", "The target towers which this perk should be applied to");
                        for (int i = 0; i < item.towerPIDList.Count; i++)
                        {
                            if (item.towerPIDList[i] < 0)
                            {
                                item.towerPIDList.RemoveAt(i); i -= 1; continue;
                            }

                            int index = TowerDB.GetPrefabIndex(item.towerPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, TowerDB.label);
                            int prefabID = TowerDB.GetItem(index).prefabID;
                            if (prefabID != item.prefabID && !item.towerPIDList.Contains(prefabID))
                            {
                                item.towerPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.towerPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label);
                        if (newIdx >= 0 && !item.towerPIDList.Contains(TowerDB.GetItem(newIdx).prefabID))
                        {
                            item.towerPIDList.Add(TowerDB.GetItem(newIdx).prefabID);
                        }
                    }
                    if (item.type == _PerkType.ModifyAbility)
                    {
                        TDE.Label(startX, startY, width, height, "Target Ability:", "The target abilities which this perk should be applied to");
                        for (int i = 0; i < item.abilityPIDList.Count; i++)
                        {
                            int index = AbilityDB.GetPrefabIndex(item.abilityPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, AbilityDB.label);
                            int prefabID = AbilityDB.GetItem(index).prefabID;
                            if (prefabID != item.prefabID && !item.abilityPIDList.Contains(prefabID))
                            {
                                item.abilityPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.abilityPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, AbilityDB.label);
                        if (newIdx >= 0 && !item.abilityPIDList.Contains(AbilityDB.GetItem(newIdx).prefabID))
                        {
                            item.abilityPIDList.Add(AbilityDB.GetItem(newIdx).prefabID);
                        }
                    }
                    if (item.type == _PerkType.ModifyEffect)
                    {
                        TDE.Label(startX, startY, width, height, "Target Effect:", "The target effects which this perk should be applied to");
                        for (int i = 0; i < item.effectPIDList.Count; i++)
                        {
                            int index = EffectDB.GetPrefabIndex(item.effectPIDList[i]);
                            index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, EffectDB.label);
                            int prefabID = EffectDB.GetItem(index).prefabID;

                            if (prefabID != item.prefabID && !item.effectPIDList.Contains(prefabID))
                            {
                                item.effectPIDList[i] = prefabID;
                            }

                            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                            {
                                item.effectPIDList.RemoveAt(i); i -= 1;
                            }

                            startY += spaceY;
                        }

                        int newIdx = -1;
                        newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, EffectDB.label);
                        if (newIdx >= 0 && !item.effectPIDList.Contains(EffectDB.GetItem(newIdx).prefabID))
                        {
                            item.effectPIDList.Add(EffectDB.GetItem(newIdx).prefabID);
                        }
                    }
                }

                startY += spaceY + 10;

                startY = DrawEffectTypeSetting(startX, startY, item) - spaceY;

                startY += spaceY;

                _EType eType = _EType.PerkT;

                if (item.type == _PerkType.ModifyAbility)
                {
                    eType = _EType.PerkA;

                    TDE.Label(startX, startY, width, height, "Use Limit:", "Modify the use limit of the ability");
                    if (item.effType == Perk._EffType.Multiplier)
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }
                    else
                    {
                        item.gain = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.gain);
                    }

                    TDE.Label(startX, startY += spaceY, width, height, "Cost:", "Modify/Multiply the activation cost of the ability");
                    item.costMul              = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.costMul);
                    startY += spaceY;
                }
                else if (item.type == _PerkType.ModifyEffect)
                {
                    eType = _EType.PerkE;

                    TDE.Label(startX, startY, width, height, "Duration:", "Modify the duration of the effect");
                    item.effect.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.effect.duration);

                    TDE.Label(startX, startY += spaceY + 5, width, height, "Stun:", "Check to enable the effec to stun. This will only override the default value if it's set to true");
                    item.effect.stun          = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), item.effect.stun);
                    startY += spaceY;
                }

                startY = DrawStats(startX - 12, startY, item.effect.stats, eType) - spaceY;
            }

            else if (item.IsForPerk())
            {
                TDE.Label(startX, startY, width, height, "Apply To All:", "Check to apply to all perk");
                item.applyToAll = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.applyToAll);

                if (!item.applyToAll)
                {
                    TDE.Label(startX, startY += spaceY, width, height, "Target Perk:", "The target perk which this perk affect should be applied to");
                    for (int i = 0; i < item.perkPIDList.Count; i++)
                    {
                        int index = PerkDB.GetPrefabIndex(item.perkPIDList[i]);
                        index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label);
                        int prefabID = PerkDB.GetItem(index).prefabID;
                        if (prefabID != item.prefabID && !item.perkPIDList.Contains(prefabID))
                        {
                            item.perkPIDList[i] = prefabID;
                        }

                        if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                        {
                            item.perkPIDList.RemoveAt(i); i -= 1;
                        }

                        startY += spaceY;
                    }

                    int newID = -1;
                    newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label);
                    if (newID >= 0 && !item.perkPIDList.Contains(newID))
                    {
                        item.perkPIDList.Add(newID);
                    }
                    startY += spaceY + 10;
                }

                TDE.Label(startX, startY, width, height, "Perk Rsc Multiplier:", "Modify/Multiply the purchase cost of the ability");
                item.costMul = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.costMul);

                if (item.gainList.Count < RscDB.GetCount())
                {
                    item.gainList.Add(0);
                }
                if (item.gainList.Count > RscDB.GetCount())
                {
                    item.gainList.Remove(item.gainList.Count - 1);
                }

                for (int i = 0; i < item.gainList.Count; i++)
                {
                    TDE.DrawSprite(new Rect(startX, startY += spaceY, height, height), RscDB.GetIcon(i));
                    TDE.Label(startX + height, startY, width - height, height, " - " + RscDB.GetName(i) + ":", "");
                    item.gainList[i] = EditorGUI.FloatField(new Rect(startX + spaceX + 25, startY, widthS, height), item.gainList[i]);
                }
            }

            return(startY + spaceY);
        }
示例#10
0
        protected float DrawBasicSetting(float startX, float startY, Perk item)
        {
            //TDE.Label(startX, startY+=spaceY, width, height, "General Setting", "", TDE.headerS);
            string textF = "General Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }

            startX += 12;

            //~ TDE.Label(startX, startY+=spaceY, width, height, "Gained on Wave:", "");	CheckColor(item.autoUnlockOnWave, -1);
            //~ item.autoUnlockOnWave=EditorGUI.IntField(new Rect(startX+spaceX, startY, widthS, height), item.autoUnlockOnWave);	ResetColor();

            //~ startY+=10;

            TDE.Label(startX, startY += spaceY, width, height, "Cost:", "The cost of PerkManager resource required for the perk\nUsed when 'Use RscManager For Cost' is disabled in PerkManager");
            item.cost = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.cost);

            TDE.Label(startX, startY += spaceY, width, height, "Cost (Rsc):", "The cost of RscManager resource required for the perk\nUsed when 'Use RscManager For Cost' is enabled in PerkManager");
            //~ while(item.costRsc.Count<RscDB.GetCount()) item.costRsc.Add(0);
            //~ while(item.costRsc.Count>RscDB.GetCount()) item.costRsc.RemoveAt(item.costRsc.Count-1);

            RscManager.MatchRscList(item.costRsc, 0);

            float cachedX = startX;

            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                if (i > 0 && i % 3 == 0)
                {
                    startX = cachedX; startY += spaceY;
                }
                if (i > 0)
                {
                    startX += widthS + 2;
                }
                TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                item.costRsc[i] = EditorGUI.FloatField(new Rect(startX + spaceX + height, startY, widthS - height, height), item.costRsc[i]);
            }
            startX = cachedX;

            //TDE.Label(startX, startY+=spaceY, width, height, "Repeatabe:", "");
            //item.repeatable=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), item.repeatable);
            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "AutoUnlockOnWave:", "If given a value, the perk will automatically be purchased for the player upon completing the specified wave");  CheckColor(item.autoUnlockOnWave, 0);
            item.autoUnlockOnWave     = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.autoUnlockOnWave);       ResetColor();

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Min Level:", "The minimum level required before the perk becomes available\n\nThis is value of 'Level ID' in GameControl");   CheckColor(item.minLevel, 0);
            item.minLevel             = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minLevel);       ResetColor();

            TDE.Label(startX, startY += spaceY, width, height, "Min Wave:", "The minimum wave required before the perk becomes available");   CheckColor(item.minWave, 0);
            item.minWave              = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minWave); ResetColor();

            TDE.Label(startX, startY += spaceY, width, height, "Min Perk Count:", "The minimum number of perk purchased required before the perk becomes available"); CheckColor(item.minPerkCount, 0);
            item.minPerkCount         = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), item.minPerkCount);       ResetColor();


            TDE.Label(startX, startY += spaceY, width, height, "Prereq Perk:", "Perk(s) required to be purchased before the perk becomes available");
            for (int i = 0; i < item.prereq.Count; i++)
            {
                TDE.Label(startX + spaceX - 20, startY, widthS, height, "-");

                int index = PerkDB.GetPrefabIndex(item.prereq[i]);
                if (index < 0)
                {
                    item.prereq.RemoveAt(i); i -= 1; continue;
                }

                index = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, PerkDB.label);

                int prefabID = PerkDB.GetItem(index).prefabID;
                if (prefabID != item.prefabID && !item.prereq.Contains(prefabID))
                {
                    item.prereq[i] = prefabID;
                }

                if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                {
                    item.prereq.RemoveAt(i); i -= 1;
                }

                startY += spaceY;
            }

            int newID = -1;           CheckColor(item.prereq.Count, 0);

            newID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newID, PerkDB.label);
            if (newID >= 0 && !item.prereq.Contains(newID))
            {
                item.prereq.Add(newID);
            }
            startY += 10;
            ResetColor();

            return(startY);
        }