Example #1
0
        void SwapResource(int ID)
        {
            List <Rsc> rscList = EditorDBManager.GetRscList();

            Rsc rsc = rscList[currentSwapID];

            rscList[currentSwapID] = rscList[ID];
            rscList[ID]            = rsc;

            currentSwapID = -1;

            EditorDBManager.SetDirtyRsc();
        }
Example #2
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            if (GUI.Button(new Rect(window.position.width - 110, 10, 100, 30), "Save"))
            {
                EditorDBManager.SetDirtyRsc();
            }

            if (GUI.Button(new Rect(10, 10, 100, 30), "New Resource"))
            {
                EditorDBManager.AddNewRsc();
            }

            List <Rsc> rscList = EditorDBManager.GetRscList();

            if (rscList.Count > 0)
            {
                GUI.Box(new Rect(5, 50, 50, 20), "ID");
                GUI.Box(new Rect(5 + 50 - 1, 50, 70 + 1, 20), "Texture");
                GUI.Box(new Rect(5 + 120 - 1, 50, 150 + 2, 20), "Name");
                GUI.Box(new Rect(5 + 270, 50, window.position.width - 280, 20), "");
            }

            int row = 0;

            for (int i = 0; i < rscList.Count; i++)
            {
                if (i % 2 == 0)
                {
                    GUI.color = new Color(.8f, .8f, .8f, 1);
                }
                else
                {
                    GUI.color = Color.white;
                }
                GUI.Box(new Rect(5, 75 + i * 49, window.position.width - 10, 50), "");
                GUI.color = Color.white;

                GUI.Label(new Rect(22, 15 + 75 + i * 49, 50, 20), rscList[i].ID.ToString());


                EditorUtilities.DrawSprite(new Rect(12 + 50, 3 + 75 + i * 49, 44, 44), rscList[i].icon, true);


                //rscList[i].name=EditorGUI.TextField(new Rect(5+120, 15+75+i*49, 150, 20), rscList[i].name);
                rscList[i].name = EditorGUI.TextField(new Rect(5 + 120, 5 + 75 + i * 49, 150, 18), rscList[i].name);
                GUI.Label(new Rect(5 + 120, 25 + 75 + i * 49, 120, 18), "Icon: ");
                rscList[i].icon = (Sprite)EditorGUI.ObjectField(new Rect(45 + 120, 25 + 75 + i * 49, 110, 18), rscList[i].icon, typeof(Sprite), false);

                if (delete != i)
                {
                    if (GUI.Button(new Rect(window.position.width - 35, 12 + 75 + i * 49, 25, 25), "X"))
                    {
                        delete = i;
                    }
                }
                else
                {
                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(window.position.width - 65, 12 + 75 + i * 49, 25, 25), "X"))
                    {
                        EditorDBManager.RemoveRsc(i);
                        delete = -1;
                    }
                    GUI.color = Color.green;
                    if (GUI.Button(new Rect(window.position.width - 35, 12 + 75 + i * 49, 25, 25), "-"))
                    {
                        delete = -1;
                    }
                    GUI.color = Color.white;
                }

                row += 1;
            }


            if (GUI.changed)
            {
                EditorDBManager.SetDirtyRsc();
            }
        }
