Пример #1
0
        void OnSelectionChange()
        {
            if (window == null)
            {
                return;
            }

            srlObj = null;

            selectedUnitList = new List <UnitAI>();

            UnityEngine.Object[] filtered = Selection.GetFiltered(typeof(UnitAI), SelectionMode.Editable);
            for (int i = 0; i < filtered.Length; i++)
            {
                selectedUnitList.Add((UnitAI)filtered[i]);
            }

            //if no no relevent object is selected
            if (selectedUnitList.Count == 0)
            {
                SelectItem();
                if (unitAIDB.unitList.Count > 0 && selectID >= 0)
                {
                    UpdateObjectHierarchyList(unitAIDB.unitList[selectID].gameObject);
                }
            }
            else
            {
                //only one relevent object is selected
                if (selectedUnitList.Count == 1)
                {
                    //if the selected object is a prefab and match the selected item in editor, do nothing
                    if (selectID > 0 && selectedUnitList[0] == unitAIDB.unitList[selectID])
                    {
                        UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                    }
                    //if the selected object doesnt match...
                    else
                    {
                        //if the selected object existed in DB
                        if (TDSEditor.ExistInDB(selectedUnitList[0]))
                        {
                            window.selectID = TDSEditor.GetUnitAIIndex(selectedUnitList[0].prefabID) - 1;
                            UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                            SelectItem();
                        }
                        //if the selected object is not in DB
                        else
                        {
                            selectID = -1;
                            UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                        }
                    }
                }
                //selected multiple editable object
                else
                {
                    selectID = -1;
                    UpdateObjectHierarchyList(selectedUnitList[0].gameObject);
                }

                srlObj = new SerializedObject(filtered);
            }

            Repaint();
        }
Пример #2
0
        void DrawObjective(ObjectiveTracker objective)
        {
            if (objective == null)
            {
                return;
            }


            EditorGUILayout.Space();


            //cont=new GUIContent("Main Objective:", "Check if this is the main objective of the level. Completing this will end the level");
            //objective.mainObjective=EditorGUILayout.Toggle(cont, objective.mainObjective);

            cont = new GUIContent("Wait For Timer:", "Enable to wait for the timer to run out before trigger a level complete state");
            objective.waitForTimer = EditorGUILayout.Toggle(cont, objective.waitForTimer);


            EditorGUILayout.Space();


            cont = new GUIContent("EnableTargetScore:", "Check if the objective is to gain a certain amount of score");
            objective.enableScoring = EditorGUILayout.Toggle(cont, objective.enableScoring);

            cont = new GUIContent("Target Score:", "The target score the player needs to gain to complete the objective");
            if (objective.enableScoring)
            {
                objective.targetScore = EditorGUILayout.FloatField(cont, objective.targetScore);
            }
            else
            {
                EditorGUILayout.LabelField(cont, new GUIContent("-", ""));
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Clear All Hostile:", "Check if all active hostile unit in the level has to be destroyed before the objective is completed");
            objective.clearAllHostile = EditorGUILayout.Toggle(cont, objective.clearAllHostile);

            if (!objective.clearAllHostile)
            {
                cont         = new GUIContent("Unit List:", "Unit in the scene that need to be destroyed to complete the objective");
                showUnitList = EditorGUILayout.Foldout(showUnitList, cont);
                if (showUnitList)
                {
                    int count = objective.unitList.Count;

                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                    count = EditorGUILayout.IntField("Count", count);
                    EditorGUILayout.EndHorizontal();

                    while (count > objective.unitList.Count)
                    {
                        objective.unitList.Add(null);
                    }
                    while (count < objective.unitList.Count)
                    {
                        objective.unitList.RemoveAt(objective.unitList.Count - 1);
                    }

                    for (int i = 0; i < objective.unitList.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                        objective.unitList[i] = (Unit)EditorGUILayout.ObjectField("Element " + i, objective.unitList[i], typeof(Unit), true);
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }


            EditorGUILayout.Space();


            //public List<Collectible> collectibleList=new List<Collectible>();	//collectible that exist in the scene
            cont = new GUIContent("Collectible List:", "Collectible item in the scene that need to be collected to complete the objective");
            showCollectibleList = EditorGUILayout.Foldout(showCollectibleList, cont);
            if (showCollectibleList)
            {
                int count = objective.collectibleList.Count;

                EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                count = EditorGUILayout.IntField("Count", count);
                EditorGUILayout.EndHorizontal();

                while (count > objective.collectibleList.Count)
                {
                    objective.collectibleList.Add(null);
                }
                while (count < objective.collectibleList.Count)
                {
                    objective.collectibleList.RemoveAt(objective.collectibleList.Count - 1);
                }

                for (int i = 0; i < objective.collectibleList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                    objective.collectibleList[i] = (Collectible)EditorGUILayout.ObjectField("Element " + i, objective.collectibleList[i], typeof(Collectible), true);
                    EditorGUILayout.EndHorizontal();
                }
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Clear All Spawner:", "Check if all active unit spawner in the level has to be destroyed/cleared before the objective is completed");
            objective.clearAllSpawner = EditorGUILayout.Toggle(cont, objective.clearAllSpawner);

            if (!objective.clearAllSpawner)
            {
                cont            = new GUIContent("Unit Spawner List:", "Unit Spawner in the scene that need to be cleared to complete the objective");
                showSpawnerList = EditorGUILayout.Foldout(showSpawnerList, cont);
                if (showSpawnerList)
                {
                    int count = objective.spawnerList.Count;

                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                    count = EditorGUILayout.IntField("Count", count);
                    EditorGUILayout.EndHorizontal();

                    while (count > objective.spawnerList.Count)
                    {
                        objective.spawnerList.Add(null);
                    }
                    while (count < objective.spawnerList.Count)
                    {
                        objective.spawnerList.RemoveAt(objective.spawnerList.Count - 1);
                    }

                    for (int i = 0; i < objective.spawnerList.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                        objective.spawnerList[i] = (UnitSpawner)EditorGUILayout.ObjectField("Element " + i, objective.spawnerList[i], typeof(UnitSpawner), true);
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }


            EditorGUILayout.Space();

            cont            = new GUIContent("Objective Trigger List:", "");
            showTriggerList = EditorGUILayout.Foldout(showTriggerList, cont);
            if (showTriggerList)
            {
                int count = objective.triggerList.Count;

                EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(15));
                count = EditorGUILayout.IntField("Count", count);
                EditorGUILayout.EndHorizontal();

                while (count > objective.triggerList.Count)
                {
                    objective.triggerList.Add(null);
                }
                while (count < objective.triggerList.Count)
                {
                    objective.triggerList.RemoveAt(objective.triggerList.Count - 1);
                }

                for (int i = 0; i < objective.triggerList.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("", GUILayout.MaxWidth(20));
                    objective.triggerList[i] = (Trigger)EditorGUILayout.ObjectField("Element " + i, objective.triggerList[i], typeof(Trigger), true);
                    EditorGUILayout.EndHorizontal();
                }
            }

            EditorGUILayout.Space();


            cont = new GUIContent("Objective Targets:", "Specific numbers of any particular unit that needs to be destroyed before the level is cleared");
            EditorGUILayout.LabelField(cont);

            if (objective.prefabList.Count != objective.prefabCountList.Count)
            {
                //if(objective.targetUnitList.Count>objective.targetUnitCountList.Count)
                while (objective.prefabList.Count > objective.prefabCountList.Count)
                {
                    objective.prefabCountList.Add(1);
                }
                while (objective.prefabList.Count < objective.prefabCountList.Count)
                {
                    objective.prefabCountList.RemoveAt(objective.prefabCountList.Count - 1);
                }
            }


            for (int i = 0; i < objective.prefabList.Count + 1; i++)
            {
                if (i == objective.prefabList.Count && objective.prefabList.Count == unitAIDB.unitList.Count)
                {
                    continue;
                }

                int unitIdx = i < objective.prefabList.Count ? TDSEditor.GetUnitAIIndex(objective.prefabList[i].prefabID) : 0;

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField("  -  ", GUILayout.MaxWidth(20));                        //GUILayout.MaxWidth(115));
                unitIdx = EditorGUILayout.Popup(unitIdx, unitAILabel);

                if (i < objective.prefabList.Count)
                {
                    objective.prefabCountList[i] = EditorGUILayout.IntField(objective.prefabCountList[i], GUILayout.MaxWidth(40));
                    objective.prefabCountList[i] = Mathf.Max(1, objective.prefabCountList[i]);
                }
                else
                {
                    EditorGUILayout.LabelField("    ", GUILayout.MaxWidth(40));
                }

                EditorGUILayout.EndHorizontal();

                if (i < objective.prefabList.Count)
                {
                    if (unitIdx == 0)
                    {
                        objective.prefabList.RemoveAt(i);
                    }
                    else if (unitIdx > 0 && !objective.prefabList.Contains(unitAIDB.unitList[unitIdx - 1]))
                    {
                        objective.prefabList[i] = unitAIDB.unitList[unitIdx - 1];
                    }
                }
                else
                {
                    if (unitIdx > 0 && !objective.prefabList.Contains(unitAIDB.unitList[unitIdx - 1]))
                    {
                        objective.prefabList.Add(unitAIDB.unitList[unitIdx - 1]);
                    }
                }
            }


            EditorGUILayout.Space();


            cont = new GUIContent("Objective Collectibles:", "Specific numbers of any particular collectible that needs to be collectible before the level is cleared");
            EditorGUILayout.LabelField(cont);

            if (objective.colPrefabList.Count != objective.colPrefabCountList.Count)
            {
                while (objective.colPrefabList.Count > objective.colPrefabCountList.Count)
                {
                    objective.colPrefabCountList.Add(1);
                }
                while (objective.colPrefabList.Count < objective.colPrefabCountList.Count)
                {
                    objective.colPrefabCountList.RemoveAt(objective.colPrefabCountList.Count - 1);
                }
            }


            for (int i = 0; i < objective.colPrefabList.Count + 1; i++)
            {
                //if(i==objective.colPrefabList.Count && objective.prefabList.Count==unitAIDB.unitList.Count) continue;

                int itemIdx = i < objective.colPrefabList.Count ? TDSEditor.GetCollectibleIndex(objective.colPrefabList[i].ID) : 0;

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField("  -  ", GUILayout.MaxWidth(20));                        //GUILayout.MaxWidth(115));
                itemIdx = EditorGUILayout.Popup(itemIdx, collectibleLabel);

                if (i < objective.colPrefabList.Count)
                {
                    objective.colPrefabCountList[i] = EditorGUILayout.IntField(objective.colPrefabCountList[i], GUILayout.MaxWidth(40));
                    objective.colPrefabCountList[i] = Mathf.Max(1, objective.colPrefabCountList[i]);
                }
                else
                {
                    EditorGUILayout.LabelField("    ", GUILayout.MaxWidth(40));
                }

                EditorGUILayout.EndHorizontal();

                if (i < objective.colPrefabList.Count)
                {
                    if (itemIdx == 0)
                    {
                        objective.colPrefabList.RemoveAt(i);
                    }
                    else if (itemIdx > 0 && !objective.colPrefabList.Contains(collectibleDB.collectibleList[itemIdx - 1]))
                    {
                        objective.colPrefabList[i] = collectibleDB.collectibleList[itemIdx - 1];
                    }
                }
                else
                {
                    if (itemIdx > 0 && !objective.colPrefabList.Contains(collectibleDB.collectibleList[itemIdx - 1]))
                    {
                        objective.colPrefabList.Add(collectibleDB.collectibleList[itemIdx - 1]);
                    }
                }
            }

            //~ public List<Collectible> colPrefabList=new List<Collectible>();	//the collectible that need to be collect
            //~ public List<int> colPrefabCountList=new List<int>();		//the count required, editable in editor
        }
Пример #3
0
        Vector2 DrawUnitConfigurator(float startX, float startY, UnitAI unit)
        {
            Vector2 v2 = DrawUnitBaseStats(startX, startY, unit, false);

            startY = v2.y;

            startY += 10;


            //~ int type=(int)unit.behaviour;
            //~ cont=new GUIContent("Base Behaviour:", "Type of the behaviour which determine the how the unit respond to presence of hostile unit");
            //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            //~ contL=new GUIContent[behaviourLabel.Length];
            //~ for(int i=0; i<contL.Length; i++) contL[i]=new GUIContent(behaviourLabel[i], behaviourTooltip[i]);
            //~ type = EditorGUI.Popup(new Rect(startX+spaceX, startY, width, 15), new GUIContent(""), type, contL);
            //~ unit.behaviour=(_Behaviour)type;

            //~ cont=new GUIContent("Aggro Range:", "The range at which the unit will chasing down and attacking player\n\nUnit will not start attacking (shooting) until the target is within aggro range");
            //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            //~ if(unit.behaviour==_Behaviour.Aggressive_Trigger || unit.behaviour==_Behaviour.StandGuard)
            //~ unit.aggroRange=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.aggroRange);
            //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

            srlPpt = srlObj.FindProperty("behaviour");


            srlObj.Update();
            EditorGUI.BeginChangeCheck();
            cont = new GUIContent("Base Behaviour:", "Type of the behaviour which determine the how the unit respond to presence of hostile unit");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            contL = new GUIContent[behaviourLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(behaviourLabel[i], behaviourTooltip[i]);
            }
            pptIntValue = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.enumValueIndex, contL);    EditorGUI.EndProperty();
            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.enumValueIndex = pptIntValue;
            }


            cont = new GUIContent("Aggro Range(P):", "The range at which the unit will chasing down and attacking player\n\nUnit will not start attacking (shooting) until the target is within aggro range");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (srlPpt.enumValueIndex == (int)_Behaviour.Aggressive_Trigger || srlPpt.enumValueIndex == (int)_Behaviour.StandGuard)
            {
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("aggroRange"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }
            srlObj.ApplyModifiedProperties();


            startY += 10;


            showMoveSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), showMoveSetting, "Show Move Setting", foldoutStyle);
            if (showMoveSetting)
            {
                startX += 15; width -= 15;

                //~ cont=new GUIContent("Anchored To Point:", "Check if the unit is a static object. Means it will not moved and wont be affected by physics");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY+5, width, height), cont);
                //~ unit.anchorDown=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.anchorDown);

                //~ cont=new GUIContent(" - Move Speed:", "The move speed of the unit");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(!unit.anchorDown) unit.moveSpeed=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.moveSpeed);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent(" - Rotate Speed:", "The rotate speed of the unit (degree per second)");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(!unit.anchorDown) unit.rotateSpeed=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.rotateSpeed);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent(" - Brake  Range:", "The range at which the unit will stop moving towards its target");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(!unit.anchorDown) unit.brakeRange=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.brakeRange);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");


                srlPpt = srlObj.FindProperty("anchorDown");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Anchored To Point:", "Check if the unit is a static object. Means it will not moved and wont be affected by physics");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                showVar = !srlPpt.hasMultipleDifferentValues & !srlPpt.boolValue;

                cont = new GUIContent(" - Move Speed(P):", "The move speed of the unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("moveSpeed"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent(" - Rotate Speed(P):", "The rotate speed of the unit (degree per second)");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("rotateSpeed"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent(" - Brake  Range(P):", "The range at which the unit will stop moving towards its target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("brakeRange"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }


                startY += 10;


                //~ cont=new GUIContent("Stop Ocassionally:", "Check to enable the target to stop every now and then when chasing the target");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ unit.stopOccasionally=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.stopOccasionally);

                //~ cont=new GUIContent("  - Stop Chance:", "Chance that determine how often the unit will stop. takes value from 0-1 with 0 as never and 1 as every cooldown");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.stopOccasionally) unit.stopRate=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.stopRate);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Stop Duration:", "How long (in second) the unit will stop for");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.stopOccasionally) unit.stopDuration=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.stopDuration);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Stop Cooldown:", "How long (in second) before the unit will try to stop after the last stop");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.stopOccasionally) unit.stopCooldown=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.stopCooldown);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");


                srlPpt = srlObj.FindProperty("stopOccasionally");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Stop Ocassionally:", "Check to enable the target to stop every now and then when chasing the target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                showVar = !srlPpt.hasMultipleDifferentValues & pptBoolValue;

                cont = new GUIContent("  - Stop Chance:", "Chance that determine how often the unit will stop. takes value from 0-1 with 0 as never and 1 as every cooldown");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("stopRate"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Stop Duration:", "How long (in second) the unit will stop for");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("stopDuration"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Stop Cooldown:", "How long (in second) before the unit will try a stop maneuver after the last stop maneuver");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("stopCooldown"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }


                startY += 10;


                //~ cont=new GUIContent("Evade Ocassionally:", "Check to enable the target to perform a evade maneuver and then when chasing the target");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ unit.evadeOccasionally=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.evadeOccasionally);

                //~ cont=new GUIContent("  - Evade Chance:", "Chance that determine how often the unit will evade. takes value from 0-1 with 0 as never and 1 as every cooldown");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.evadeOccasionally) unit.evadeRate=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.evadeRate);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Evade Duration:", "How long (in second) the unit will perform the maneuver for");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.evadeOccasionally) unit.evadeDuration=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.evadeDuration);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

                //~ cont=new GUIContent("  - Stop Cooldown:", "How long (in second) before the unit will try a evade maneuver after the last evade maneuver");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
                //~ if(unit.evadeOccasionally) unit.evadeCooldown=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.evadeCooldown);
                //~ else EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");


                srlPpt = srlObj.FindProperty("evadeOccasionally");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Evade Ocassionally:", "Check to enable the target to perform a evade maneuver and then when chasing the target");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                showVar = !srlPpt.hasMultipleDifferentValues & !pptBoolValue;

                cont = new GUIContent("  - Evade Chance:", "Chance that determine how often the unit will evade. takes value from 0-1 with 0 as never and 1 as every cooldown");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("evadeRate"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Evade Duration:", "How long (in second) the unit will perform the maneuver for");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("evadeDuration"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }

                cont = new GUIContent("  - Evade Cooldown:", "How long (in second) before the unit will try a evade maneuver after the last evade maneuver");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                if (showVar)
                {
                    EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("evadeCooldown"), contN);
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                }


                startX -= 15; width += 15;
            }

            startY += 10;

            showAttackSetting = EditorGUI.Foldout(new Rect(startX, startY += spaceY, width, height), showAttackSetting, "Show Attack Setting", foldoutStyle);
            if (showAttackSetting)
            {
                startX += 15; width -= 15; spaceX += 10;           //width-=20;

                startY += 5;

                //~ cont=new GUIContent("Range Attack:", "Check if the unit can perform any range attack");
                //~ EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont, headerStyle);
                //~ unit.enableAttack=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.enableAttack);

                srlPpt = srlObj.FindProperty("enableRangeAttack");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("Range Attack:", "Check if the unit can perform any range attack");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                bool enableRangeAttack = !srlPpt.hasMultipleDifferentValues & pptBoolValue;

                //if(unit.enableAttack){
                if (enableRangeAttack)
                {
                    string lbSp = " - ";

                    cont = new GUIContent(lbSp + "Shoot Periodically:", "Check to enable the target to shoot after every attack cooldown, regardless of existance or range of target");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                    unit.shootPeriodically = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.shootPeriodically);

                    cont = new GUIContent(lbSp + "AlwaysOnTarget:", "Check to have the unit shoot object always fire towards target, regardless of aim direction");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.alwaysShootTowardsTarget = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), unit.alwaysShootTowardsTarget);


                    startY += 10;


                    cont = new GUIContent(lbSp + "Shoot Object:", "The prefab of the bullet/object fired by the unit\nMust be a prefab with ShootObject component attached on it\n\n*Required for range attack to work");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, unit.shootObject != null ? new GUIStyle("Label") : conflictStyle);
                    unit.shootObject = (GameObject)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), unit.shootObject, typeof(GameObject), false);

                    int objID = GetObjectIDFromHList(unit.turretObj, objHList);
                    cont = new GUIContent(lbSp + "Turret Object:", "The pivot transform on the unit to track the shoot direction");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    objID          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), objID, objHLabelList);
                    unit.turretObj = (objHList[objID] == null) ? null : objHList[objID].transform;

                    cont = new GUIContent(lbSp + "TurretTrackSpeed:", "The tracking speed of the turret. Slower turret will have a harder time keeping up with target.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    if (unit.turretObj != null)
                    {
                        unit.turretTrackingSpeed = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.turretTrackingSpeed);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                    }


                    startY += 10;


                    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 weapon transform itself will be use as the shootPoint\nThe orientation of the shootPoint matter as they dictate the orientation of the firing direction.\n");
                    shootPointFoldout = EditorGUI.Foldout(new Rect(startX + 3, startY += spaceY, spaceX, height), shootPointFoldout, cont);
                    int shootPointCount = unit.shootPointList.Count;
                    shootPointCount = EditorGUI.DelayedIntField(new Rect(startX + spaceX, startY, 40, height), shootPointCount);

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

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

                    cont = new GUIContent(lbSp + "Shoot Point Delay:", "The delay in seconds between subsequent shot in each shoot point");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    if (unit.shootPointList.Count > 1)
                    {
                        unit.shootPointDelay = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.shootPointDelay);
                    }
                    else
                    {
                        EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
                    }


                    startY += 10;


                    cont = new GUIContent(lbSp + "Attack Range:", "The attack range of the unit");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.range = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.range);

                    cont = new GUIContent(lbSp + "Attack Cooldown:", "The cooldown duration in seconds between each subsequent attack");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.cooldown = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.cooldown);

                    startY += 5;

                    cont = new GUIContent(lbSp + "First Attack Delay:", "The delay in second before the unit can perform it's first attack. To prevent unit to fire immediately after being spawned or as soon as the game start");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    unit.firstAttackDelay = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.firstAttackDelay);

                    cont = new GUIContent("Randomize", "Randomize the first attack delay between 0 and the specified value");
                    unit.randFirstAttackDelay = EditorGUI.Toggle(new Rect(startX + spaceX + 45, startY, 20, height), unit.randFirstAttackDelay);
                    EditorGUI.LabelField(new Rect(startX + spaceX + 45 + 15, startY, width, height), cont);


                    startY += 10;


                    v2     = DrawAttackStats1(startX, startY + spaceY, unit.attackStats, true, false, "   Attack Stats (Range)");
                    startY = v2.y;
                }



                startY += 10;



                srlPpt = srlObj.FindProperty("enableContactAttack");

                EditorGUI.BeginChangeCheck();
                cont = new GUIContent("AttackOnContact:", "Check if the unit can attack when comes into contact with hostile unit");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);
                pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
                if (EditorGUI.EndChangeCheck())
                {
                    srlPpt.boolValue = pptBoolValue;
                }

                bool enableContactAttack = !srlPpt.hasMultipleDifferentValues & pptBoolValue;

                if (enableContactAttack)
                {
                    string lbSp = " - ";

                    cont = new GUIContent(lbSp + "Attack Cooldown:", "The cooldown duration in seconds between each subsequent attack");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY + 5, width, height), cont);
                    unit.contactCooldown = EditorGUI.DelayedFloatField(new Rect(startX + spaceX, startY, 40, height), unit.contactCooldown);

                    startY += 10;

                    v2     = DrawAttackStats1(startX, startY + spaceY, unit.contactAttackStats, false, false, "   Attack Stats (On Contact)");
                    startY = v2.y;
                }


                startX -= 15; width += 15; spaceX -= 10;           //width+=20;
            }


            startY += 20;

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Misc", headerStyle);

            cont = new GUIContent("DestroyUponContact:", "Check to destroy unit upon coming into contact with a hostile");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.destroyUponPlayerContact=EditorGUI.Toggle(new Rect(startX+spaceX, startY, 40, height), unit.destroyUponPlayerContact);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("destroyUponPlayerContact"), contN);

            startY += 10;

            cont = new GUIContent("Score On Destroy:", "Score gained by player when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.valueScore=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueScore);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("valueScore"), contN);

            cont = new GUIContent("HitPoint On Destroy:", "Hit-Point gained by player when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.valueHitPoint=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueHitPoint);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("valueHitPoint"), contN);

            cont = new GUIContent("Energy On Destroy:", "Energy gained by player when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //unit.valueEnergy=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueEnergy);
            EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("valueEnergy"), contN);

            //cont=new GUIContent("Credit On Destroy:", "Credit gained by player when the unit is destroyed");
            //EditorGUI.LabelField(new Rect(startX, startY+=spaceY, width, height), cont);
            //unit.valueCredits=EditorGUI.DelayedIntField(new Rect(startX+spaceX, startY, 40, height), unit.valueCredits);

            startY += 10;


            //Vector2 v3=DrawDestroyEffectObj(startX, startY+spaceY, unit);
            Vector2 v3 = DrawDestroyEffectObj(startX, startY + spaceY, srlObj);

            startY = v3.y + 10;


            srlPpt = srlObj.FindProperty("useDropManager");

            EditorGUI.BeginChangeCheck();
            cont = new GUIContent("Use DropManager:", "Check to use DropManager to determine what the unit drops");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            pptBoolValue = EditorGUI.Toggle(new Rect(startX + spaceX, startY, 40, height), EditorGUI.BeginProperty(new Rect(), contN, srlPpt), srlPpt.boolValue);       EditorGUI.EndProperty();
            if (EditorGUI.EndChangeCheck())
            {
                srlPpt.boolValue = pptBoolValue;
            }

            showVar = !srlPpt.hasMultipleDifferentValues & !pptBoolValue;

            cont = new GUIContent("Drop Object:", "The game object to drop when the unit is destroyed");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (showVar)
            {
                //unit.dropObject=(GameObject)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), unit.dropObject, typeof(GameObject), false);
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, width, height), srlObj.FindProperty("dropObject"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }

            cont = new GUIContent("Drop Chance:", "The chance for the object to drop. Takes value from 0-1 with 0.3 being 30% chance to drop");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (showVar)
            {
                //unit.dropChance=EditorGUI.DelayedFloatField(new Rect(startX+spaceX, startY, 40, height), unit.dropChance);
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("dropChance"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            startY += 10;



            EditorGUI.showMixedValue = srlObj.FindProperty("spawnUponDestroy").hasMultipleDifferentValues;
            int unitIdx = unit.spawnUponDestroy != null?TDSEditor.GetUnitAIIndex(unit.spawnUponDestroy.prefabID) : 0;

            cont = new GUIContent("SpawnUponDestroy:", "The unit to spawn when this unit is destroyed (optional)");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);

            EditorGUI.BeginChangeCheck();
            unitIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), unitIdx, unitAILabel);
            if (EditorGUI.EndChangeCheck())
            {
                if (unitIdx == 0)
                {
                    unit.spawnUponDestroy = null;
                    srlObj.FindProperty("spawnUponDestroy").objectReferenceValue = null;
                }
                else if (unitIdx > 0)
                {
                    unit.spawnUponDestroy = unitAIDB.unitList[unitIdx - 1];
                    srlObj.FindProperty("spawnUponDestroy").objectReferenceValue = unitAIDB.unitList[unitIdx - 1];
                }
            }

            EditorGUI.showMixedValue = false;



            cont = new GUIContent("Spawn Count:", "Number of unit to spawn");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            if (unit.spawnUponDestroy != null)
            {
                EditorGUI.PropertyField(new Rect(startX + spaceX, startY, 40, height), srlObj.FindProperty("spawnUponDestroyCount"), contN);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX + spaceX, startY, 40, height), "-");
            }


            startY += 15;


            GUIStyle style = new GUIStyle("TextArea");

            style.wordWrap = true;
            cont           = new GUIContent("Unit description (to be used in runtime): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            unit.desp = EditorGUI.DelayedTextField(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style);


            return(new Vector2(startX, startY + 200));
        }
        Vector2 DrawSpawnerConfigurator(float startX, float startY, UnitSpawner spawner)
        {
            int mode = (int)spawner.spawnMode;

            cont = new GUIContent("Spawn Mode:", "The spawn mode to use");
            EditorGUI.LabelField(new Rect(startX, startY, width, height), cont, headerStyle);
            contL = new GUIContent[spawnModeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(spawnModeLabel[i], spawnModeTooltip[i]);
            }
            mode = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), mode, contL);
            spawner.spawnMode = (_SpawnMode)mode;


            if (spawner.spawnMode == _SpawnMode.WaveBased)
            {
                cont = new GUIContent("- Endless", "Enable to activate endless mode (wave will be generated procedurally)");
                EditorGUI.LabelField(new Rect(startX + spaceX + width + 25, startY, width, height), cont, headerStyle);
                spawner.endlessWave = EditorGUI.Toggle(new Rect(startX + spaceX + width + 10, startY, 40, height), spawner.endlessWave);
            }


            startY += 10;


            cont = new GUIContent("Spawn Upon Start:", "Check to have the spawner start spawning automatically as soon as the game start");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.spawnUponStart = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), spawner.spawnUponStart);

            cont = new GUIContent("Start Delay:", "Delay (in second) before the spawning start");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            //if(spawner.spawnUponStart)
            spawner.startDelay = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), spawner.startDelay);
            //else
            //	EditorGUI.LabelField(new Rect(startX+spaceX, startY, 40, height), "-");

            startY += 10;

            cont = new GUIContent("Random Rotation:", "Check to have the unit spawned facing random rotation, otherwise the rotation of the spawn area will be used");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.randomRotation = EditorGUI.Toggle(new Rect(startX + spaceX, startY, width, height), spawner.randomRotation);

            startY += 10;


            for (int i = 0; i < spawner.spawnAreaList.Count - 1; i++)
            {
                if (spawner.spawnAreaList[i] == null)
                {
                    spawner.spawnAreaList.RemoveAt(i); i -= 1;
                }
            }
            if (spawner.spawnAreaList.Count == 0)
            {
                spawner.spawnAreaList.Add(null);
            }

            cont = new GUIContent("Spawn Area:", "The area which the unit should be spawn in\nIf unspecified, the unit will simply be spawned at the position of the spawner\nRequire game object with a TDSArea component");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
            spawner.spawnAreaList[0] = (TDSArea)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), spawner.spawnAreaList[0], typeof(TDSArea), true);

            if (spawner.spawnAreaList[0] == null)
            {
                TDSArea existingArea = spawner.gameObject.GetComponent <TDSArea>();
                if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, 75, height), "Add Area"))
                {
                    if (existingArea != null)
                    {
                        spawner.spawnAreaList[0] = existingArea;
                    }
                    else
                    {
                        spawner.spawnAreaList[0] = spawner.gameObject.AddComponent <TDSArea>();
                    }
                }
            }

            //only show extra spawn area in free form or endless mode
            if (spawner.spawnMode == _SpawnMode.FreeForm || (spawner.spawnMode == _SpawnMode.WaveBased && spawner.endlessWave))
            {
                EditorGUI.HelpBox(new Rect(startX + spaceX + width + 20, startY, 1.5f * width, (spawner.spawnAreaList.Count + 1) * spaceY), "Alternate spawn-area will be randomly selected in freeform and endless mode", MessageType.None);

                for (int i = 1; i < spawner.spawnAreaList.Count; i++)
                {
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Alt " + i + ":");
                    spawner.spawnAreaList[i] = (TDSArea)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), spawner.spawnAreaList[i], typeof(TDSArea), true);

                    if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, 55, height), "remove"))
                    {
                        spawner.spawnAreaList.RemoveAt(i);
                        i -= 1;
                    }
                }

                if (GUI.Button(new Rect(startX + spaceX, startY += spaceY, width / 2, height), "Add"))
                {
                    spawner.spawnAreaList.Add(null);
                }
                if (GUI.Button(new Rect(startX + spaceX + width / 2, startY, width / 2, height), "Remove"))
                {
                    spawner.spawnAreaList.RemoveAt(spawner.spawnAreaList.Count - 1);
                }
            }

            startY += 10;


            Vector2 v2 = DrawOverrideHitPoint(startX, startY, spawner);

            startY = v2.y - 10;


            if (spawner.spawnMode == _SpawnMode.FreeForm)
            {
                int modeL = (int)spawner.limitType;
                cont = new GUIContent("Limit Type:", "Which mode to determine if the spawning is finished");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont, headerStyle);
                contL = new GUIContent[limitModeLabel.Length];
                for (int i = 0; i < contL.Length; i++)
                {
                    contL[i] = new GUIContent(limitModeLabel[i], limitModeTooltip[i]);
                }
                modeL             = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, 15), new GUIContent(""), modeL, contL);
                spawner.limitType = (_SpawnLimitType)modeL;

                if (spawner.limitType == _SpawnLimitType.Count)
                {
                    cont = new GUIContent(" - Count Limit:", "The maximum amount of unit to be spawned. The spawner will stop spawning after it has spawned this many unit.");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.limitSpawnCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), spawner.limitSpawnCount);
                }
                else if (spawner.limitType == _SpawnLimitType.Timed)
                {
                    cont = new GUIContent(" - Time Limit:", "The time duration in second which the spawner will be spawning. The spawner will stop spawning when the time is due");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.limitSpawnTime = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), spawner.limitSpawnTime);
                }
                else if (spawner.limitType == _SpawnLimitType.None)
                {
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "");
                    EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "Infinite Spawn");
                }


                cont = new GUIContent("Spawn Cooldown:", "The cooldown between each unit spawn");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                spawner.spawnCD = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), spawner.spawnCD);

                cont = new GUIContent("Active Limit:", "The maximum amount of active spawned unit at any given time");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                spawner.activeLimit = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), spawner.activeLimit);


                startY += 15;


                v2     = DrawSpawnUnitList(startX, startY, spawner);
                startY = v2.y;
            }
            else if (spawner.spawnMode == _SpawnMode.WaveBased)
            {
                cont = new GUIContent("Waves Cooldown:", "cooldown between each wave");
                EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                spawner.delayBetweenWave = EditorGUI.FloatField(new Rect(startX + spaceX, startY, 40, height), spawner.delayBetweenWave);


                startY += 10;


                if (spawner.endlessWave)
                {
                    cont = new GUIContent("MaxSubWaveCount:", "Maximum subwave allow for each generated wave");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.maxSubWaveCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, 40, height), spawner.maxSubWaveCount);

                    startY += 5;
                    float cachedX = startX;   float spX = 70;

                    cont = new GUIContent("Unit Count:", "starting unit count for each wave");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.unitCount = EditorGUI.IntField(new Rect(startX + spX, startY, 40, height), spawner.unitCount);

                    cont = new GUIContent("Increment:", "increment in unit count for each subsequent wave");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.unitCountInc = EditorGUI.IntField(new Rect(startX + spX, startY, 40, height), spawner.unitCountInc);

                    startY -= 2 * spaceY;       startX += 125;

                    cont = new GUIContent("Credit:", "starting unit count for each wave");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.startingCredit = EditorGUI.IntField(new Rect(startX + spX, startY, 40, height), spawner.startingCredit);

                    cont = new GUIContent("Increment:", "increment in unit count for each subsequent wave");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.creditIncrement = EditorGUI.IntField(new Rect(startX + spX, startY, 40, height), spawner.creditIncrement);

                    startY -= 2 * spaceY;       startX += 125;

                    cont = new GUIContent("Score:", "starting unit count for each wave");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.startingScore = EditorGUI.IntField(new Rect(startX + spX, startY, 40, height), spawner.startingScore);

                    cont = new GUIContent("Increment:", "increment in unit count for each subsequent wave");
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), cont);
                    spawner.scoreIncrement = EditorGUI.IntField(new Rect(startX + spX, startY, 40, height), spawner.scoreIncrement);


                    startY += 15;
                    startX  = cachedX;

                    v2     = DrawSpawnUnitList(startX, startY, spawner);
                    startY = v2.y;
                }
                else
                {
                    EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Waves Count: " + spawner.waveList.Count, headerStyle);
                    if (GUI.Button(new Rect(startX + spaceX, startY, 40, 16), "+"))
                    {
                        spawner.waveList.Add(new Wave());
                    }
                    if (GUI.Button(new Rect(startX + spaceX + 50, startY, 40, 16), "-"))
                    {
                        if (spawner.waveList.Count > 1)
                        {
                            spawner.waveList.RemoveAt(spawner.waveList.Count - 1);
                        }
                    }

                    for (int i = 0; i < spawner.waveList.Count; i++)
                    {
                        Wave wave = spawner.waveList[i];

                        startY += spaceY + 10;

                        GUI.Box(new Rect(startX + 25, startY, 655, (2 + wave.subWaveList.Count) * spaceY + 15), "");

                        startX += 5;
                        startY += 5;

                        EditorGUI.LabelField(new Rect(startX, startY, width, height), (i + 1) + ".");

                        startX += 25;
                        //cont=new GUIContent("Credit:", "The credit gained upon clearing the wave");
                        //EditorGUI.LabelField(new Rect(startX, startY, width, height), cont);
                        //wave.creditGain=EditorGUI.IntField(new Rect(startX+45, startY, 40, height), wave.creditGain);

                        cont = new GUIContent("Score:", "The score gained upon clearing the wave");
                        EditorGUI.LabelField(new Rect(startX + 110, startY, width, height), cont);
                        wave.scoreGain = EditorGUI.IntField(new Rect(startX + 154, startY, 40, height), wave.scoreGain);


                        GUI.color = new Color(1f, 0.7f, 0.7f, 1f);
                        if (GUI.Button(new Rect(startX + 585, startY, 55, 16), "remove"))
                        {
                            spawner.waveList.RemoveAt(i);   i -= 1;
                            continue;
                        }
                        GUI.color = Color.white;

                        startY += 5;

                        EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Sub Waves:");
                        if (GUI.Button(new Rect(startX + spaceX - 20, startY, 40, 16), "+"))
                        {
                            wave.subWaveList.Add(new SubWave());
                        }
                        if (GUI.Button(new Rect(startX + spaceX + 30, startY, 40, 16), "-"))
                        {
                            if (wave.subWaveList.Count > 1)
                            {
                                wave.subWaveList.RemoveAt(wave.subWaveList.Count - 1);
                            }
                        }

                        for (int n = 0; n < wave.subWaveList.Count; n++)
                        {
                            SubWave subWave = wave.subWaveList[n];

                            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, 15), "-");

                            int unitIdx = subWave.unitPrefab != null?TDSEditor.GetUnitAIIndex(subWave.unitPrefab.prefabID) : 0;

                            unitIdx = EditorGUI.Popup(new Rect(startX + 20, startY, width, 15), unitIdx, unitAILabel);
                            if (unitIdx == 0)
                            {
                                subWave.unitPrefab = null;
                            }
                            else if (unitIdx > 0)
                            {
                                subWave.unitPrefab = unitAIDB.unitList[unitIdx - 1];
                            }

                            float cachedX = startX;

                            cont = new GUIContent("Count:", "The number of unit to be spawned");
                            EditorGUI.LabelField(new Rect(startX += 180, startY, width, height), cont);
                            subWave.count = EditorGUI.IntField(new Rect(startX + 45, startY, 25, height), subWave.count);

                            cont = new GUIContent("Delay:", "Delay (in second) before the spawning start");
                            EditorGUI.LabelField(new Rect(startX += 90, startY, width, height), cont);
                            subWave.startDelay = EditorGUI.FloatField(new Rect(startX + 42, startY, 25, height), subWave.startDelay);

                            cont = new GUIContent("Interval:", "The spawn interval (in second) between each unit");
                            EditorGUI.LabelField(new Rect(startX += 80, startY, width, height), cont);
                            subWave.interval = EditorGUI.FloatField(new Rect(startX + 52, startY, 25, height), subWave.interval);

                            cont = new GUIContent("Alt-Area:", "The area which the unit of this wave should be spawned, replacing the default area (optional)");
                            EditorGUI.LabelField(new Rect(startX += 90, startY, width, height), cont);
                            wave.spawnArea = (TDSArea)EditorGUI.ObjectField(new Rect(startX + 60, startY, 100, height), wave.spawnArea, typeof(TDSArea), true);


                            if (wave.subWaveList.Count > 1)
                            {
                                if (GUI.Button(new Rect(startX + 180, startY, 20, 16), "X"))
                                {
                                    wave.subWaveList.RemoveAt(n);   n -= 1;
                                }
                            }

                            startX = cachedX;
                        }

                        startX -= 5;
                        startY += 5;

                        startX -= 25;
                    }
                }
            }

            return(new Vector2(startX, startY + (2 * spaceY)));
        }