Esempio n. 1
0
        private static List <UnitTower> filterTowers()
        {
            List <UnitTower> towerList    = EditorDBManager.GetTowerList();
            List <UnitTower> filteredList = null;

            if (filter == Filter.All)
            {
                filteredList = towerList;
            }
            else
            {
                filteredList = new List <UnitTower>();
                foreach (UnitTower ut in towerList)
                {
                    if (filter == Filter.Defender && ut.IsDefender())
                    {
                        filteredList.Add(ut);
                    }
                    else if (filter == Filter.Tower && (ut.IsTower() || ut.IsCreep()))
                    {
                        filteredList.Add(ut);
                    }
                    else if (filter == Filter.Hero && ut.IsHero())
                    {
                        filteredList.Add(ut);
                    }
                }
            }

            return(filteredList);
        }
Esempio n. 2
0
        void Awake()
        {
            instance = (UIPerkMenu)target;

            EditorDBManager.Init();

            EditorUtility.SetDirty(instance);
        }
Esempio n. 3
0
        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("Multi Shot:", "Check if the unit is Multi Shot");
            //EditorGUI.LabelField(new Rect(startX+ spaceX+30, startY, width, height), cont);
            //unit.multishot = EditorGUI.Toggle(new Rect(startX +width+ spaceX-100, startY, 40, height), unit.multishot);

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

            //if (unit.multishot)
            //{
            //    cont = new GUIContent("Shot Delay:", "Shot Delay");
            //    EditorGUI.LabelField(new Rect(startX + spaceX + 30, startY, width, height), cont);
            //    unit.multishot_delay = EditorGUI.FloatField(new Rect(startX + width + spaceX - 100, startY, 40, height), unit.multishot_delay);
            //}

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

            //if (unit.multishot)
            //{
            //    cont = new GUIContent("Max target:", "Max target");
            //    EditorGUI.LabelField(new Rect(startX + spaceX + 30, startY, width, height), cont);
            //    unit.max_targets = EditorGUI.IntField(new Rect(startX + width + spaceX - 100, startY, 40, height), unit.max_targets);
            //}


            //cont = new GUIContent("Multi target:", "Check if the unit is Multi target");
            //EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.multishot = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.multishot);

            return(new Vector3(startX, startY, spaceX + width));
        }
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
        private static void UpdateObjectHierarchyList()
        {
            List <UnitCreep> creepList = EditorDBManager.GetCreepList();

            if (creepList.Count == 0 || selectID >= creepList.Count)
            {
                return;
            }
            EditorUtilities.GetObjectHierarchyList(creepList[selectID].gameObject, SetObjListCallback);
        }
Esempio n. 6
0
        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. 7
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window = (UnitCreepEditorWindow)EditorWindow.GetWindow <UnitCreepEditorWindow>("Creep Editor");
            //~ window.minSize=new Vector2(375, 449);
            //~ window.maxSize=new Vector2(375, 800);

            EditorDBManager.Init();

            InitLabel();
            UpdateObjectHierarchyList();
        }
Esempio n. 8
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. 9
0
        public void Select(string name)
        {
            int selectID = 0;
            List <UnitCreep> creepList = EditorDBManager.GetCreepList();

            for (int i = 0; i < creepList.Count; i++)
            {
                if (creepList[i].unitName.Trim().Equals(name.Trim()))
                {
                    selectID = i;
                }
            }
            SelectCreep(selectID);
        }
Esempio n. 10
0
        public static void Init(string title = "Tower Editor")
        {
            // Get existing open window or if none, make a new one:
            window = (UnitTowerEditorWindow)EditorWindow.GetWindow(typeof(UnitTowerEditorWindow), false, title);
            //~ window.minSize=new Vector2(375, 449);
            //~ window.maxSize=new Vector2(375, 800);

            EditorDBManager.Init();

            InitLabel();
            UpdateObjectHierarchyList();

            skin = Resources.Load <GUISkin>("GUISkin");
        }
Esempio n. 11
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. 12
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. 13
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. 14
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;
            }
            else 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);

                //cont = new GUIContent("Target layer:", "The Target layer of the unit");
                //EditorGUI.LabelField(new Rect(startX+=0, startY += spaceY, width, height), cont);
                //unit.targetLayer = EditorGUI.LayerField(new Rect(startX + spaceX, startY, spaceX, height), unit.targetLayer);
            }

            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 (unit.shootPoints.Count > unit.useNextShootObjects.Count)
                {
                    unit.useNextShootObjects = new List <bool>();
                    for (int i = 0; i < unit.shootPoints.Count; i++)
                    {
                        unit.useNextShootObjects.Add(false);
                    }
                }

                if (shootPointCount != unit.shootPoints.Count)
                {
                    while (unit.shootPoints.Count < shootPointCount)
                    {
                        unit.shootPoints.Add(null);
                        unit.useNextShootObjects.Add(false);
                    }
                    while (unit.shootPoints.Count > shootPointCount)
                    {
                        unit.shootPoints.RemoveAt(unit.shootPoints.Count - 1);
                        unit.useNextShootObjects.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), "SP" + (i + 1) + "   Next SO:");
                        objID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                        unit.shootPoints[i] = (objHList[objID] == null) ? null : objHList[objID].transform;

                        unit.useNextShootObjects[i] = EditorGUI.Toggle(new Rect(startX + 80, startY, 80, 20), unit.useNextShootObjects[i]);
                    }
                }

                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. 15
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            GUI.skin = skin;

            List <UnitTower> towerList = filterTowers();

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

            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. 16
0
        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. 17
0
        Vector2 DrawUnitList(float startX, float startY, List <UnitTower> towerList)
        {
            float width = FULL_WIDTH_TOWER_LIST;

            if (minimiseList)
            {
                width = COLAPSED_WIDTH_TOWER_LIST;
            }

            if (!minimiseList)
            {
                if (GUI.Button(new Rect(startX + 100, startY - 20, 40, 18), "up"))
                {
                    if (selectID > 0)
                    {
                        UnitTower tower = towerList[selectID];
                        towerList[selectID]     = towerList[selectID - 1];
                        towerList[selectID - 1] = tower;
                        selectID -= 1;

                        if (selectID * 35 < scrollPos1.y)
                        {
                            scrollPos1.y = selectID * 35;
                        }
                    }
                }
                if (GUI.Button(new Rect(startX + 142, startY - 20, 40, 18), "down"))
                {
                    if (selectID < towerList.Count - 1)
                    {
                        UnitTower tower = towerList[selectID];
                        towerList[selectID]     = towerList[selectID + 1];
                        towerList[selectID + 1] = tower;
                        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, towerList.Count * 35 + 5);

            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 < towerList.Count; i++)
            {
                EditorUtilities.DrawSprite(new Rect(startX, startY + (i * 35), 30, 30), towerList[i].iconSprite);

                if (minimiseList)
                {
                    if (selectID == i)
                    {
                        GUI.color = new Color(0, 1f, 1f, 1f);
                    }
                    if (GUI.Button(new Rect(startX + 115, startY + (i * 35), 30, 30), "X"))
                    {
                        SelectTower(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), 180, 30), towerList[i].unitName))
                {
                    SelectTower(i);
                }
                GUI.color = Color.white;

                if (deleteID == i)
                {
                    if (GUI.Button(new Rect(startX + 137, startY + (i * 35), 20, 20), "N"))
                    {
                        deleteID = -1;
                    }

                    GUI.color = Color.red;
                    if (GUI.Button(new Rect(startX + 137, startY + (i * 35) + 15, 20, 20), "Y"))
                    {
                        if (selectID >= deleteID)
                        {
                            SelectTower(Mathf.Max(0, selectID - 1));
                        }
                        EditorDBManager.RemoveTower(deleteID);
                        deleteID = -1;
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    if (GUI.Button(new Rect(startX + 217, startY + (i * 35), 25, 25), "X"))
                    {
                        deleteID = i;
                    }
                }
            }

            GUI.EndScrollView();

            return(new Vector2(startX + width, startY));
        }
Esempio n. 18
0
        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;

            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, 20, 15), "^"))
            {
                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, 20), "-1"))
            {
                if (tower.stats.Count > 1)
                {
                    tower.stats.RemoveAt(tower.stats.Count - 1);
                }
            }
            if (GUI.Button(new Rect(startX + 165, startY, 50, 20), "+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 + 10), 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, 20, 15), "^"))
            {
                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, 20, 15), "^"))
                {
                    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, 400);
            startX = cachedX;

            float maxHeight        = 0;
            float maxContentHeight = 0;

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

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

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


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

                startY += spaceY + 5;
            }

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

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

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

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

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

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

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


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

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

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



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

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


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

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

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



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

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

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



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

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

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



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

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

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

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



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

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

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


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

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

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



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

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

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

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

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

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

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

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

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


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


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



            statContentHeight = startY + spaceY - 15;

            return(new Vector3(startX + 220, startY, statContentHeight));
        }
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)
            {
                for (int i = 0; i < creep.stats.Count; i++)
                {
                    v3 = DrawStat(creep.stats[i], startX, startY, statContentHeight, creepList[selectID]);
                    statContentHeight = v3.z;
                    if (contentHeight < v3.y)
                    {
                        contentHeight = v3.y;
                    }
                    //if (contentWidth < 580)
                    contentWidth = 580;

                    startY += 435;
                }
            }

            contentHeight -= cachedY;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                EditorDBManager.SetDirtyCreep();
            }
        }
Esempio n. 21
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);
            }
        }
Esempio n. 22
0
        Vector2 DrawUnitList(float startX, float startY, List <UnitCreep> creepList)
        {
            float width = 160;

            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. 23
0
        Vector3 DrawUnitConfigurator(float startX, float startY, List <UnitCreep> creepList, bool offense = false)
        {
            UnitCreep creep = creepList[selectID];

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

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

            int type = (int)creep.type;

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

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

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

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

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

            startY += 20;


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

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

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

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

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

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


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


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

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

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

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

            startY += 20;


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


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

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

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

            return(new Vector3(startX, startY, maxWidth));
        }
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
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }
            if (instance == null)
            {
                EditorGUI.LabelField(new Rect(5, 5, 350, 18), "No SpawnManager in current scene");
                GetSpawnManager();
                return;
            }

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


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

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

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


            float startX = 5;
            float startY = 5;


            int spawnMode = (int)instance.spawnMode;

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

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


            int spawnLimit = (int)instance.spawnLimit;

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

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

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

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

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

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

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

            startY += 35;
            float waveConfigStartY = startY;

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

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

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

            startX += 5;
            startY += 10;

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

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

            startX = cachedX;
            startY = v2.y;

            GUI.EndScrollView();

            contentHeight = startY - waveConfigStartY;

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