Esempio n. 1
0
        public static void Init()
        {
            window = (PerkEditorWindow)EditorWindow.GetWindow(typeof(PerkEditorWindow));
            EditorDBManager.Init();

            InitLabel();
        }
        public static Vector3 DrawUnitDefensiveSetting(Unit unit, float startX, float startY, List <GameObject> objHList, string[] objHLabelList)
        {
            //float cachedX=startX;
            //float cachedY=startY;

            string[] armorTypeLabel = EditorDBManager.GetArmorTypeLabel();
            cont = new GUIContent("Armor Type:", "The armor type of the unit\nArmor type can be configured in Damage Armor Table Editor");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.armorType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.armorType, armorTypeLabel);

            int objID = GetObjectIDFromHList(unit.targetPoint, objHList);

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

            cont = new GUIContent("Hit Threshold:", "The range from the targetPoint where a shootObject is considered reached the target");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.hitThreshold = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), unit.hitThreshold);

            cont = new GUIContent("Immuned to Crit:", "Check if the unit is immuned to critical hit");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.immuneToCrit = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.immuneToCrit);

            cont = new GUIContent("Immuned to Slow:", "Check if the unit is immuned to slow");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.immuneToSlow = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.immuneToSlow);

            cont = new GUIContent("Immuned to Stun:", "Check if the unit is immuned to stun");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            unit.immuneToStun = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.immuneToStun);

            return(new Vector3(startX, startY, spaceX + width));
        }
Esempio n. 3
0
        void Awake()
        {
            instance = (UIPerkMenu)target;

            EditorDBManager.Init();

            EditorUtility.SetDirty(instance);
        }
Esempio n. 4
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window         = (ResourceDBEditor)EditorWindow.GetWindow(typeof(ResourceDBEditor));
            window.minSize = new Vector2(355, 455);
            //~ window.maxSize=window.minSize;

            EditorDBManager.Init();
        }
Esempio n. 5
0
        Vector2 DrawItemIDAbility(float startX, float startY, Perk perk, int limit = 1)
        {
            string[]       abilityNameList = EditorDBManager.GetAbilityNameList();
            List <Ability> abilityList     = EditorDBManager.GetAbilityList();

            if (perk.itemIDList.Count == 0)
            {
                perk.itemIDList.Add(-1);
            }
            while (perk.itemIDList.Count > limit)
            {
                perk.itemIDList.RemoveAt(perk.itemIDList.Count - 1);
            }

            for (int i = 0; i < perk.itemIDList.Count; i++)
            {
                int ID = perk.itemIDList[i];

                if (ID >= 0)
                {
                    for (int n = 0; n < abilityList.Count; n++)
                    {
                        if (abilityList[n].ID == ID)
                        {
                            ID = n + 1; break;
                        }
                    }
                }

                cont = new GUIContent(" - Ability:", "The ability to add to game when the perk is unlocked");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                ID = EditorGUI.Popup(new Rect(startX + spaceX - 20, startY, width, 15), ID, abilityNameList);
                if (ID > 0 && !perk.itemIDList.Contains(abilityList[ID - 1].ID))
                {
                    perk.itemIDList[i] = abilityList[ID - 1].ID;
                }
                else if (ID == 0)
                {
                    perk.itemIDList[i] = -1;
                }

                //if the list is full, extend it
                if (i == perk.itemIDList.Count - 1 && ID >= 0 && perk.itemIDList.Count < limit)
                {
                    perk.itemIDList.Add(-1);
                }

                //if one of the element in the list is empty, shrink it
                if (i < perk.itemIDList.Count - 1 && perk.itemIDList[i] == -1)
                {
                    perk.itemIDList.RemoveAt(i); i -= 1;
                }
            }

            return(new Vector2(startX, startY));
        }
Esempio n. 6
0
        private static void UpdateObjectHierarchyList()
        {
            List <UnitTower> towerList = EditorDBManager.GetTowerList();

            if (towerList.Count <= 0 || selectID >= towerList.Count)
            {
                return;
            }
            EditorUtilities.GetObjectHierarchyList(towerList[selectID].gameObject, SetObjListCallback);
        }
Esempio n. 7
0
        private static void UpdateObjectHierarchyList()
        {
            List <UnitCreep> creepList = EditorDBManager.GetCreepList();

            if (creepList.Count == 0 || selectID >= creepList.Count)
            {
                return;
            }
            EditorUtilities.GetObjectHierarchyList(creepList[selectID].gameObject, SetObjListCallback);
        }
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window = (DamageArmorDBEditor)EditorWindow.GetWindow(typeof(DamageArmorDBEditor));
            //~ window.minSize=new Vector2(340, 170);
            window.minSize = new Vector2(470, 300);
            //~ window.maxSize=new Vector2(471, 301);

            EditorDBManager.Init();
        }
Esempio n. 9
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window = (UnitCreepEditorWindow)EditorWindow.GetWindow(typeof(UnitCreepEditorWindow));
            //~ window.minSize=new Vector2(375, 449);
            //~ window.maxSize=new Vector2(375, 800);

            EditorDBManager.Init();

            InitLabel();
            UpdateObjectHierarchyList();
        }
Esempio n. 10
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();
        }
Esempio n. 11
0
        int GetListIDFromPerkID(int ID)
        {
            List <Perk> perkList = EditorDBManager.GetPerkList();

            for (int i = 0; i < perkList.Count; i++)
            {
                if (perkList[i].ID == ID)
                {
                    return(i);
                }
            }
            return(0);
        }
        private static void GetAbility()
        {
            EditorDBManager.Init();

            abilityList = EditorDBManager.GetAbilityList();

            if (Application.isPlaying)
            {
                return;
            }

            List <int> abilityIDList = EditorDBManager.GetAbilityIDList();

            for (int i = 0; i < instance.unavailableIDList.Count; i++)
            {
                if (!abilityIDList.Contains(instance.unavailableIDList[i]))
                {
                    instance.unavailableIDList.RemoveAt(i); i -= 1;
                }
            }
        }
