Esempio n. 1
0
        protected float DrawVisualObject(float startX, float startY, VisualObject vo, string label, string tooltip)
        {
            TDE.Label(startX, startY, width, height, label, tooltip);
            vo.obj = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), vo.obj, typeof(GameObject), true);

            TDE.Label(startX, startY += spaceY, width, height, " - Auto Destroy:", "Check if the spawned effect should be destroyed automatically");
            if (vo.obj != null)
            {
                vo.autoDestroy = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), vo.autoDestroy);
            }
            else
            {
                TDE.Label(startX + spaceX, startY, width, height, "-");
            }

            TDE.Label(startX, startY += spaceY, width, height, " - Effect Duration:", "How long before the spawned effect object is destroyed");
            if (vo.obj != null && vo.autoDestroy)
            {
                vo.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, width, height), vo.duration);
            }
            else
            {
                TDE.Label(startX + spaceX, startY, width, height, "-");
            }

            return(startY);
        }
Esempio n. 2
0
        protected float DrawCreepVisualEffect(float startX, float startY, UnitCreep creep)
        {
            string textF = "Visual Setting ";          //+(!foldVisual ? "(show)" : "(hide)");

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

            startX += 12;

            startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectSpawn, "Spawn Effect", "OPTIONAL: The effect object to spawn when the creep is spawned");
            startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectDestroyed, "Destroyed Effect", "OPTIONAL: The effect object to spawn when the creep is destroyed");
            startY = 5 + DrawVisualObject(startX, startY += spaceY, creep.effectDestination, "Destination Effect", "OPTIONAL: The effect object to spawn when the creep reach the destination");

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Spawn:", "OPTIONAL - The audio clip to play when the unit is spawned");
            creep.soundSpawn          = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundSpawn, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound -Destination:", "OPTIONAL - The audio clip to play when the unit reaches destination");
            creep.soundDestination    = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundDestination, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Destroyed:", "OPTIONAL - The audio clip to play when the unit is destroyed");
            creep.soundDestroyed      = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), creep.soundDestroyed, typeof(AudioClip), true);

            return(startY);
        }
Esempio n. 3
0
        Vector2 DrawAbilityConfigurator(float startX, float startY, Ability item)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, item);

            TDE.Label(startX, startY += spaceY, width, height, "Hide In Inspector:", "");
            item.hideInInspector      = EditorGUI.Toggle(new Rect(startX + width, startY, width, height), item.hideInInspector);

            startY = DrawGeneralSetting(startX, startY + 10, item);

            startY += spaceY * 2;


            string text = "Ability Stats ";          //+(!foldStats ? "(show)" : "(hide)");

            foldStats = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldStats, text, TDE.foldoutS);
            if (foldStats)
            {
                int effType = (int)item.effectType;
                TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Type:", "Indicate what does the ability do");
                contL           = TDE.SetupContL(effTypeLabel, effTypeTooltip);
                effType         = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), effType, contL);
                item.effectType = (Ability._EffectType)effType;

                startY += 10;

                if (item.effectType != Ability._EffectType.Default || item.effectDelay <= 0)
                {
                    GUI.color = Color.grey;
                }

                TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Delay:", "Delay in second before the effects apply to target\n\nFor any visual effect to play out");
                item.effectDelay = EditorGUI.FloatField(new Rect(startX + spaceX + 12, startY, widthS, height), item.effectDelay);

                GUI.color = item.effectType == Ability._EffectType.Default ? Color.white : Color.grey;

                startY    = DrawStats(startX, startY, item.stats, _EType.Ability);
                GUI.color = Color.white;
            }
            else
            {
                startY += spaceY;
            }


            startY = DrawVisualSetting(startX, startY, item) + spaceY;


            startY += spaceY;


            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont);
            item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style);

            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 4
0
        //protected float DrawTowerVisualEffect(float startX, float startY, UnitTower tower){

        protected float DrawUnitAnimation(float startX, float startY, Unit item)
        {
            string textF = "Animation Setting ";          //+(!foldVisual ? "(show)" : "(hide)");

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

            startX += 12;

            int objIdx = GetIndexFromHierarchy(item.animatorT, objHierarchyList);

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Animator Object:", "The transform object which contain the Animator component");
            objIdx         = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
            item.animatorT = objHierarchyList[objIdx];

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Clip Idle:", "The animation clip to play when the unit is idle");
            item.clipIdle             = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipIdle, typeof(AnimationClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Clip Hit:", "The animation clip to play when the unit is hit by an attack");
            item.clipHit              = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipHit, typeof(AnimationClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Clip Idle:", "The animation clip to play when the unit is destroyed");
            item.clipDestroyed        = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipDestroyed, typeof(AnimationClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Clip Attack:", "The animation clip to play when the unit attacks");
            item.clipAttack           = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipAttack, typeof(AnimationClip), true);

            TDE.Label(startX, startY += spaceY, width, height, " - delay:", "Unit's active target field-of-view in angle");
            item.animationAttackDelay = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.animationAttackDelay);

            startY += 10;

            if (item.IsCreep())
            {
                TDE.Label(startX, startY += spaceY, width, height, "Clip Move:", "The animation clip to play when the unit is moving");
                item.clipMove             = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipMove, typeof(AnimationClip), true);

                TDE.Label(startX, startY += spaceY, width, height, "Clip Spawn:", "The animation clip to play when the unit is spawned");
                item.clipSpawn            = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipSpawn, typeof(AnimationClip), true);

                TDE.Label(startX, startY += spaceY, width, height, "Clip Destination:", "The animation clip to play when the unit reaches destination");
                item.clipDestination      = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipDestination, typeof(AnimationClip), true);
            }
            if (item.IsTower())
            {
                TDE.Label(startX, startY += spaceY, width, height, "Clip Construct:", "The animation clip to play when the unit is constructing");
                item.clipConstruct        = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipConstruct, typeof(AnimationClip), true);

                TDE.Label(startX, startY += spaceY, width, height, "Clip Deconstruct:", "The animation clip to play when the unit is deconstructing");
                item.clipDeconstruct      = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.clipDeconstruct, typeof(AnimationClip), true);
            }

            return(startY);
        }
