Exemplo n.º 1
0
 protected override void ShiftItemDown()
 {
     if (selectID < EffectDB.GetList().Count - 1)
     {
         ShiftItem(1);
     }
 }
Exemplo n.º 2
0
        private void ShiftItem(int dir)
        {
            Effect item = EffectDB.GetList()[selectID];

            EffectDB.GetList()[selectID]       = EffectDB.GetList()[selectID + dir];
            EffectDB.GetList()[selectID + dir] = item;
            selectID += dir;
        }
Exemplo n.º 3
0
 public static EffectDB Init()
 {
     if (instance != null)
     {
         return(instance);
     }
     instance = LoadDB();
     return(instance);
 }
Exemplo n.º 4
0
 private void SelectItem(int newID)
 {
     selectID = newID;
     if (EffectDB.GetList().Count <= 0)
     {
         return;
     }
     selectID = Mathf.Clamp(selectID, 0, EffectDB.GetList().Count - 1);
 }
Exemplo n.º 5
0
        public static void Init(int prefabID = -1)
        {
            window         = (EffectEditorWindow)EditorWindow.GetWindow(typeof(EffectEditorWindow), false, "EffectEditor");
            window.minSize = new Vector2(420, 300);

            TDE.Init();

            window.InitLabel();

            if (prefabID >= 0)
            {
                window.selectID = EffectDB.GetPrefabIndex(prefabID);
            }
        }
Exemplo n.º 6
0
        public Effect GetEffectOnHit()
        {
            int overrideID = PerkManager.GetAbilityOverrideOnHitEff(prefabID);          //GetPerkOverrideOnHitEff();

            if (overrideID < 0 && stats.effectOnHitID < 0)
            {
                return(null);
            }
            else
            {
                //return EffectDB.GetPrefab(stats.effectOnHitID).Clone();

                Effect effect = EffectDB.GetPrefab(overrideID >= 0 ? overrideID : stats.effectOnHitID).ModifyWithPerk();
                effect.SetType(instanceID, this);
                return(effect);
            }
        }
Exemplo n.º 7
0
        private int _NewItem(int idx = -1)
        {
            Effect item = null;

            if (idx < 0)
            {
                item = new Effect(); item.Reset();
            }
            if (idx >= 0)
            {
                item = EffectDB.GetList()[idx].Clone();
            }

            item.prefabID = TDE.GenerateNewID(EffectDB.GetPrefabIDList());

            EffectDB.GetList().Add(item);
            EffectDB.UpdateLabel();

            return(EffectDB.GetList().Count - 1);
        }
Exemplo n.º 8
0
        public Effect GetEffectOnHit()
        {
            if (IsTower())
            {
                int overrideID = PerkManager.GetUnitOverrideOnHitEff(prefabID);
                if (overrideID < 0 && statsList[level].effectOnHitID < 0)
                {
                    return(null);
                }

                Effect effect = EffectDB.GetPrefab(overrideID >= 0 ? overrideID : statsList[level].effectOnHitID).ModifyWithPerk();
                effect.SetType(level, this);
                return(effect);
            }
            else
            {
                if (statsList[level].effectOnHitID < 0)
                {
                    return(null);
                }

                Effect effect = null;
                if (cachedEffOnHitIdx < 0)
                {
                    effect            = EffectDB.GetPrefab(statsList[level].effectOnHitID).Clone();
                    cachedEffOnHitIdx = EffectDB.GetPrefabIndex(effect.prefabID);
                }
                else
                {
                    effect = EffectDB.GetItem(cachedEffOnHitIdx).Clone();
                    //Debug.Log("use cached "+cachedEffOnHitIdx+"   "+effect.name);
                }

                effect.SetType(level, this);
                return(effect);
            }
        }
Exemplo n.º 9
0
        public static void Init()
        {
            if (init)
            {
                return;
            }

            init = true;                //Debug.Log(" - Init Editor - ");

            damageTableDB = DamageTableDB.Init();
            rscDB         = RscDB.Init();
            towerDB       = TowerDB.Init();
            creepDB       = CreepDB.Init();
            abilityDB     = AbilityDB.Init();
            perkDB        = PerkDB.Init();
            effectDB      = EffectDB.Init();

            DamageTableDB.UpdateLabel();
            TowerDB.UpdateLabel();
            CreepDB.UpdateLabel();
            AbilityDB.UpdateLabel();
            PerkDB.UpdateLabel();
            EffectDB.UpdateLabel();
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
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);
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
0
        public void OnGUI()
        {
            TDE.InitGUIStyle();

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


            List <Effect> abilityList = EffectDB.GetList();

            Undo.RecordObject(this, "window");
            Undo.RecordObject(EffectDB.GetDB(), "abilityDB");


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


            if (GUI.Button(new Rect(5, 5, 120, 25), "Create New"))
            {
                Select(NewItem());
            }
            if (abilityList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected"))
            {
                Select(NewItem(selectID));
            }


            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 = DrawEffectList(startX, startY, abilityList);

            startX = v2.x + 25;

            if (abilityList.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            = DrawEffectConfigurator(startX, startY, abilityList[selectID]);
            contentWidth  = v2.x - startX;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                TDE.SetDirty();
            }
        }
Exemplo n.º 14
0
 protected override void DeleteItem()
 {
     EffectDB.GetList().RemoveAt(deleteID);
     EffectDB.UpdateLabel();
 }