Example #3
0
        Vector3 DrawUnitConfigurator(float startX, float startY, List <UnitCreep> creepList, bool offense = false)
        {
            UnitCreep creep = creepList[selectID];

            float maxWidth = 0;
            //float cachedY=startY;
            float cachedX = startX;

            startX += 65;   //startY+=20;

            int type = (int)creep.type;

            cont = new GUIContent("Creep Type:", "Type of the creep. Different type of creep has different capabilities");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            contL = new GUIContent[creepTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(creepTypeLabel[i], creepTypeTooltip[i]);
            }
            type       = EditorGUI.Popup(new Rect(startX + 80, startY, width - 40, 15), new GUIContent(""), type, contL);
            creep.type = (_CreepType)type;
            startX     = cachedX;

            v3 = DrawIconAndName(creep, startX, startY); startY = v3.y; maxWidth = v3.z;

            cont = new GUIContent("Move When Casting:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's hitChance. Assume two attackers with 1 hitChance and .8 hitChance and the dodgeChance set to .2, the chances to dodge attack from each attacker are 20% and 40% respectively.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            creep.movableWhenCasting = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 50, height), creep.movableWhenCasting);

            cont = new GUIContent("Dodge Chance:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's hitChance. Assume two attackers with 1 hitChance and .8 hitChance and the dodgeChance set to .2, the chances to dodge attack from each attacker are 20% and 40% respectively.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            creep.stats[0].dodge = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 50, height), creep.stats[0].dodge);

            v3 = DrawUnitDefensiveSetting(creep, startX, startY, objHList, objHLabelList); startY = v3.y; if (maxWidth < v3.z)
            {
                maxWidth = v3.z;
            }

            startY += 20;


            cont = new GUIContent("Flying:", "Check to mark the creep as flying unit.");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            creep.flying = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), creep.flying);

            cont = new GUIContent("Move Speed:", "Moving speed of the creep");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            creep.moveSpeed = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), creep.moveSpeed);

            cont = new GUIContent("Life Cost:", "The amont of life taken from player when this creep reach it's destination");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            creep.lifeCost = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.lifeCost);

            //cont=new GUIContent("Score Value:", "Score gained when destroy this creep");
            //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            //creep.scoreValue=EditorGUI.IntField(new Rect(startX+spaceX, startY, 40, height), creep.scoreValue);

            cont = new GUIContent("Life Gain:", "Life awarded to the player when player successfully destroy this creep");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            creep.lifeValue = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.lifeValue);

            cont = new GUIContent("Energy Gain:", "Energy awarded to the player when player successfully destroy this creep");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            creep.valueEnergyGain = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.valueEnergyGain);


            cont = new GUIContent("Resource Gain Upon Destroyed:", "The amont of life taken from player when this creep reach it's destination");
            //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            rscGainFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), rscGainFoldout, cont);
            if (rscGainFoldout)
            {
                List <Rsc> rscList = EditorDBManager.GetRscList();
                for (int i = 0; i < rscList.Count; i++)
                {
                    EditorUtilities.DrawSprite(new Rect(startX + 25, startY += spaceY - 2, 20, 20), rscList[i].icon); startY += 2;
                    EditorGUI.LabelField(new Rect(startX, startY, width, height), "    -       min/max");//+rscList[i].name);
                    creep.valueRscMin[i] = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.valueRscMin[i]);
                    creep.valueRscMax[i] = EditorGUI.IntField(new Rect(startX + spaceX + 40, startY, 40, height), creep.valueRscMax[i]);
                }
                startY += 5;
            }


            string[] creepNameList = EditorDBManager.GetCreepNameList();
            cont = new GUIContent("SpawnUponDestroyed:", "Creep prefab to be spawn when an instance of this unit is destroyed. Note that the HP of the spawned unit is inherit from the destroyed unit. Use HP-multiplier to specifiy how much of the HP should be carried forward");
            GUI.Label(new Rect(startX, startY += spaceY, width, height), cont);
            int ID = -1;

            for (int i = 0; i < creepList.Count; i++)
            {
                if (creepList[i].gameObject == creep.spawnUponDestroyed)
                {
                    ID = i + 1;
                }
            }
            ID = EditorGUI.Popup(new Rect(startX + spaceX + 30, startY, 120, height), ID, creepNameList);
            if (ID > 0 && creepList[ID - 1] != creep)
            {
                creep.spawnUponDestroyed = creepList[ID - 1].gameObject;
            }
            else if (ID == 0)
            {
                creep.spawnUponDestroyed = null;
            }

            if (creep.spawnUponDestroyed != null)
            {
                cont = new GUIContent(" - Num to Spawn:", "The amount of creep to spawn when this unit is destroyed");
                EditorGUI.LabelField(new Rect(startX + 20, startY += spaceY, width, height), cont);
                creep.spawnUponDestroyedCount = EditorGUI.IntField(new Rect(startX + spaceX + 30, startY, 40, height), creep.spawnUponDestroyedCount);

                cont = new GUIContent(" - HP Multiplier:", "The percentage of HP to pass to the next unit. 0.5 being 50% of parent unit's fullHP, 1 being 100% of parent unit's fullHP");
                EditorGUI.LabelField(new Rect(startX + 20, startY += spaceY, width, height), cont);
                creep.spawnUnitHPMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX + 30, startY, 40, height), creep.spawnUnitHPMultiplier);
            }

            startY += 20;


            if (creep.type == _CreepType.Offense)
            {
                cont = new GUIContent("Stop To Attack:", "Check to have the creep stop moving when there's target to attack");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                creep.stopToAttack = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), creep.stopToAttack);
                startY            += spaceY;
            }
            v3 = DrawUnitOffensiveSetting(creep, startX, startY, objHList, objHLabelList); startY = v3.y + 20; if (maxWidth < v3.z)
            {
                maxWidth = v3.z;
            }


            if (creep.type == _CreepType.Offense)
            {
                startY += 30;
            }

            BaseAnimationController ani = creep.gameObject.GetComponent <BaseAnimationController>();

            if (ani == null)
            {
                if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Add animation component"))
                {
                    ani = creep.gameObject.AddComponent <BaseAnimationController>();
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Remove animation component"))
                {
                    DestroyImmediate(ani, true);
                    return(new Vector3(startX, startY, maxWidth));
                }
            }

            return(new Vector3(startX, startY, maxWidth));
        }