Esempio n. 13
0
        private static void GetTower()
        {
            EditorDBManager.Init();

            towerList = EditorDBManager.GetTowerList();

            if (Application.isPlaying)
            {
                return;
            }

            List <int> towerIDList = EditorDBManager.GetTowerIDList();

            for (int i = 0; i < instance.availableTowerIDList.Count; i++)
            {
                if (!towerIDList.Contains(instance.availableTowerIDList[i]))
                {
                    instance.availableTowerIDList.RemoveAt(i);      i -= 1;
                }
            }
        }
Esempio n. 14
0
        private static void GetWeapon()
        {
            EditorDBManager.Init();

            weaponList = EditorDBManager.GetFPSWeaponList();

            if (Application.isPlaying)
            {
                return;
            }

            List <int> weaponIDList = EditorDBManager.GetFPSWeaponIDList();

            for (int i = 0; i < instance.unavailableIDList.Count; i++)
            {
                if (!weaponIDList.Contains(instance.unavailableIDList[i]))
                {
                    instance.unavailableIDList.RemoveAt(i); i -= 1;
                }
            }
        }
Esempio n. 15
0
 private static void GetPerk()
 {
     EditorDBManager.Init();
     perkList = EditorDBManager.GetPerkList();
 }
Esempio n. 16
0
        public static Vector3 DrawUnitOffensiveSetting(UnitTower tower, UnitCreep creep, float startX, float startY, List <GameObject> objHList, string[] objHLabelList)
        {
            float cachedX = startX;
            //float cachedY=startY;

            Unit unit = null;

            if (tower != null)
            {
                unit = tower;
            }
            if (creep != null)
            {
                unit = creep;
            }



            if (tower && TowerDealDamage(tower) || (creep && creep.type == _CreepType.Offense))
            {
                string[] damageTypeLabel = EditorDBManager.GetDamageTypeLabel();
                cont = new GUIContent("Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                unit.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.damageType, damageTypeLabel);
            }

            if (tower && TowerUseShootObject(tower) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
                shootPointFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), shootPointFoldout, cont);
                int shootPointCount = unit.shootPoints.Count;
                shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

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

                if (shootPointFoldout)
                {
                    for (int i = 0; i < unit.shootPoints.Count; i++)
                    {
                        int objID = GetObjectIDFromHList(unit.shootPoints[i], objHList);
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                        objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                        unit.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                    }
                }

                if (unit.shootPoints.Count > 1)
                {
                    cont = new GUIContent("Shots delay Between ShootPoint:", "Delay in second between shot fired at each shootPoint. When set to zero all shootPoint fire simulteneously");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 60, height), cont);
                    unit.delayBetweenShootPoint = EditorGUI.FloatField(new Rect(startX + spaceX + 90, startY - 1, 55, height - 1), unit.delayBetweenShootPoint);
                }
            }


            if (tower && TowerUseTurret(tower) || (creep && creep.type == _CreepType.Offense))
            {
                int objID = GetObjectIDFromHList(unit.turretObject, objHList);
                cont = new GUIContent("TurretObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). When left unassigned, no aiming will be done.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.turretObject = (objHList[objID] == null) ? null : objHList[objID].transform;

                objID = GetObjectIDFromHList(unit.barrelObject, objHList);
                cont  = new GUIContent("BarrelObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). This is only required if the unit barrel and turret rotates independently on different axis");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.barrelObject = (objHList[objID] == null) ? null : objHList[objID].transform;

                cont = new GUIContent("Aim Rotate In x-axis:", "Check if the unit turret/barrel can rotate in x-axis (elevation)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.rotateTurretAimInXAxis = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, 40, height), unit.rotateTurretAimInXAxis);
            }


            if (tower && TowerTargetHostile(tower) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("Directional Targeting:", "Check if the unit should only target hostile unit from a fixed direction");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                unit.directionalTargeting = EditorGUI.Toggle(new Rect(startX + spaceX + 20, startY, 40, height), unit.directionalTargeting);

                if (unit.directionalTargeting)
                {
                    startX += spaceX + 50;

                    cont = new GUIContent("- FOV:", "Field-Of-View of the directional targeting");
                    EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                    unit.dirScanFOV = EditorGUI.FloatField(new Rect(startX + 60, startY, 40, height), unit.dirScanFOV);

                    if (tower != null)
                    {
                        cont = new GUIContent("- Angle:", "The y-axis angle in clock-wise (from transform local space) which the directional targeting will be aim towards\n0: +ve z-axis\n90: +ve x-axis\n180: -ve z-axis\n270: -ve x-axis");
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                        unit.dirScanAngle = EditorGUI.FloatField(new Rect(startX + 60, startY, 40, height), unit.dirScanAngle);
                    }
                }
            }

            return(new Vector3(cachedX, startY, spaceX + width));
        }
Esempio n. 17
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;

            startY += 20;
            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)
            {
                EditorUtilities.DrawSprite(new Rect(startX + 25, startY += spaceY - 2, 20, 20), EditorDBManager.iconRsc);     startY += 2;
                EditorGUI.LabelField(new Rect(startX, startY, width, height), "    -       min/max");
                creep.valueRscMin = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), creep.valueRscMin);
                creep.valueRscMax = EditorGUI.IntField(new Rect(startX + spaceX + 40, startY, 40, height), creep.valueRscMax);

                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;
            }

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

            if (ani == null)
            {
                if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Add animation component"))
                {
                    ani = creep.gameObject.AddComponent <UnitCreepAnimation>();
                }
            }

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

                startY += 5;

                type  = (int)ani.type;
                cont  = new GUIContent("Type:", "Type of the animation to use");
                contL = new GUIContent[animationTypeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(animationTypeLabel[i], animationTypeTooltip[i]);
                }
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                type     = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), type, contL);
                ani.type = (UnitCreepAnimation._AniType)type;

                if (ani.type == UnitCreepAnimation._AniType.Legacy)
                {
                    int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList);
                    cont = new GUIContent("AnimationRootObj:", "The gameObject that contains the Animation component that runs the animation on the unit");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    objID          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                    ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID];


                    cont = new GUIContent("Move Speed Multiplier:", "The multiplier used to match the move animation speed to the unit's move speed");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.moveSpeedMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX + 30, startY, 40, height), ani.moveSpeedMultiplier);
                }
                else if (ani.type == UnitCreepAnimation._AniType.Mecanim)
                {
                    int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList);
                    cont = new GUIContent("Animator RootObj:", "The gameObject that contains the Animator component that control the animation on the unit");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    objID          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                    ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID];
                }

                if (ani.type != UnitCreepAnimation._AniType.None)
                {
                    cont = new GUIContent("Spawn Clip:", "The animation clip to be played when the creep is destroyed");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipSpawn = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipSpawn, typeof(AnimationClip), false);

                    cont = new GUIContent("Move Clip:", "The animation clip to be played when the creep is moving");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipMove = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipMove, typeof(AnimationClip), false);

                    cont = new GUIContent("Dead Clip:", "The animation clip to be played when the creep is destroyed");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipDead = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDead, typeof(AnimationClip), false);

                    cont = new GUIContent("Destination Clip:", "The animation clip to be played when the creep reach its destination");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipDestination = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDestination, typeof(AnimationClip), false);
                }
            }



            return(new Vector3(startX, startY, maxWidth));
        }
Esempio n. 18
0
        Vector2 DrawUnitList(float startX, float startY, List <UnitCreep> creepList)
        {
            float width = 260;

            if (minimiseList)
            {
                width = 60;
            }


            if (!minimiseList)
            {
                if (GUI.Button(new Rect(startX + 180, startY - 20, 40, 18), "up"))
                {
                    if (selectID > 0)
                    {
                        UnitCreep creep = creepList[selectID];
                        creepList[selectID]     = creepList[selectID - 1];
                        creepList[selectID - 1] = creep;
                        selectID -= 1;

                        if (selectID * 35 < scrollPos1.y)
                        {
                            scrollPos1.y = selectID * 35;
                        }
                    }
                }
                if (GUI.Button(new Rect(startX + 222, startY - 20, 40, 18), "down"))
                {
                    if (selectID < creepList.Count - 1)
                    {
                        UnitCreep creep = creepList[selectID];
                        creepList[selectID]     = creepList[selectID + 1];
                        creepList[selectID + 1] = creep;
                        selectID += 1;

                        if (listVisibleRect.height - 35 < selectID * 35)
                        {
                            scrollPos1.y = (selectID + 1) * 35 - listVisibleRect.height + 5;
                        }
                    }
                }
            }


            listVisibleRect = new Rect(startX, startY, width + 15, window.position.height - startY - 5);
            listContentRect = new Rect(startX, startY, width, creepList.Count * 40);

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

            scrollPos1 = GUI.BeginScrollView(listVisibleRect, scrollPos1, listContentRect);


            startY += 5;      startX += 5;

            for (int i = 0; i < creepList.Count; i++)
            {
                EditorUtilities.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), creepList[i].iconSprite);

                if (minimiseList)
                {
                    if (selectID == i)
                    {
                        GUI.color = new Color(0, 1f, 1f, 1f);
                    }
                    if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 30, 30), ""))
                    {
                        SelectCreep(i);
                    }
                    GUI.color = Color.white;

                    continue;
                }



                if (selectID == i)
                {
                    GUI.color = new Color(0, 1f, 1f, 1f);
                }
                if (GUI.Button(new Rect(startX + 35, startY + (i * 35), 150, 30), creepList[i].unitName))
                {
                    SelectCreep(i);
                }
                GUI.color = Color.white;

                if (deleteID == i)
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "cancel"))
                    {
                        deleteID = -1;
                    }

                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35) + 15, 60, 15), "confirm"))
                    {
                        if (selectID >= deleteID)
                        {
                            SelectCreep(Mathf.Max(0, selectID - 1));
                        }
                        EditorDBManager.RemoveCreep(deleteID);
                        deleteID = -1;
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    if (GUI.Button(new Rect(startX + 190, startY + (i * 35), 60, 15), "remove"))
                    {
                        deleteID = i;
                    }
                }
            }

            GUI.EndScrollView();

            return(new Vector2(startX + width, startY));
        }
Esempio n. 19
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, startY, 220, statContentHeight - startY), "");

            startX += 10;     startY += 10;

            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 && TowerUseShootObject(tower)) || (creep && creep.type == _CreepType.Offense))
            {
                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, 4 * fWidth - 20, height), stat.shootObject, typeof(ShootObject), false);
                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("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.range = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.range);

                //~ 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.range = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.range);
                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 + 5;

            return(new Vector3(startX + 220, startY, statContentHeight));
        }
Esempio n. 20
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            List <UnitCreep> creepList = EditorDBManager.GetCreepList();

            if (GUI.Button(new Rect(window.position.width - 120, 5, 100, 25), "Save"))
            {
                EditorDBManager.SetDirtyCreep();
            }

            EditorGUI.LabelField(new Rect(5, 7, 150, 17), "Add new creep:");
            UnitCreep newCreep = null;

            newCreep = (UnitCreep)EditorGUI.ObjectField(new Rect(100, 7, 140, 17), newCreep, typeof(UnitCreep), false);
            if (newCreep != null)
            {
                int newSelectID = EditorDBManager.AddNewCreep(newCreep);
                if (newSelectID != -1)
                {
                    SelectCreep(newSelectID);
                }
            }


            float startX = 5;
            float startY = 50;        float cachedY = 50;

            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 = DrawUnitList(startX, startY, creepList);     startX = v2.x + 25;

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

            cont = new GUIContent("Creep Prefab:", "The prefab object of the creep\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            EditorGUI.ObjectField(new Rect(startX + 90, startY, 185, height), creepList[selectID].gameObject, typeof(GameObject), false);
            startY += spaceY + 10;


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

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

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

            UnitCreep creep = creepList[selectID];

            v3            = DrawUnitConfigurator(startX, startY, creepList, creep.type == _CreepType.Offense);
            contentWidth  = v3.z;
            contentHeight = v3.y;

            startX += spaceX + width + 45;
            startY += 75;

            if (creep.type != _CreepType.Default)
            {
                v3 = DrawStat(creep.stats[0], startX, startY, statContentHeight, creepList[selectID]);
                statContentHeight = v3.z;
                if (contentHeight < v3.y)
                {
                    contentHeight = v3.y;
                }
                if (contentWidth < 530)
                {
                    contentWidth = 530;
                }
            }

            contentHeight -= cachedY;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                EditorDBManager.SetDirtyCreep();
            }
        }
Esempio n. 21
0
        public static Vector3 DrawUnitOffensiveSetting(UnitTower tower, UnitCreep creep, float startX, float startY, List <GameObject> objHList, string[] objHLabelList)
        {
            float cachedX = startX;

            Unit unit = null;

            if (tower != null)
            {
                unit = tower;
            }
            if (creep != null)
            {
                unit = creep;
            }



            if (tower && TowerDealDamage(tower) || (creep && creep.type == _CreepType.Offense))
            {
                string[] damageTypeLabel = EditorDBManager.GetDamageTypeLabel();
                cont = new GUIContent("Damage Type:", "The damage type of the unit\nDamage type can be configured in Damage Armor Table Editor");
                EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                unit.damageType = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unit.damageType, damageTypeLabel);
            }

            if (tower && TowerUseShootObject(tower) || (creep && creep.type == _CreepType.Offense))
            {
                cont = new GUIContent("ShootPoint:", "The transform which indicate the position where the shootObject will be fired from (Optional)\nEach shootPoint assigned will fire a shootObject instance in each attack\nIf left empty, the unit transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the shootObject starting orientation.\n");
                shootPointFoldout = EditorGUI.Foldout(new Rect(startX, startY += spaceY, spaceX, height), shootPointFoldout, cont);
                int shootPointCount = unit.shootPoints.Count;
                shootPointCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

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

                if (shootPointFoldout)
                {
                    for (int i = 0; i < unit.shootPoints.Count; i++)
                    {
                        int objID = GetObjectIDFromHList(unit.shootPoints[i], objHList);
                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "    - Element " + (i + 1));
                        objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                        unit.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform;
                    }
                }

                if (unit.shootPoints.Count > 1)
                {
                    cont = new GUIContent("Shots delay Between ShootPoint:", "Delay in second between shot fired at each shootPoint. When set to zero all shootPoint fire simulteneously");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width + 60, height), cont);
                    unit.delayBetweenShootPoint = EditorGUI.FloatField(new Rect(startX + spaceX + 90, startY - 1, 55, height - 1), unit.delayBetweenShootPoint);
                }
            }


            if (tower && TowerUseTurret(tower) || (creep && creep.type == _CreepType.Offense))
            {
                int objID = GetObjectIDFromHList(unit.turretObject, objHList);
                cont = new GUIContent("TurretObject:", "The object under unit's hierarchy which is used to aim toward target (Optional). When left unassigned, no aiming will be done.");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                objID             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                unit.turretObject = (objHList[objID] == null) ? null : objHList[objID].transform;
            }

            return(new Vector3(cachedX, startY, spaceX + width));
        }
        Vector2 DrawUnitConfigurator(float startX, float startY, List <UnitTower> towerList)
        {
            float maxWidth = 0;

            UnitTower tower = towerList[selectID];


            float cachedY = startY;
            float cachedX = startX;

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

            int type = (int)tower.type;

            cont = new GUIContent("Tower Type:", "Type of the tower. Each type of tower serve a different function");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            contL = new GUIContent[towerTypeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(towerTypeLabel[i], towerTypeTooltip[i]);
            }
            type       = EditorGUI.Popup(new Rect(startX + 80, startY, width - 40, 15), new GUIContent(""), type, contL);
            tower.type = (_TowerType)type;
            startX     = cachedX;

            v3 = DrawIconAndName(tower, startX, startY);      startY = v3.y;


            startX = cachedX;
            spaceX = 110;

            cachedY = startY;
            v3      = DrawUnitDefensiveSetting(tower, startX, startY, objHList, objHLabelList);         //startY=v3.y;


            if (startX + spaceX + width > maxWidth)
            {
                maxWidth = startX + spaceX + width;
            }


            startY  = cachedY;
            startX += spaceX + width + 35;



            if (TowerDealDamage(tower))
            {
                int targetMode = (int)tower.targetMode;
                cont = new GUIContent("Target Mode:", "Determine which type of unit the tower can target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                contL = new GUIContent[targetModeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(targetModeLabel[i], targetModeTooltip[i]);
                }
                targetMode       = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), new GUIContent(""), targetMode, contL);
                tower.targetMode = (_TargetMode)targetMode;
                startY          += spaceY;
            }

            v3 = DrawUnitOffensiveSetting(tower, startX, startY, objHList, objHLabelList);            startY = v3.y + spaceY;


            if (startX + spaceX + width > maxWidth)
            {
                maxWidth = startX + spaceX + width;
            }



            string[]         weaponNameList = EditorDBManager.GetFPSWeaponNameList();
            List <FPSWeapon> weaponList     = EditorDBManager.GetFPSWeaponList();
            int weaponID = 0;

            if (tower.FPSWeaponID != -1)
            {
                for (int i = 0; i < weaponList.Count; i++)
                {
                    if (weaponList[i].prefabID == tower.FPSWeaponID)
                    {
                        weaponID = i + 1; break;
                    }
                }
            }
            cont = new GUIContent("FPS Weapon:", "Weapon tied to this tower when using FPS mode");
            GUI.Label(new Rect(startX, startY, 120, height), cont);
            weaponID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), weaponID, weaponNameList);
            if (weaponID == 0)
            {
                tower.FPSWeaponID = -1;
            }
            else
            {
                tower.FPSWeaponID = weaponList[weaponID - 1].prefabID;
            }



            //if(startY>maxHeight) maxHeight=startY;
            float maxY = startY;

            startY = 300;

            startX = cachedX; cachedY = startY;


            cont = new GUIContent("Building Effect:", "The effect object to be spawned when the tower start a building process\nThis is entirely optional");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            tower.buildingEffect = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.buildingEffect, typeof(GameObject), false);
            startY += 20;
            cont    = new GUIContent("Built Effect:", "The effect object to be spawned when the tower has finish a build process\nThis is entirely optional");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            tower.builtEffect = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), tower.builtEffect, typeof(GameObject), false);
            startY           += 40;



            string[] towerNameList = EditorDBManager.GetTowerNameList();

            cont = new GUIContent("Prev lvl Tower:", "Tower prefab which this current selected tower is upgrade from. If blank then this is the base tower (level 1). ");
            GUI.Label(new Rect(startX, startY, 120, height), cont);
            int ID = -1;

            for (int i = 0; i < towerList.Count; i++)
            {
                if (towerList[i] == tower.prevLevelTower)
                {
                    ID = i + 1;
                }
            }
            ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, 105, height), ID, towerNameList);
            if (GUI.Button(new Rect(startX + 215, startY, 48, 15), "Select"))
            {
                if (tower.prevLevelTower != null)
                {
                    SelectTower(ID - 1);
                }
            }


            cont = new GUIContent("lvl within Prefab:", "");
            GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
            if (GUI.Button(new Rect(startX + spaceX, startY, 50, 15), "-1"))
            {
                if (tower.stats.Count > 1)
                {
                    tower.stats.RemoveAt(tower.stats.Count - 1);
                }
            }
            if (GUI.Button(new Rect(startX + 165, startY, 50, 15), "+1"))
            {
                tower.stats.Add(tower.stats[tower.stats.Count - 1].Clone());
            }

            if (tower.nextLevelTowerList.Count == 0)
            {
                tower.nextLevelTowerList.Add(null);
            }

            cont = new GUIContent("Next lvl Tower 1:", "Tower prefab to be used beyond the stats level specified for this prefab");
            GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
            ID = -1;
            for (int i = 0; i < towerList.Count; i++)
            {
                if (towerList[i] == tower.nextLevelTowerList[0])
                {
                    ID = i + 1;
                }
            }
            ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, 105, height), ID, towerNameList);
            if (ID > 0 && towerList[ID - 1] != tower)
            {
                if (tower.nextLevelTowerList[0] != null)
                {
                    tower.nextLevelTowerList[0].prevLevelTower = null;
                }

                tower.nextLevelTowerList[0]      = towerList[ID - 1];
                towerList[ID - 1].prevLevelTower = tower;
            }
            else if (ID == 0)
            {
                tower.nextLevelTowerList[0] = null;
            }
            if (GUI.Button(new Rect(startX + 215, startY, 48, 15), "Select"))
            {
                if (tower.nextLevelTowerList[0] != null)
                {
                    SelectTower(ID - 1);
                }
            }

            if (tower.nextLevelTowerList[0] == null)
            {
                if (tower.nextLevelTowerList.Count > 1 && tower.nextLevelTowerList[1] != null)
                {
                    tower.nextLevelTowerList[0] = tower.nextLevelTowerList[1];
                    tower.nextLevelTowerList.RemoveAt(1);
                }
            }

            if (tower.nextLevelTowerList[0] != null)
            {
                if (tower.nextLevelTowerList.Count < 2)
                {
                    tower.nextLevelTowerList.Add(null);
                }

                //startX+=295;
                cont = new GUIContent("Next lvl Tower 2:", "Tower prefab to be used beyond the stats level specified for this prefab");
                GUI.Label(new Rect(startX, startY += spaceY, 120, height), cont);
                ID = -1;
                for (int i = 0; i < towerList.Count; i++)
                {
                    if (towerList[i] == tower.nextLevelTowerList[1])
                    {
                        ID = i + 1;
                    }
                }
                ID = EditorGUI.Popup(new Rect(startX + spaceX, startY, 105, height), ID, towerNameList);
                if (ID > 0 && towerList[ID - 1] != tower && !tower.nextLevelTowerList.Contains(towerList[ID - 1]))
                {
                    if (tower.nextLevelTowerList[1] != null)
                    {
                        tower.nextLevelTowerList[1].prevLevelTower = null;
                    }

                    tower.nextLevelTowerList[1]      = towerList[ID - 1];
                    towerList[ID - 1].prevLevelTower = tower;
                }
                else if (ID == 0)
                {
                    tower.nextLevelTowerList[1] = null;
                }
                if (GUI.Button(new Rect(startX + 215, startY, 48, 15), "Select"))
                {
                    if (tower.nextLevelTowerList[1] != null)
                    {
                        SelectTower(ID - 1);
                    }
                }

                //GUI.Label(new Rect(startX+270, startY, 200, height), "(for alternate upgrade path)");
                //startX=cachedX;
            }



            startY = Mathf.Max(maxY + 20, 460);
            startX = cachedX;

            float maxHeight        = 0;
            float maxContentHeight = 0;

            minimiseStat = EditorGUI.Foldout(new Rect(startX, startY, width, height), minimiseStat, "Show Stats");
            if (!minimiseStat)
            {
                startY += spaceY;
                startX += 15;

                int lvl = GetStatsLevelStartOffset(tower);

                if (tower.stats.Count == 0)
                {
                    tower.stats.Add(new UnitStat());
                }
                for (int i = 0; i < tower.stats.Count; i++)
                {
                    EditorGUI.LabelField(new Rect(startX, startY, width, height), "Level " + (lvl + i + 1) + " Stats");
                    v3 = DrawStat(tower.stats[i], startX, startY + spaceY, statContentHeight, tower);
                    if (maxContentHeight < v3.z)
                    {
                        maxContentHeight = v3.z;
                    }
                    //statContentHeight=v3.z;
                    startX = v3.x + 10;
                    if (startX > maxWidth)
                    {
                        maxWidth = startX;
                    }
                    if (maxHeight < v3.y)
                    {
                        maxHeight = v3.y;
                    }
                }
                statContentHeight = maxContentHeight;
                startY            = maxHeight;
            }

            startX  = cachedX;
            startY += spaceY;


            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Unit general description (to be used in runtime): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            tower.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 530, 50), tower.desp, style);

            startX = maxWidth - cachedX + 80;

            return(new Vector2(startX, startY));
        }
Esempio n. 23
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            List <UnitTower> towerList = EditorDBManager.GetTowerList();

            if (GUI.Button(new Rect(window.position.width - 120, 5, 100, 25), "Save"))
            {
                EditorDBManager.SetDirtyTower();
            }

            EditorGUI.LabelField(new Rect(5, 7, 150, 17), "Add new tower:");
            UnitTower newTower = null;

            newTower = (UnitTower)EditorGUI.ObjectField(new Rect(100, 7, 140, 17), newTower, typeof(UnitTower), false);
            if (newTower != null)
            {
                int newSelectID = EditorDBManager.AddNewTower(newTower);
                if (newSelectID != -1)
                {
                    SelectTower(newSelectID);
                }
            }


            float startX = 5;
            float startY = 50;

            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 = DrawUnitList(startX, startY, towerList);

            startX = v2.x + 25;

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

            selectID = Mathf.Clamp(selectID, 0, towerList.Count - 1);

            cont = new GUIContent("Tower Prefab:", "The prefab object of the tower\nClick this to highlight it in the ProjectTab");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
            EditorGUI.ObjectField(new Rect(startX + 90, startY, 185, height), towerList[selectID].gameObject, typeof(GameObject), false);

            cont = new GUIContent("Disable in BuildManager:", "When checked, tower won't appear on BuildManager list and thus can't be built\nThis is to mark towers that can only be upgrade from a built tower or unlock from perk");
            EditorGUI.LabelField(new Rect(startX + 295, startY, width, height), cont);
            towerList[selectID].disableInBuildManager = EditorGUI.Toggle(new Rect(startX + 440, startY, 185, height), towerList[selectID].disableInBuildManager);

            startY += spaceY + 10;


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

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

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

            v2            = DrawUnitConfigurator(startX, startY, towerList);
            contentWidth  = v2.x;
            contentHeight = v2.y;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                EditorDBManager.SetDirtyTower();
            }
        }
Esempio n. 24
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();
            }
        }
Esempio n. 25
0
        Vector3 DrawUnitConfigurator(float startX, float startY, List <UnitCreep> creepList)
        {
            UnitCreep creep = creepList[selectID];

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

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

            startX = cachedX;

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

            cachedY = startY;

            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("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 + 5, width + 150, height), cont);
            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;


            startY = cachedY + spaceY;  startX += 300;


            //~ 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;

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

            if (ani == null)
            {
                if (GUI.Button(new Rect(startX, startY, width + 50, height + 2), "Add animation component"))
                {
                    ani = creep.gameObject.AddComponent <UnitCreepAnimation>();
                }
            }

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

                startY += 5;

                int type = (int)ani.type;
                cont  = new GUIContent("Type:", "Type of the animation to use");
                contL = new GUIContent[animationTypeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(animationTypeLabel[i], animationTypeTooltip[i]);
                }
                //cont=new GUIContent("AnimationRootObj:", "The gameObject that contains the Animation component that runs the animation on the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                type     = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), type, contL);
                ani.type = (UnitCreepAnimation._AniType)type;

                if (ani.type == UnitCreepAnimation._AniType.Legacy)
                {
                    int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList);
                    cont = new GUIContent("AnimationRootObj:", "The gameObject that contains the Animation component that runs the animation on the unit");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    objID          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                    ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID];


                    cont = new GUIContent("Move Speed Multiplier:", "The multiplier used to match the move animation speed to the unit's move speed");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.moveSpeedMultiplier = EditorGUI.FloatField(new Rect(startX + spaceX + 30, startY, 40, height), ani.moveSpeedMultiplier);
                }
                else if (ani.type == UnitCreepAnimation._AniType.Mecanim)
                {
                    int objID = GetObjectIDFromHList(ani.aniRootObj != null ? ani.aniRootObj.transform : null, objHList);
                    cont = new GUIContent("Animator RootObj:", "The gameObject that contains the Animator component that control the animation on the unit");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    objID          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                    ani.aniRootObj = (objHList[objID] == null) ? null : objHList[objID];

                    //~ cont=new GUIContent("Dead Clip:", "The animation clip played by the animator when the creep is destroyed. This is required to know the duration of the animation");
                    //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                    //~ ani.clipDead=(AnimationClip)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), ani.clipDead, typeof(AnimationClip), false);

                    //~ cont=new GUIContent("Destination Clip:", "The animation clip played by the animator when the creep reach its destination. This is required to know the duration of the animation");
                    //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                    //~ ani.clipDestination=(AnimationClip)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), ani.clipDestination, typeof(AnimationClip), false);
                }

                if (ani.type != UnitCreepAnimation._AniType.None)
                {
                    cont = new GUIContent("Spawn Clip:", "The animation clip to be played when the creep is destroyed");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipSpawn = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipSpawn, typeof(AnimationClip), false);

                    cont = new GUIContent("Move Clip:", "The animation clip to be played when the creep is moving");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipMove = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipMove, typeof(AnimationClip), false);

                    cont = new GUIContent("Dead Clip:", "The animation clip to be played when the creep is destroyed");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipDead = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDead, typeof(AnimationClip), false);

                    cont = new GUIContent("Destination Clip:", "The animation clip to be played when the creep reach its destination");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    ani.clipDestination = (AnimationClip)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), ani.clipDestination, typeof(AnimationClip), false);
                }
            }



            //GUI.Box(new Rect(cachedX, cachedY, maxWidth, 10), "");

            return(new Vector3(startX, startY, maxWidth));
        }