Esempio n. 5
0
        public float DrawEffectTypeSetting(float startX, float startY, Perk item)
        {
            if (!item.SupportModNMul())
            {
                return(startY);
            }

            int type = (int)item.effType;             contL = TDE.SetupContL(effTypeLabel, effTypeTooltip);

            TDE.Label(startX, startY, width, height, "Effect Type:", "", TDE.headerS);
            type                = EditorGUI.Popup(new Rect(startX + spaceX, startY, 2 * widthS + 3, height), new GUIContent(""), type, contL);
            item.effType        = (Perk._EffType)type;
            item.effect.effType = (Effect._EffType)type;


            if (GUI.Button(new Rect(startX + spaceX + 2 * widthS + 5, startY, widthS * 2 - 12, height), "Reset"))
            {
                if (item.effType == Perk._EffType.Modifier)
                {
                    item.gain = 0;
                    for (int i = 0; i < item.gainList.Count; i++)
                    {
                        item.gainList[i] = 0;
                    }

                    if (item.type == _PerkType.ModifyAbility)
                    {
                        item.costMul = 0;
                    }
                    if (item.type == _PerkType.ModifyEffect)
                    {
                        item.effect.duration = 0;
                    }
                }
                if (item.effType == Perk._EffType.Multiplier)
                {
                    item.gain = 1;
                    for (int i = 0; i < item.gainList.Count; i++)
                    {
                        item.gainList[i] = 1;
                    }

                    if (item.type == _PerkType.ModifyAbility)
                    {
                        item.costMul = 1;
                    }
                    if (item.type == _PerkType.ModifyEffect)
                    {
                        item.effect.duration = 1;
                    }
                }

                item.effect.Reset();
            }


            return(startY + spaceY);
        }
Esempio n. 6
0
        protected float DrawSpawnOverride(float startX, float startY, UnitCreep.SubUnitOverride ovrr, bool valid, bool fold, foldCallback callback)
        {
            string text = "Show Override Setting ";          //+(!fold ? "(show)" : "(hide)");

            fold = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), fold, text);    callback(fold);
            if (fold)
            {
                startX += 12;     spaceX += 30;     width += 20;

                GUI.color = ovrr.mulHP <= 0 ? grey : white;
                TDE.Label(startX, startY += spaceY, width, height, " - HP Multiplier:", "Set >0 to enable override of the spawned unit HP\n\nThe override value is determined by applying this multiplier value to the parent unit HP");
                if (valid)
                {
                    ovrr.mulHP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulHP);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                } GUI.color = white;

                GUI.color = ovrr.mulSH <= 0 ? grey : white;
                TDE.Label(startX, startY += spaceY, width, height, " - Shield Multiplier:", "Set >0 to enable override of the spawned unit shield\n\nThe override value is determined by applying this multiplier value to the parent unit shield");
                if (valid)
                {
                    ovrr.mulSH = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulSH);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                } GUI.color = white;

                GUI.color = ovrr.mulSpd <= 0 ? grey : white;
                TDE.Label(startX, startY += spaceY, width, height, " - Speed Multiplier:", "Set >0 to enable override of the spawned unit speed\n\nThe override value is determined by applying this multiplier value to the parent unit speed");
                if (valid)
                {
                    ovrr.mulSpd = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulSpd);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                } GUI.color = white;

                GUI.color = ovrr.mulRsc <= 0 ? grey : white;
                TDE.Label(startX, startY += spaceY, width, height, " - Rsc Gain Multiplier:", "Set >0 to enable override of the spawned unit resource gain on destroyed\n\nThe override value is determined by applying this multiplier value to the parent unit resource gain on destroyed");
                if (valid)
                {
                    ovrr.mulRsc = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), ovrr.mulRsc);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                } GUI.color = white;

                startX -= 12;     spaceX -= 30;     width -= 20;
            }
            return(startY);
        }