Example #4
0
        public static Vector3 DrawStat(UnitStat stat, float startX, float startY, float statContentHeight, UnitTower tower, UnitCreep creep)
        {
            List <Rsc> rscList = EditorDBManager.GetRscList();

            float width  = 150;
            float fWidth = 35;
            float spaceX = 130;
            float height = 18;
            float spaceY = height + 2;

            //startY-=spaceY;

            GUI.Box(new Rect(startX + 10, startY + 20, 220, statContentHeight - startY), "");
            startX += 20; startY += 25;
            if (tower && tower.IsHero())
            {
                //stat.icon = EditorGUI.ObjectField(new Rect(startX + 100, startY + 20, 60, 60), stat.icon, typeof(Sprite)) as Sprite;
                //startX += 20; startY += 85;
                cont = new GUIContent("Ability:", "Istrumination");
                EditorGUI.LabelField(new Rect(startX, startY, 50, spaceY), cont);
                stat.abilityHolder = EditorGUI.ObjectField(new Rect(startX + 80, startY, 105, spaceY), stat.abilityHolder, typeof(AbilityBehavior)) as AbilityBehavior;
                startX            += 0; startY += spaceY;
            }

            if (tower != null)
            {
                cont = new GUIContent("Construct Duration:", "The time in second it takes to construct (if this is the first level)/upgrade (if this is not the first level)");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.buildDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buildDuration);

                cont = new GUIContent("Deconstruct Duration:", "The time in second it takes to deconstruct if the unit is in this level");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.unBuildDuration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.unBuildDuration);


                if (stat.cost.Count != rscList.Count)
                {
                    while (stat.cost.Count > rscList.Count)
                    {
                        stat.cost.RemoveAt(stat.cost.Count - 1);
                    }
                    while (stat.cost.Count < rscList.Count)
                    {
                        stat.cost.Add(0);
                    }
                }
                cont = new GUIContent("Build/Upgrade Cost:", "The resource required to build/upgrade to this level");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                int count = 0; startY += spaceY; float cachedX = startX;
                for (int i = 0; i < rscList.Count; i++)
                {
                    EditorUtilities.DrawSprite(new Rect(startX + 10, startY - 1, 20, 20), rscList[i].icon);
                    stat.cost[i] = EditorGUI.IntField(new Rect(startX + 30, startY, fWidth, height), stat.cost[i]);
                    count       += 1; startX += 65;
                    if (count == 3)
                    {
                        startY += spaceY; startX = cachedX;
                    }
                }
                startX = cachedX; startY += 5;

                startY += spaceY + 5;
            }

            //if(tower && tower.IsHero())
            //{
            //    cont = new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
            //    EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            //    stat.shootObject = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, width-20, height), stat.shootObject, typeof(ShootObject));
            //    startY += spaceY;
            //}
            //else
            if ((tower && TowerUseShootObject(tower)) || (creep && creep.type == _CreepType.Offense))
            {
                if (stat.shootObjects.Count == 0 && stat.shootObject)
                {
                    stat.shootObjects.Add(stat.shootObject);
                }
                cont = new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                Vector2 Start = EditorUtilities.DrawButton(new Rect(startX, startY + 15, 30, height),
                                                           Vector2.zero, "+", () =>
                {
                    if (stat.shootObjects.Count > 0 && stat.shootObjects[stat.shootObjects.Count - 1])
                    {
                        stat.shootObjects.Add(stat.shootObjects[stat.shootObjects.Count - 1]);    //clone the last one
                    }
                    else
                    {
                        stat.shootObjects.Add(null);
                    }
                });

                EditorUtilities.DrawButton(new Rect(startX + 31, startY + 15, 30, height),
                                           Vector2.zero, "-", () =>
                {
                    if (stat.shootObjects.Count > 1)
                    {
                        stat.shootObjects.RemoveAt(stat.shootObjects.Count - 1);
                    }
                });

                if (stat.shootObjects.Count < 2)
                {
                    startY = Start.y;
                }
                if (stat.shootObjects.Count == 1)
                {
                    startY -= height;
                }
                for (int i = 0; i < stat.shootObjects.Count; i++)
                {
                    stat.shootObjects[i] = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, 4 * fWidth - 20, height), stat.shootObjects[i], typeof(ShootObject), false);
                    startY += spaceY;
                }
            }

            cont = new GUIContent("Target layer:", "");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            stat.customMask = EditorUtilities.LayerMaskField(new Rect(startX + spaceX - 50, startY, 4 * fWidth - 20, height), "", stat.customMask);
            startY         += 5;

            if (tower && TowerUseShootObjectT(tower))
            {
                cont = new GUIContent("ShootObject:", "The shootObject used by the unit.\nUnit that intended to shoot at the target will not function correctly if this is left unassigned.");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                stat.shootObjectT = (Transform)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, 4 * fWidth - 20, height), stat.shootObjectT, typeof(Transform), false);
                startY           += 5;
            }

            if ((tower && TowerDealDamage(tower)) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("Damage(Min/Max):", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.damageMin = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.damageMin);
                stat.damageMax = EditorGUI.FloatField(new Rect(startX + spaceX + fWidth, startY, fWidth, height), stat.damageMax);

                cont = new GUIContent("Cooldown:", "Duration between each attack");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.cooldown = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.cooldown);


                cont = new GUIContent("Attack Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.attackRange = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.attackRange);

                if (creep)
                {
                    cont = new GUIContent("Detect Range:", "Detect range of the creep");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    creep.detectRange = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), creep.detectRange);
                }
                //~ cont=new GUIContent("Range(Min/Max):", "");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ stat.minRange=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.minRange);
                //~ stat.range=EditorGUI.FloatField(new Rect(startX+spaceX+fWidth, startY, fWidth, height), stat.range);

                cont = new GUIContent("AOE Radius:", "Area-of-Effective radius. When the shootObject hits it's target, any other hostile unit within the area from the impact position will suffer the same target as the target.\nSet value to >0 to enable. ");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.aoeRadius = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.aoeRadius);



                cont = new GUIContent("Hit Chance:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's dodgeChance. Assume two targets with 0 dodgeChance and .2 dodgeChance and the hitChance set to 1, the unit will always hits the target and have 20% chance to miss the second target.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.hit = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.hit);

                if (!creep)
                {
                    cont = new GUIContent("Dodge Chance:", "Take value from 0-1. 0 being 0% and 1 being 100%. Final value are subject to target's hitChance. Assume two attackers with 1 hitChance and .8 hitChance and the dodgeChance set to .2, the chances to dodge attack from each attacker are 20% and 40% respectively.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    stat.dodge = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dodge);
                }


                cont = new GUIContent("Stun", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

                cont = new GUIContent("        - Chance:", "Chance to stun the target in each successful attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.stun.chance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.stun.chance);

                cont = new GUIContent("        - Duration:", "The stun duration in second");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.stun.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.stun.duration);



                cont = new GUIContent("Critical", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

                cont = new GUIContent("            - Chance:", "Chance to score critical hit in attack. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.crit.chance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.crit.chance);

                cont = new GUIContent("            - Multiplier:", "Damage multiplier for successful critical hit. Takes value from 0 and above with with 0.5 being 50% of normal damage as bonus");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.crit.dmgMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.crit.dmgMultiplier);



                cont = new GUIContent("Slow", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

                cont = new GUIContent("         - Duration:", "The effect duration in second");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.slow.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.slow.duration);

                cont = new GUIContent("         - Multiplier:", "Move speed multiplier. Takes value from 0-1 with with 0.7 being decrese default speed by 30%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.slow.slowMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.slow.slowMultiplier);



                cont = new GUIContent("Dot", "Damage over time");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

                cont = new GUIContent("        - Duration:", "The effect duration in second");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.dot.duration = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dot.duration);

                cont = new GUIContent("        - Interval:", "Duration between each tick. Damage is applied at each tick.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.dot.interval = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dot.interval);

                cont = new GUIContent("        - Damage:", "Damage applied at each tick");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.dot.value = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.dot.value);



                cont = new GUIContent("InstantKill", "");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

                cont = new GUIContent("                - Chance:", "The chance to instant kill the target. Takes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.instantKill.chance = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.instantKill.chance);

                cont = new GUIContent("        - HP Threshold:", "The HP threshold of the target in order for the instantKill to become valid. Take value from 0-1 with 0.3 being 30% of the fullHP.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.instantKill.HPThreshold = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.instantKill.HPThreshold);


                cont = new GUIContent("Damage Shield Only:", "When checked, unit will only inflict shield damage");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.damageShieldOnly = EditorGUI.Toggle(new Rect(startX + spaceX, startY, fWidth, height), stat.damageShieldOnly);

                cont = new GUIContent("Shield Break:", "The chance of the unit's attack to damage target's shield and disable shield regen permenantly\nTakes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.shieldBreak = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.shieldBreak);

                cont = new GUIContent("Shield Pierce:", "The chance of the unit's attack to bypass target's shield and damage HP directly\nTakes value from 0-1 with 0 being 0% and 1 being 100%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.shieldPierce = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.shieldPierce);
            }



            if ((tower && tower.type == _TowerType.Support) || (creep && creep.type == _CreepType.Support))
            {
                cont = new GUIContent("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.attackRange = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.attackRange);
                startY          += 5;

                cont = new GUIContent("Buff:", "Note: Buffs from multple tower doesnt stack, however when there's difference in the buff strength, the stronger buff applies. A tower can gain maximum dmage buff from one source and maximum range buff from another");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont); startY -= spaceY;

                cont = new GUIContent("        - Damage:", "Damage buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in damage");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.damageBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.damageBuff);

                cont = new GUIContent("        - Cooldown:", "Dooldown buff multiplier. Takes value from 0-1 with 0.2 being reduce cooldown by 20%");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.cooldownBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.cooldownBuff);

                cont = new GUIContent("        - Range:", "Range buff multiplier. Takes value from 0 and above with 0.5 being 50% increase in range");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.rangeBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.rangeBuff);

                cont = new GUIContent("        - Critical:", "Critical hit chance buff modifier. Takes value from 0 and above with 0.25 being 25% increase in critical hit chance");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.criticalBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.criticalBuff);

                cont = new GUIContent("        - Hit:", "Hit chance buff modifier. Takes value from 0 and above with .2 being 20% increase in hit chance");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.hitBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.hitBuff);

                cont = new GUIContent("        - Dodge:", "Dodge chance buff modifier. Takes value from 0 and above with 0.15 being 15% increase in dodge chance");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.dodgeBuff = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.dodgeBuff);

                cont = new GUIContent("        - HP Regen:", "HP Regeneration Buff. Takes value from 0 and above with 2 being gain 2HP second ");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.buff.regenHP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.buff.regenHP);
            }


            if (tower && tower.type == _TowerType.Resource)
            {
                if (stat.rscGain.Count != rscList.Count)
                {
                    while (stat.rscGain.Count > rscList.Count)
                    {
                        stat.rscGain.RemoveAt(stat.rscGain.Count - 1);
                    }
                    while (stat.rscGain.Count < rscList.Count)
                    {
                        stat.rscGain.Add(0);
                    }
                }
                cont = new GUIContent("Resource Gain:", "The resource gain by unit at each cooldown interval\nOnly applicable to ResourceTower");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                int count = 0; startY += spaceY; float cachedX = startX;
                for (int i = 0; i < rscList.Count; i++)
                {
                    EditorUtilities.DrawSprite(new Rect(startX + 10, startY - 1, 20, 20), rscList[i].icon);
                    stat.rscGain[i] = EditorGUI.IntField(new Rect(startX + 30, startY, fWidth, height), stat.rscGain[i]);
                    count          += 1; startX += 65;
                    if (count == 3)
                    {
                        startY += spaceY; startX = cachedX;
                    }
                }
                startX = cachedX; startY += 5;
            }


            if (tower)
            {
                startY += 10;
                cont    = new GUIContent("Custom Description:", "Check to use use custom description. If not, the default one (generated based on the effect) will be used");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.useCustomDesp = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), stat.useCustomDesp);
                if (stat.useCustomDesp)
                {
                    GUIStyle style = new GUIStyle("TextArea");
                    style.wordWrap = true;
                    stat.desp      = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 200, 90), stat.desp, style);
                    startY        += 90;
                }
            }



            statContentHeight = startY + spaceY - 15;

            return(new Vector3(startX + 220, startY, statContentHeight));
        }