Esempio n. 26
0
 int GetPerkIDFromListID(int ID)
 {
     return(EditorDBManager.GetPerkList()[ID].ID);
 }
Esempio n. 27
0
        public override void OnInspectorGUI()
        {
            cont = new GUIContent("Assign Item Manually:", "Check to manually assign the item and their associate perk");
            instance.assignItemManually = EditorGUILayout.Toggle(cont, instance.assignItemManually);

            if (instance.assignItemManually)
            {
                GUILayout.BeginHorizontal();
                //EditorGUILayout.Space();
                if (GUILayout.Button("Add Item", GUILayout.MaxWidth(120)))
                {
                    //AddItem();
                    instance.itemList.Add(new UIPerkMenu.PerkItem());
                }
                if (GUILayout.Button("Reduce Item", GUILayout.MaxWidth(120)))
                {
                    //RemoveItem();
                    instance.itemList.RemoveAt(instance.itemList.Count - 1);
                }
                GUILayout.EndHorizontal();

                EditorGUILayout.Space();

                string[]    perkNameList = EditorDBManager.GetPerkNameList();
                List <Perk> perkList     = EditorDBManager.GetPerkList();
                int[]       intList      = new int[perkNameList.Length];
                for (int i = 0; i < perkNameList.Length; i++)
                {
                    if (i == 0)
                    {
                        intList[i] = -1;
                    }
                    else
                    {
                        intList[i] = perkList[i - 1].ID;
                    }
                }

                for (int i = 0; i < instance.itemList.Count; i++)
                {
                    GUILayout.BeginHorizontal();

                    GUILayout.Label(" - Element " + (i + 1), GUILayout.Width(75));

                    instance.itemList[i].button.rootObj = (GameObject)EditorGUILayout.ObjectField(instance.itemList[i].button.rootObj, typeof(GameObject), true);

                    //~ if(GUILayout.Button("+", GUILayout.MaxWidth(20))){
                    //~ InsertWaypoints(i);
                    //~ }
                    //~ if(GUILayout.Button("-", GUILayout.MaxWidth(20))){
                    //~ i-=RemoveWaypoints(i);
                    //~ }
                    GUILayout.EndHorizontal();


                    GUILayout.BeginHorizontal();
                    GUILayout.Label("    Link   ", GUILayout.Width(75));
                    instance.itemList[i].linkObj = (GameObject)EditorGUILayout.ObjectField(instance.itemList[i].linkObj, typeof(GameObject), true);
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                    GUILayout.Label("    Label:   ", GUILayout.Width(75));
                    instance.itemList[i].perkID = EditorGUILayout.IntPopup(instance.itemList[i].perkID, perkNameList, intList);
                    GUILayout.EndHorizontal();

                    EditorGUILayout.Space();
                }
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }


            int startX = 0;
            int startY = 0;

            if (GUI.Button(new Rect(10, 10, 100, 30), "New Armor"))
            {
                EditorDBManager.AddNewArmorType();
            }
            if (GUI.Button(new Rect(120, 10, 100, 30), "New Damage"))
            {
                EditorDBManager.AddNewDamageType();
            }


            List <DamageType> damageTypeList = EditorDBManager.GetDamageTypeList();
            List <ArmorType>  armorTypeList  = EditorDBManager.GetArmorTypeList();


            Rect visibleRect = new Rect(10, 50, window.position.width - 20, 185);
            Rect contentRect = new Rect(10, 50, 118 + damageTypeList.Count * 105, 5 + (armorTypeList.Count + 1) * 25);

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

            startY = 60;
            startX = 20;
            for (int i = 0; i < damageTypeList.Count; i++)
            {
                DamageType dmgType = damageTypeList[i];
                if (selectedID == i && tab == _Tab.Damage)
                {
                    GUI.color = new Color(0, 1, 1, 1);
                }
                if (GUI.Button(new Rect(startX += 105, startY, 100, 20), dmgType.name))
                {
                    selectedID = i;   tab = _Tab.Damage;
                    delete     = false;
                    GUI.FocusControl("");
                }
                GUI.color = Color.white;
            }



            startY = 60;
            for (int i = 0; i < armorTypeList.Count; i++)
            {
                startX = 20;

                ArmorType armorType = armorTypeList[i];
                if (selectedID == i && tab == _Tab.Armor)
                {
                    GUI.color = new Color(0, 1, 1, 1);
                }
                if (GUI.Button(new Rect(startX, startY += 25, 100, 20), armorType.name))
                {
                    selectedID = i;   tab = _Tab.Armor;
                    delete     = false;
                    GUI.FocusControl("");
                }
                GUI.color = Color.white;

                if (armorType.modifiers.Count != damageTypeList.Count)
                {
                    while (armorType.modifiers.Count < damageTypeList.Count)
                    {
                        armorType.modifiers.Add(1);
                    }
                    while (armorType.modifiers.Count > damageTypeList.Count)
                    {
                        armorType.modifiers.RemoveAt(armorType.modifiers.Count - 1);
                    }
                    EditorDBManager.SetDirtyDamageArmor();
                }

                startX += 110;
                for (int j = 0; j < damageTypeList.Count; j++)
                {
                    armorType.modifiers[j] = EditorGUI.FloatField(new Rect(startX, startY, 90, 20), armorType.modifiers[j]);
                    startX += 105;
                }
            }



            GUI.EndScrollView();



            startX = 10;
            startY = 250;



            if (selectedID >= 0)
            {
                DAType daInstance = null;
                if (tab == _Tab.Damage)
                {
                    selectedID = Mathf.Min(selectedID, damageTypeList.Count - 1);
                    daInstance = damageTypeList[selectedID];
                }
                if (tab == _Tab.Armor)
                {
                    selectedID = Mathf.Min(selectedID, armorTypeList.Count - 1);
                    daInstance = armorTypeList[selectedID];
                }

                GUI.Label(new Rect(startX, startY, 200, 17), "Name:");
                daInstance.name = EditorGUI.TextField(new Rect(startX + 80, startY, 150, 17), daInstance.name);


                GUIStyle styleL = new GUIStyle(GUI.skin.textArea);
                styleL.wordWrap  = true;
                styleL.clipping  = TextClipping.Clip;
                styleL.alignment = TextAnchor.UpperLeft;
                EditorGUI.LabelField(new Rect(startX, startY += 25, 150, 17), "Description: ");
                daInstance.desp = EditorGUI.TextArea(new Rect(startX, startY += 17, window.position.width - 20, 50), daInstance.desp, styleL);


                string label = "";
                if (tab == _Tab.Damage)
                {
                    for (int i = 0; i < armorTypeList.Count; i++)
                    {
                        label += " - cause " + (armorTypeList[i].modifiers[selectedID] * 100).ToString("f0") + "% damage to " + armorTypeList[i].name + "\n";
                    }
                }
                if (tab == _Tab.Armor)
                {
                    for (int i = 0; i < damageTypeList.Count; i++)
                    {
                        label += " - take " + (armorTypeList[selectedID].modifiers[i] * 100).ToString("f0") + "% damage from " + damageTypeList[i].name + "\n";
                    }
                }
                GUI.Label(new Rect(startX, startY += 60, window.position.width - 20, 100), label);


                startX = 300;
                startY = 250;
                if (!delete)
                {
                    if (GUI.Button(new Rect(startX, startY, 80, 20), "delete"))
                    {
                        delete = true;
                    }
                }
                else if (delete)
                {
                    if (GUI.Button(new Rect(startX, startY, 80, 20), "cancel"))
                    {
                        delete = false;
                    }
                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX += 90, startY, 80, 20), "confirm"))
                    {
                        if (tab == _Tab.Damage)
                        {
                            EditorDBManager.RemoveDamageType(selectedID);
                        }
                        if (tab == _Tab.Armor)
                        {
                            EditorDBManager.RemoveArmorType(selectedID);
                        }
                        selectedID = -1;
                    }
                    GUI.color = Color.white;
                }
            }



            if (GUI.changed)
            {
                EditorDBManager.SetDirtyDamageArmor();
            }
        }
Esempio n. 29
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, startY, 220, statContentHeight - startY), "");

            startX += 10;     startY += 10;

            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 && TowerUseShootObject(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.shootObject = (ShootObject)EditorGUI.ObjectField(new Rect(startX + spaceX - 50, startY, 4 * fWidth - 20, height), stat.shootObject, typeof(ShootObject), false);
                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)))
            {
                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("Clip Size:", "The amount of attack the unit can do before the unit needs to reload\nWhen set to <0 the unit will never need any reload");
                 * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                 * stat.clipSize=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.clipSize);
                 * stat.clipSize=Mathf.Round(stat.clipSize);
                 *
                 *
                 * cont=new GUIContent("Reload Duration:", "");
                 * EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                 * stat.reloadDuration=EditorGUI.FloatField(new Rect(startX+spaceX, startY, fWidth, height), stat.reloadDuration);
                 */


                cont = new GUIContent("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.range = EditorGUI.FloatField(new Rect(startX + spaceX, 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("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);
            }



            if ((tower && tower.type == _TowerType.Support))
            {
                cont = new GUIContent("Range:", "Effect range of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                stat.range = EditorGUI.FloatField(new Rect(startX + spaceX, startY, fWidth, height), stat.range);
                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("        - 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)
            {
                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;
                    //~ cont=new GUIContent("Description(to be used in runtime): ", "");
                    //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, 200, 20), cont);
                    stat.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 200, 90), stat.desp, style);
                    startY   += 90;
                }
            }



            statContentHeight = startY + spaceY + 5;

            return(new Vector3(startX + 220, startY, statContentHeight));
        }
Esempio n. 30
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            List <Perk> perkList = EditorDBManager.GetPerkList();

            if (GUI.Button(new Rect(window.position.width - 120, 5, 100, 25), "Save"))
            {
                EditorDBManager.SetDirtyPerk();
            }


            if (GUI.Button(new Rect(5, 5, 120, 25), "Create New"))
            {
                int newSelectID = EditorDBManager.AddNewPerk();
                if (newSelectID != -1)
                {
                    SelectPerk(newSelectID);
                }
            }
            if (perkList.Count > 0 && GUI.Button(new Rect(130, 5, 100, 25), "Clone Selected"))
            {
                int newSelectID = EditorDBManager.ClonePerk(selectID);
                if (newSelectID != -1)
                {
                    SelectPerk(newSelectID);
                }
            }


            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 = DrawPerkList(startX, startY, perkList);

            startX = v2.x + 25;

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


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

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

            //float cachedX=startX;
            v2            = DrawPerkConfigurator(startX, startY, perkList[selectID]);
            contentWidth  = v2.x + 50;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                EditorDBManager.SetDirtyPerk();
            }
        }