Esempio n. 7
0
        Vector2 DrawEffectConfigurator(float startX, float startY, Effect item)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, item);

            spaceX += 12;

            TDE.Label(startX, startY += spaceY, width, height, "Stackable:", "Check if the effect can stack if apply on a same unit with repeatably");
            item.stackable            = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.stackable);

            TDE.Label(startX, startY += spaceY, width, height, "Duration:", "The long the effect will last (in second)");
            item.duration             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.duration);

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Effect Attributes:", "", TDE.headerS);        startX += 12;     spaceX -= 12;

            if (GUI.Button(new Rect(startX + spaceX, startY, widthS * 2, height), "Reset"))
            {
                item.Reset();
            }

            TDE.Label(startX, startY += spaceY, width, height, "Stun Target:", "Check if the effect effect will stun its target");
            item.stun = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.stun);

            startY += 10;     startX -= 12;     spaceX -= 12;

            int type = (int)item.effType;             contL = TDE.SetupContL(effTypeLabel, effTypeTooltip);

            TDE.Label(startX + 12, startY += spaceY, width, height, "Effect Type:", "", TDE.headerS);
            type         = EditorGUI.Popup(new Rect(startX + spaceX + 23, startY, 2 * widthS + 3, height), new GUIContent(""), type, contL);
            item.effType = (Effect._EffType)type;

            if (GUI.Button(new Rect(startX + spaceX + 23 + 2 * widthS + 5, startY, widthS * 2 - 12, height), "Reset"))
            {
                item.Reset();
            }

            //TDE.Label(startX, startY+=spaceY, width, height, "Multipliers:", "", TDE.headerS);
            startY = DrawStats(startX, startY += spaceY, item.stats, _EType.Effect);

            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, height), cont);
            item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style);

            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 8
0
        private Vector2 DrawUnitConfigurator(float startX, float startY, UnitTower unit)
        {
            startY = TDE.DrawBasicInfo(startX, startY, unit);

            TDE.Label(startX + 12, startY, width, height, "Hide In Inspector:", "Check to hide the tower in Inspector (It won't be showing up in TowerManager)");
            unit.hideInInspector = EditorGUI.Toggle(new Rect(startX + spaceX + 12, startY, width, height), unit.hideInInspector);

            int type = (int)unit.towerType;

            cont  = new GUIContent("Tower Type:", "Type of the tower. Each type of tower serve a different function");
            contL = TDE.SetupContL(towerTypeLabel, towerTypeTooltip);
            EditorGUI.LabelField(new Rect(startX + 12, startY += spaceY, width, height), cont);
            type           = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), type, contL);
            unit.towerType = (UnitTower._TowerType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 12, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), towerTypeTooltip[(int)unit.towerType], MessageType.Info);
                startY += 45 - height;
            }


            cont = new GUIContent("MaxCount In Scene:", "The maximum number of this tower prefab is allowed in any particular scene.\nSet to >0 to take effect");
            EditorGUI.LabelField(new Rect(startX + 12, startY += spaceY, width, height), cont);
            GUI.color         = unit.limitInScene > 0 ? Color.white : Color.grey;
            unit.limitInScene = EditorGUI.IntField(new Rect(startX + spaceX + 12, startY, widthS, height), unit.limitInScene);    GUI.color = Color.white;


            startY = DrawGeneralSetting(startX, startY + 10, unit);

            if (unit.statsList.Count == 0)
            {
                unit.statsList.Add(new Stats());
            }
            startY = DrawTowerStats(startX, startY + spaceY, unit);

            startY = DrawTowerVisualEffect(startX, startY + spaceY, unit) + spaceY;

            startY = DrawUnitAnimation(startX, startY, unit) + spaceY;

            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont);
            unit.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style);

            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 9
0
        //static int spaceX=120; static int spaceY=18; static int width=150; static int widthS=40; static int height=16;
        public static float DrawBasicInfo(float startX, float startY, TDItem item)
        {
            int spaceX = 120; int spaceY = 18; int width = 150; int height = 16;

            TDE.DrawSprite(new Rect(startX, startY, 60, 60), item.icon);    startX += 65;

            TDE.Label(startX, startY += 5, width, height, "TypeID:", "The item name to be displayed in game");
            item.name = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), item.name);

            TDE.Label(startX, startY += spaceY, width, height, "Icon:", "The item icon to be displayed in game, must be a sprite");
            item.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), item.icon, typeof(Sprite), false);

            TDE.Label(startX, startY += spaceY, width, height, "PrefabID: " + item.prefabID.ToString());
            //TDE.Label(startX+spaceX-65, startY, width, height, item.prefabID.ToString(), "");

            return(startY + spaceY);
        }
Esempio n. 10
0
        public static float DrawBasicInfo(float startX, float startY, Unit unit)
        {
            int spaceX = 120; int spaceY = 18; int width = 150; int height = 16;

            TDE.DrawSprite(new Rect(startX, startY, 60, 60), unit.icon);    startX += 65;

            TDE.Label(startX, startY += 5, width, height, "TypeID:", "The item name to be displayed in game");
            unit.unitName             = EditorGUI.TextField(new Rect(startX + spaceX - 65, startY, width, height), unit.unitName);

            TDE.Label(startX, startY += spaceY, width, height, "Icon:", "The item icon to be displayed in game, must be a sprite");
            unit.icon = (Sprite)EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.icon, typeof(Sprite), false);

            TDE.Label(startX, startY += spaceY, width, height, "Prefab:", "The prefab object of the unit\nClick this to highlight it in the ProjectTab");
            EditorGUI.ObjectField(new Rect(startX + spaceX - 65, startY, width, height), unit.gameObject, typeof(GameObject), false);

            return(startY + spaceY * 2);
        }
Esempio n. 11
0
        public float DrawGenAttribute(float startX, float startY, GenAttribute att, string label = "", string tooltip = "", Sprite icon = null, float limit = -1)
        {
            float cachedY = startY;   spaceX -= 30;

            //GUI.Box(new Rect(startX, startY, genAttBlockWidth, genAttBlockHeight), "");

            if (icon != null)
            {
                TDE.DrawSprite(new Rect(startX + 12, startY, height, height), icon);
            }

            if (label != "")
            {
                TDE.Label(startX + 12 + (icon != null ? height + 3 : 0), startY, width, height, label, tooltip, TDE.headerS);
            }

            TDE.Label(startX, startY += spaceY, width, height, " - Start Value:", "The starting value at wave 1  (StartValue)+wave*IncRate");
            att.startValue            = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.startValue);

            TDE.Label(startX, startY += spaceY, width, height, " - Inc Rate:", "How much the value increase over each wave");
            att.incrementRate         = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.incrementRate);

            TDE.Label(startX, startY += spaceY, width, height, " - Deviation:", "Randomization range for multiplier of the final value (0.2 means +/-20%, .5 means +/-50% and so on");
            att.deviation             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.deviation);

            TDE.Label(startX, startY += spaceY, width, height, " - Limit (Min):", "The minimum value of the attribute");

            GUI.color    = att.limitMin > 0 ? white : grey;
            att.limitMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.limitMin);       GUI.color = white;

            TDE.Label(startX, startY += spaceY, width, height, " - Limit (Max):", "The maximum value of the attribute");
            GUI.color    = att.limitMax > 0 ? white : grey;
            att.limitMax = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), att.limitMax);       GUI.color = white;

            if (limit > -1)
            {
                att.limitMin = Mathf.Max(att.limitMin, limit);
            }

            genAttBlockWidth  = spaceX + widthS;
            genAttBlockHeight = startY - cachedY;
            spaceX           += 30;

            return(startY += spaceY);
        }
Esempio n. 12
0
        protected float DrawVisualSetting(float startX, float startY, Ability item)
        {
            string textF = "Visual and Audio Setting ";          //+(!foldVisual ? "(show)" : "(hide)");

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

            startX += 12;

            startY = DrawVisualObject(startX, startY += spaceY, item.effectOnActivate, "On Activate Effect:", "OPTIONAL: The effect object to spawn when the ability is activated\nYou can also add custom script on this object to have your own custom ability effect");
            startY = DrawVisualObject(startX, startY += spaceY, item.effectOnTarget, "On Target Effect:", "OPTIONAL: The effect object to spawn when on each individual target of the ability\nYou can also add custom script on this object to have your own custom ability effect");

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Sound On Activate:", "OPTIONAL - The audio clip to play when the ability is activated");
            item.soundOnActivate      = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.soundOnActivate, typeof(AudioClip), true);

            return(startY);
        }
Esempio n. 13
0
        Vector2 DrawPerkConfigurator(float startX, float startY, Perk item)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, item);


            int type = (int)item.type;                contL = TDE.SetupContL(perkTypeLabel, perkTypeTooltip);

            TDE.Label(startX, startY += spaceY + 5, width, height, "Perk Type:", "Specify what the perk do");
            type      = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL);
            item.type = (_PerkType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 2, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), perkTypeTooltip[(int)item.type], MessageType.Info);
                startY += 45 - height;
            }

            startY += 10;


            startY = DrawBasicSetting(startX, startY, item) + 10;


            startY = DrawEffectSetting(startX, startY, item);


            startY += spaceY;

            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Perk description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY, 400, 20), cont);
            item.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), item.desp, style);

            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 14