Example #5
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }
            if (instance == null)
            {
                EditorGUI.LabelField(new Rect(5, 5, 350, 18), "No SpawnManager in current scene");
                GetSpawnManager();
                return;
            }

            if (creepList.Count != creepNameList.Length)
            {
                ResetCreepNameList();
            }


            if (instance.spawnLimit == SpawnManager._SpawnLimit.Finite && !instance.procedurallyGenerateWave)
            {
                if (GUI.Button(new Rect(window.position.width - 130, 5, 125, 25), configureAutoGen ? "Wave List" : "Configuration"))
                {
                    configureAutoGen = !configureAutoGen;
                }

                if (!configureAutoGen)
                {
                    GUI.color = new Color(0, 1, 1, 1);
                    cont      = new GUIContent("Auto Generate", "Procedurally generate all the waves\nCAUTION: overwirte all existing wave!");
                    if (GUI.Button(new Rect(window.position.width - 130, 35, 125, 25), cont))
                    {
                        for (int i = 0; i < instance.waveList.Count; i++)
                        {
                            instance.waveList[i] = instance.waveGenerator.Generate(i);
                        }
                    }
                    GUI.color = Color.white;
                }
            }

            if (GUI.Button(new Rect(window.position.width - 130, 90, 125, 25), "Creep Editor"))
            {
                UnitCreepEditorWindow.Init();
            }


            float startX = 5;
            float startY = 5;


            int spawnMode = (int)instance.spawnMode;

            cont = new GUIContent("Spawn Mode:", "Spawn mode in this level");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            cont     = new GUIContent("", "");
            contList = new GUIContent[spawnModeLabel.Length];
            for (int i = 0; i < contList.Length; i++)
            {
                contList[i] = new GUIContent(spawnModeLabel[i], spawnModeTooltip[i]);
            }
            spawnMode          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), cont, spawnMode, contList);
            instance.spawnMode = (SpawnManager._SpawnMode)spawnMode;

            if (instance.spawnMode != SpawnManager._SpawnMode.Round)
            {
                cont = new GUIContent("Allow Skip:", "Allow player to skip ahead and spawn the next wave");
                EditorGUI.LabelField(new Rect(startX + spaceX + width + 20, startY, width, height), cont);
                instance.allowSkip = GUI.Toggle(new Rect(startX + spaceX + width + 90, startY, 15, 15), instance.allowSkip, "");
            }


            int spawnLimit = (int)instance.spawnLimit;

            cont = new GUIContent("Spawn Count:", "Spawn count in this level. Infinite (endless mode) must use procedural wave generation");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            cont     = new GUIContent("", "");
            contList = new GUIContent[spawnLimitLabel.Length];
            for (int i = 0; i < contList.Length; i++)
            {
                contList[i] = new GUIContent(spawnLimitLabel[i], spawnLimitTooltip[i]);
            }
            spawnLimit          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), cont, spawnLimit, contList);
            instance.spawnLimit = (SpawnManager._SpawnLimit)spawnLimit;

            cont = new GUIContent("Auto Start: ", "Check to have the spawning start on a fixed timer. Rather than waiting for player initiation");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 50, height), cont);
            instance.autoStart = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), instance.autoStart);

            if (instance.autoStart)
            {
                cont = new GUIContent("Timer: ", "The duration to wait in second before the spawning start");
                EditorGUI.LabelField(new Rect(startX + spaceX + 30, startY, width + 50, height), cont);
                instance.autoStartDelay = EditorGUI.FloatField(new Rect(startX + spaceX + 70, startY, width - 70, height), instance.autoStartDelay);
            }

            if (instance.spawnLimit == SpawnManager._SpawnLimit.Finite)
            {
                cont = new GUIContent("Auto Generate", "Check to have the SpawnManager automatically generate the wave in runtime as opposed to using preset data");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 50, height), cont);
                instance.procedurallyGenerateWave             = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), instance.procedurallyGenerateWave);

                cont = new GUIContent("Default Path:", "The primary path to be used. Every creep will follow this path unless an alternate path is specified in a sub-wave");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                instance.defaultPath = (PathTD)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, 15), instance.defaultPath, typeof(PathTD), true);

                cont = new GUIContent("Waves Size: " + instance.waveList.Count, "Number of waves in the level");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, 15), cont);
                if (GUI.Button(new Rect(startX + spaceX, startY - 1, 40, 15), "-1"))
                {
                    if (instance.waveList.Count > 1)
                    {
                        instance.waveList.RemoveAt(instance.waveList.Count - 1);
                        waveFoldList.RemoveAt(waveFoldList.Count - 1);
                    }
                }
                if (GUI.Button(new Rect(startX + spaceX + 50, startY - 1, 40, 15), "+1"))
                {
                    if (instance.waveList.Count > 0)
                    {
                        instance.waveList.Add(instance.waveList[instance.waveList.Count - 1].Clone());
                    }
                    else
                    {
                        Wave    wave    = new Wave();
                        SubWave subWave = new SubWave();
                        wave.subWaveList.Add(subWave);
                        List <Rsc> rscList = EditorDBManager.GetRscList();
                        wave.rscGainList = new List <int>();
                        for (int i = 0; i < rscList.Count; i++)
                        {
                            wave.rscGainList.Add(0);
                        }
                        instance.waveList.Add(wave);
                    }
                    waveFoldList.Add(true);
                }
            }
            else
            {
                configureAutoGen = false;
            }

            if (instance.spawnLimit == SpawnManager._SpawnLimit.Infinite || configureAutoGen)
            {
                EditorGUI.LabelField(new Rect(startX, startY + 30, 400, height), "Procedural Wave Generation Parameters");
                startY += 10;
            }

            startY += 35;
            float waveConfigStartY = startY;

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

            contentWidth = 0;
            GUI.color    = new Color(.8f, .8f, .8f, 1f);
            GUI.Box(visibleRect, "");
            GUI.color = Color.white;

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

            startX += 5;
            startY += 10;

            float   cachedX = startX;
            Vector2 v2      = Vector2.zero;

            if (instance.spawnLimit == SpawnManager._SpawnLimit.Infinite || configureAutoGen || instance.procedurallyGenerateWave)
            {
                v2 = WaveGeneratorSetting(startX + 5, startY);
            }
            else
            {
                v2 = WaveConfigurator(startX, startY);
            }

            startX = cachedX;
            startY = v2.y;

            GUI.EndScrollView();

            contentHeight = startY - waveConfigStartY;

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }