Example #1
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);
        }