0
        protected float DrawTowerVisualEffect(float startX, float startY, UnitTower tower)
        {
            string textF = "Visual and Audio Setting ";          //+(!foldVisual ? "(show)" : "(hide)");

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

            startX += 12;

            startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectBuilding, "Building Effect", "OPTIONAL: The effect object to spawn when the tower is entering building/upgrading/selling state");
            startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectBuilt, "Built Effect", "OPTIONAL: The effect object to spawn when the tower has complete a building/upgrading process");
            startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectBuilt, "Sold Effect", "OPTIONAL: The effect object to spawn when the tower has been sold");
            startY = 5 + DrawVisualObject(startX, startY += spaceY, tower.effectDestroyed, "Destroyed Effect", "OPTIONAL: The effect object to spawn when the tower has been sold");

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Building:", "OPTIONAL - The audio clip to play when the tower starts building");
            tower.soundBuilding       = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundBuilding, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Built:", "OPTIONAL - The audio clip to play when the tower finishes building");
            tower.soundBuilt          = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundBuilt, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Upgrading:", "OPTIONAL - The audio clip to play when the tower starts upgrading");
            tower.soundUpgrading      = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundUpgrading, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Upgraded:", "OPTIONAL - The audio clip to play when the tower finishes upgraded");
            tower.soundUpgraded       = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundUpgraded, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Sold:", "OPTIONAL - The audio clip to play when the tower is sold");
            tower.soundSold           = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundSold, typeof(AudioClip), true);

            TDE.Label(startX, startY += spaceY, width, height, "Sound-Destroyed:", "OPTIONAL - The audio clip to play when the tower is destroyed");
            tower.soundDestroyed      = (AudioClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.soundDestroyed, typeof(AudioClip), true);

            return(startY);
        }
Esempio n. 15
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);
        }
Esempio n. 16
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);
        }
Esempio n. 17
0
        private float DrawGeneralSetting(float startX, float startY)
        {
            TDE.Label(startX, startY, width, height, "Endless Mode:", "Check to enable endless mode");
            instance.endlessMode = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), instance.endlessMode);

            TDE.Label(startX, startY += spaceY, width, height, "Generate On Start:", "Check to have the waves regenerated at the start of game. All preset setting will be overwritten.");
            if (instance.endlessMode)
            {
                TDE.Label(startX + spaceX, startY, height, height, "-", "");
            }
            else
            {
                instance.genWaveOnStart = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), instance.genWaveOnStart);
            }

            TDE.Label(startX, startY += spaceY, width, height, "Start On Timer:", "Check to start the game on a timer instead of waiting for player initiation");
            instance.autoStart        = EditorGUI.Toggle(new Rect(startX + spaceX, startY, height, height), instance.autoStart);
            if (instance.autoStart)
            {
                instance.startTimer = EditorGUI.FloatField(new Rect(startX + spaceX + height + 5, startY, widthS, height), instance.startTimer);
            }

            int spawnCDType = (int)instance.spawnCDType;

            TDE.Label(startX, startY += spaceY, width, height, "Countdown Type:", "Spawn count down type in this level");
            contL                = TDE.SetupContL(spawnCDTypeLabel, spawnCDTypeTooltip);
            spawnCDType          = EditorGUI.Popup(new Rect(startX + spaceX, startY, widthS * 2 + 5, height), new GUIContent(""), spawnCDType, contL);
            instance.spawnCDType = (SpawnManager._SpawnCDType)spawnCDType;

            cont = new GUIContent(" - Skippable", "Allow player to skip ahead and spawn the next wave");
            if (instance.spawnCDType != SpawnManager._SpawnCDType.None)
            {
                instance.skippable = EditorGUI.ToggleLeft(new Rect(startX + spaceX + widthS * 2 + 10, startY, width, 15), cont, instance.skippable);
            }


            startY += spaceY * .5f;

            if (!instance.endlessMode)
            {
                TDE.Label(startX, startY += spaceY, width, height, "WavesList (" + instance.waveList.Count + "):", "Number of waves in the level");

                if (GUI.Button(new Rect(startX + spaceX, startY, widthS, 15), "-1"))
                {
                    if (instance.waveList.Count > 1)
                    {
                        instance.waveList.RemoveAt(instance.waveList.Count - 1);
                    }
                }
                if (GUI.Button(new Rect(startX + spaceX + widthS + 5, startY, widthS, 15), "+1"))
                {
                    instance.waveList.Add(new Wave());
                }

                if (!instance.genWaveOnStart && !configureGenerator)
                {
                    if (GUI.Button(new Rect(startX + spaceX + widthS * 2.5f, startY, widthS * 2, height), "Generate"))
                    {
                        instance.GenerateWave();
                    }
                }

                TDE.Label(window.position.width - width - 7, startY, width, height, " - Show Override Setting");
                showOverrideSetting = EditorGUI.Toggle(new Rect(window.position.width - width - 20, startY, width, height), showOverrideSetting);
            }
            else
            {
                startY += spaceY;           //TDE.Label(startX+spaceX, startY, width, height), "-");
            }
            return(startY + spaceY);
        }
Esempio n. 18
0
        protected float DrawUnitSetting(float startX, float startY, Unit item)
        {
            InitLabel();

            //string text="Unit Setting" + (foldUnit ? "(Hide)" : "(Show)");
            //foldUnit=EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldUnit, "Unit Setting", TDE.foldoutS);
            //if(!foldUnit) return startY;

            startX += 12;

            if (item.IsTurret())
            {
                int tgtMode = (int)item.targetMode;
                cont  = new GUIContent("Targeting Mode:", "How the unit select target from a group of potential hostile");
                contL = TDE.SetupContL(targetModeLabel, targetModeTooltip);
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                tgtMode         = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), tgtMode, contL);
                item.targetMode = (UnitTower._TargetMode)tgtMode;

                TDE.Label(startX, startY += spaceY, width, height, " - Reset On Attack:", "Check to force the unit to look for the most viable target on every attack (more expensive)");
                item.resetTargetOnAttack  = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.resetTargetOnAttack);

                GUI.color = (item.targetingFov <= 0 || item.targetingFov >= 360) ? grey : white;
                TDE.Label(startX, startY += spaceY, width, height, "Targeting FOV:", "Unit's active target field-of-view in angle");
                item.targetingFov         = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.targetingFov);     GUI.color = white;
                item.targetingFov         = Mathf.Clamp(item.targetingFov, 0, 360);

                startY += 10;
            }


            int objIdx = GetIndexFromHierarchy(item.targetPoint, objHierarchyList);

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "TargetPoint:", "The transform object which indicate the center point of the unit\nThis would be the point where the shootObject and effect will be aiming at");
            objIdx           = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
            item.targetPoint = objHierarchyList[objIdx];

            TDE.Label(startX, startY += spaceY, width, height, "Unit Radius:", "A reference value to indicate how 'big' the target is, used to determine when a shootobject hit the unit");
            item.unitRadius           = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.unitRadius);


            if (item.IsTurret())
            {
                startY += 10;

                GUIStyle style = item.shootObject == null ? TDE.conflictS : null;
                TDE.Label(startX, startY += spaceY, width, height, "Shoot Object:", "The shoot-object to fire at each attack. Must be a prefab contain a 'ShootObject' component", style);
                item.shootObject          = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), item.shootObject, typeof(ShootObject), true);

                cont = new GUIContent("ShootPoint:", "OPTIONAL - The transform which indicate the position where the shootObject will be fired from\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 = item.shootPoint.Count;
                shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), shootPointCount);

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

                if (shootPointFoldout)
                {
                    for (int i = 0; i < item.shootPoint.Count; i++)
                    {
                        objIdx = GetIndexFromHierarchy(item.shootPoint[i], objHierarchyList);
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                        objIdx             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
                        item.shootPoint[i] = objHierarchyList[objIdx];
                    }
                }

                TDE.Label(startX, startY += spaceY, width, height, "Shoot Point Spacing:", "The time delay in second between each shoot-point during an attack");
                if (item.shootPoint.Count <= 1)
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-", "");
                }
                else
                {
                    item.shootPointSpacing = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.shootPointSpacing);
                }

                startY += 10;

                TDE.Label(startX, startY += spaceY, width, height, "Turret Pivot:", "OPTIONAL - The object under unit's hierarchy which is used to aim toward target\nWhen left unassigned, no aiming will be done.");
                objIdx           = GetIndexFromHierarchy(item.turretPivot, objHierarchyList);
                objIdx           = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
                item.turretPivot = objHierarchyList[objIdx];

                TDE.Label(startX, startY += spaceY, width, height, "Barrel Pivot:", "OPTIONAL - The secondary object under unit's hierarchy which is used to aim toward target in x-axis only\nWhen left unassigned, no aiming will be done.");
                if (item.turretPivot == null)
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                }
                else
                {
                    objIdx           = GetIndexFromHierarchy(item.barrelPivot, objHierarchyList);
                    objIdx           = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objIdx, objHierarchylabel);
                    item.barrelPivot = objHierarchyList[objIdx];
                }

                TDE.Label(startX, startY += spaceY, width, height, "Aim In X-Axis:", "Check to have the turret aim in x-axis");
                if (item.turretPivot == null)
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, widthS, height), "-");
                }
                else
                {
                    item.aimInXAxis = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.aimInXAxis);
                }

                TDE.Label(startX, startY += spaceY, width, height, "Snap Aiming:", "Check to have the turret look at target instantly");
                if (item.turretPivot == null)
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }
                else
                {
                    item.snapAiming = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), item.snapAiming);
                }

                TDE.Label(startX, startY += spaceY, width, height, "Aim Speed:", "");
                if (item.turretPivot == null || item.snapAiming)
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }
                else
                {
                    item.aimSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), item.aimSpeed);
                }


                //~ public bool snapAiming=true;
                //~ public float aimSpeed=20;
            }

            return(startY);
        }
Esempio n. 19
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);
        }
Esempio n. 20
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);
        }
Esempio n. 21
0
        private Vector2 DrawUnitConfigurator(float startX, float startY, UnitCreep unit)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, unit);

            int type = (int)unit.creepType;

            cont  = new GUIContent("Creep Type:", "Type of the creep. Each type of creep serve a different function");
            contL = TDE.SetupContL(creepTypeLabel, creepTypeTooltip);
            EditorGUI.LabelField(new Rect(startX + 12, startY, width, height), cont);
            type           = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), type, contL);
            unit.creepType = (UnitCreep._CreepType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 12, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), creepTypeTooltip[(int)unit.creepType], MessageType.Info);
                startY += 45 - height;
            }


            startY = DrawGeneralSetting(startX, startY + spaceY + 10, unit);

            startY = DrawMovementSetting(startX, startY + spaceY, unit);


            startY += spaceY * 2;


            _EType cType = _EType.CDefault;

            if (unit.IsTurret())
            {
                cType = _EType.CTurret;
            }
            else if (unit.IsAOE())
            {
                cType = _EType.CAOE;
            }
            else if (unit.IsSupport())
            {
                cType = _EType.CSupport;
            }
            else if (unit.IsSpawner())
            {
                cType = _EType.CSpawner;
            }

            string text = "Unit Stats ";          //+ !foldStats ? "(show)" : "(hide)" ;

            foldStats = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldStats, text, TDE.foldoutS);
            if (foldStats)
            {
                startY = DrawStats(startX, startY + spaceY, unit.statsList[0], cType) - spaceY;

                if (unit.IsSpawner())
                {
                    startX += 12;     startY += 10;

                    TDE.Label(startX, startY += spaceY, width, height, "Spawn Prefab:", "Creep prefab to be spawned");
                    int idx = CreepDB.GetPrefabIndex(unit.spawnerPrefab);
                    idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, CreepDB.label);
                    unit.spawnerPrefab = CreepDB.GetItem(idx);
                    if (unit.spawnerPrefab == unit)
                    {
                        unit.spawnerPrefab = null;
                    }

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

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

                    bool valid = unit.spawnerPrefab != null && unit.spawnerCount > 0;

                    startY = DrawSpawnOverride(startX, startY, unit.spawnerOverride, valid, foldSpawnerOverride, SetFoldSpawnerOverride);

                    startX -= 12;
                }
            }


            startY = DrawCreepVisualEffect(startX, startY + spaceY, unit);

            startY = DrawUnitAnimation(startX, startY + spaceY, unit);

            startY += spaceY;


            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            unit.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style);


            return(new Vector2(maxX, startY + 170));
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
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);
        }
Esempio n. 25
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);
        }
Esempio n. 26
0
        protected float DrawTowerStats(float startX, float startY, UnitTower unit)
        {
            string textF = "Tower Stats And Upgrade";          //+(!foldStats ? "(show)" : "(hide)");

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

            startX += 15;

            TDE.Label(startX, startY += spaceY, width, height, "Next Upgrade:", "The tower prefab this tower can be upgraded to");
            for (int i = 0; i < unit.upgradeTowerList.Count; i++)
            {
                if (unit.upgradeTowerList[i] == null)
                {
                    unit.upgradeTowerList.RemoveAt(i);  i -= 1; continue;
                }

                TDE.Label(startX + spaceX - 20, startY, width, height, " - ", "");
                int idx = TowerDB.GetPrefabIndex(unit.upgradeTowerList[i]);
                idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, TowerDB.label);
                if (TowerDB.GetItem(idx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(idx)))
                {
                    unit.upgradeTowerList[i] = TowerDB.GetItem(idx);
                }

                if (GUI.Button(new Rect(startX + spaceX + width + 5, startY, height, height), "-"))
                {
                    unit.upgradeTowerList.RemoveAt(i);      i -= 1; continue;
                }

                startY += spaceY;
            }

            int newIdx = -1;

            if (unit.upgradeTowerList.Count > 0)
            {
                TDE.Label(startX + spaceX - 65, startY, width, height, " Add New:", "");
            }
            newIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newIdx, TowerDB.label);
            if (newIdx >= 0 && TowerDB.GetItem(newIdx) != unit && !unit.upgradeTowerList.Contains(TowerDB.GetItem(newIdx)))
            {
                Debug.Log("new index  " + newIdx + "     " + TowerDB.GetItem(newIdx));
                unit.upgradeTowerList.Add(TowerDB.GetItem(newIdx));
            }

            startY += 10;

            //~ if(GUI.Button(new Rect(startX+spaceX+15, startY, width, height), "Add Level")) {
            if (GUI.Button(new Rect(startX, startY + spaceY, width, height), "Add Level"))
            {
                unit.statsList.Add(new Stats());
                unit.statsList[unit.statsList.Count - 1].ResetAsBaseStat();
                foldStats = true;
            }

            startY += spaceY;

            blockWidth = spaceX + 2 * widthS + 26;

            float cachedX = startX;
            float cachedY = (startY += spaceY);

            for (int i = 0; i < unit.statsList.Count; i++)
            {
                GUI.Box(new Rect(startX, cachedY, blockWidth, blockHeight), "");

                EditorGUI.LabelField(new Rect(startX + 6, startY += 3, width, height), "Level " + (i + 1), TDE.headerS);

                GUI.color = new Color(1f, .25f, .25f, 1f);
                if (GUI.Button(new Rect(startX + blockWidth - 1.5f * widthS - 3, startY, widthS * 1.5f, 14), "remove"))
                {
                    if (unit.statsList.Count > 1)
                    {
                        unit.statsList.RemoveAt(i); i -= 1;
                    }
                }
                GUI.color = Color.white;

                _EType tType = _EType.TAOE;
                if (unit.IsTurret())
                {
                    tType = _EType.TTurret;
                }
                else if (unit.IsSupport())
                {
                    tType = _EType.TSupport;
                }
                else if (unit.IsResource())
                {
                    tType = _EType.TRsc;
                }
                else if (unit.IsMine())
                {
                    tType = _EType.TMine;
                }
                else if (unit.IsBlock())
                {
                    tType = _EType.TBlock;
                }


                blockHeight = DrawStats(startX, startY + spaceY + 3, unit.statsList[i], tType, true) - cachedY + 5;
                startY      = cachedY;

                startX += blockWidth + 10;

                maxX = startX;
            }
            startY += blockHeight;
            startX  = cachedX - 15;

            return(startY);
        }
Esempio n. 27
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);
        }
Esempio n. 28
0
        public void OnGUI()
        {
            TDE.InitGUIStyle();

            if (!CheckIsPlaying())
            {
                return;
            }
            if (window == null)
            {
                Init();
            }


            List <UnitTower> towerList = TowerDB.GetList();

            Undo.RecordObject(this, "window");
            Undo.RecordObject(TowerDB.GetDB(), "towerDB");
            if (towerList.Count > 0)
            {
                Undo.RecordObject(towerList[selectID], "tower");
            }


            if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save"))
            {
                TDE.SetDirty();
            }

            UnitTower newTower = null;

            TDE.Label(5, 7, 150, 17, "Add New Tower:", "Drag tower prefab to this slot to add it to the list");
            newTower = (UnitTower)EditorGUI.ObjectField(new Rect(115, 7, 150, 17), newTower, typeof(UnitTower), false);
            if (newTower != null)
            {
                Select(NewItem(newTower));
            }


            float startX = 5; float startY = 55;

            if (minimiseList)
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>"))
                {
                    minimiseList = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<"))
                {
                    minimiseList = true;
                }
            }

            Vector2 v2 = DrawTowerList(startX, startY, towerList);

            startX = v2.x + 25;

            if (towerList.Count == 0)
            {
                return;
            }


            Rect visibleRect = new Rect(startX, startY, window.position.width - startX, window.position.height - startY);
            Rect contentRect = new Rect(startX, startY, contentWidth, contentHeight);

            scrollPos = GUI.BeginScrollView(visibleRect, scrollPos, contentRect);

            v2            = DrawUnitConfigurator(startX, startY, towerList[selectID]);
            contentWidth  = v2.x - startX;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                TDE.SetDirty();
            }
        }
Esempio n. 29
0
        protected float DrawMovementSetting(float startX, float startY, UnitCreep unit)
        {
            string text = "Movement Setting ";          //+(!foldMovement ? "(show)" : "(hide)");

            foldMovement = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), foldMovement, text, TDE.foldoutS);
            if (foldMovement)
            {
                startX += 12;

                int type = (int)unit.pathOffsetMode;
                cont  = new GUIContent("Path Offset Mode:", "Gives a slight random offset to prevent creep from following the center of the path exactly\nThe actual deviation magnitude is set on individual path");
                contL = TDE.SetupContL(offsetModeLabel, offsetModeTooltip);
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                type = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), type, contL);
                unit.pathOffsetMode = (UnitCreep._PathOffsetMode)type;

                startY += 7;

                TDE.Label(startX, startY += spaceY, width, height, "Face Traveling Dir.:", "Check to have the creep face the direction their traveling in");
                unit.faceTravelingDir     = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.faceTravelingDir);

                TDE.Label(startX, startY += spaceY, width, height, " - Snap To Dir.:", "Check to have the creep sanp to the traveling direction instantly instead of rotate towards it");
                if (unit.faceTravelingDir)
                {
                    unit.snapToDir = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.snapToDir);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }

                TDE.Label(startX, startY += spaceY, width, height, " - Rotate Speed:", "The speed in which the unit rotate to face the traveling direction");
                if (unit.faceTravelingDir && !unit.snapToDir)
                {
                    unit.rotateSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.rotateSpeed);
                }
                else
                {
                    TDE.Label(startX + spaceX, startY, widthS, height, "-");
                }

                if (unit.IsTurret())
                {
                    startY += 7;

                    TDE.Label(startX, startY += spaceY, width, height, "Stop To Attack:", "Check to have the creep stop while attacking");
                    unit.stopToAttack         = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.stopToAttack);

                    TDE.Label(startX, startY += spaceY, width, height, " - Limit Per Stop:", "Number of attack the creep will perform everytime it stops\nOnce the limit is hit the unit will carry on moving");
                    if (unit.stopToAttack)
                    {
                        unit.attackLimitPerStop = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.attackLimitPerStop);
                    }
                    else
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }

                    TDE.Label(startX, startY += spaceY, width, height, " - Cooldown:", "Cooldown between stop\nUnit cannot stop to attack again when it's on cooldown");
                    if (unit.stopToAttack)
                    {
                        unit.stopToAttackCooldown = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), unit.stopToAttackCooldown);
                    }
                    else
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }
                }
            }

            return(startY);
        }