Beispiel #1
0
 protected override void ShiftItemDown()
 {
     if (selectID < CreepDB.GetList().Count - 1)
     {
         ShiftItem(1);
     }
 }
Beispiel #2
0
        private static void LoadCreep()
        {
            creepDBPrefab = CreepDB.LoadDB();
            creepList     = creepDBPrefab.creepList;

            for (int i = 0; i < creepList.Count; i++)
            {
                //creepList[i].prefabID=i;
                if (creepList[i] != null)
                {
                    creepIDList.Add(creepList[i].prefabID);
                    if (creepList[i].stats.Count == 0)
                    {
                        creepList[i].stats.Add(new UnitStat());
                    }
                }
                else
                {
                    creepList.RemoveAt(i);
                    i -= 1;
                }
            }

            UpdateCreepNameList();
        }
Beispiel #3
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window         = (SpawnEditorWindow)EditorWindow.GetWindow(typeof(SpawnEditorWindow));
            window.minSize = new Vector2(670, 620);


            int enumLength = Enum.GetValues(typeof(SpawnManager._SpawnMode)).Length;

            spawnModeLabel   = new string[enumLength];
            spawnModeTooltip = new string[enumLength];
            for (int i = 0; i < enumLength; i++)
            {
                spawnModeLabel[i] = ((SpawnManager._SpawnMode)i).ToString();
                if ((SpawnManager._SpawnMode)i == SpawnManager._SpawnMode.Continous)
                {
                    spawnModeTooltip[i] = "A new wave is spawn upon every wave duration countdown (with option to skip the timer)";
                }
                if ((SpawnManager._SpawnMode)i == SpawnManager._SpawnMode.WaveCleared)
                {
                    spawnModeTooltip[i] = "A new wave is spawned when the current wave is cleared (with option to spawn next wave in advance)";
                }
                if ((SpawnManager._SpawnMode)i == SpawnManager._SpawnMode.Round)
                {
                    spawnModeTooltip[i] = "Each wave is treated like a round. a new wave can only take place when the previous wave is cleared. Each round require initiation from user";
                }
            }


            creepList = CreepDB.Load();
            rscList   = ResourceDB.Load();
            GetSpawnManager();
        }
Beispiel #4
0
        public void UpdateUnitList()
        {
            List <GenItem>   newItemList = new List <GenItem>();
            List <UnitCreep> unitList    = CreepDB.GetList();

            for (int i = 0; i < unitList.Count; i++)
            {
                int idx = -1;
                for (int n = 0; n < genItemList.Count; n++)
                {
                    if (genItemList[n].unitPrefabID == unitList[i].prefabID)
                    {
                        idx = n; break;
                    }
                }

                if (idx < 0)
                {
                    newItemList.Add(new GenItem(unitList[i]));
                    newItemList[i].SetAllOverride(true);
                }
                else
                {
                    newItemList.Add(genItemList[idx]);
                }
            }

            genItemList = newItemList;
        }
Beispiel #5
0
        private void ShiftItem(int dir)
        {
            UnitCreep creep = CreepDB.GetList()[selectID];

            CreepDB.GetList()[selectID]       = CreepDB.GetList()[selectID + dir];
            CreepDB.GetList()[selectID + dir] = creep;
            selectID += dir;
        }
Beispiel #6
0
 public static CreepDB Init()
 {
     if (instance != null)
     {
         return(instance);
     }
     instance = LoadDB();
     return(instance);
 }
Beispiel #7
0
 private void SelectItem(int newID)
 {
     selectID = newID;
     if (CreepDB.GetList().Count <= 0)
     {
         return;
     }
     selectID = Mathf.Clamp(selectID, 0, CreepDB.GetList().Count - 1);
     UpdateObjHierarchyList(CreepDB.GetList()[selectID].transform);
 }
Beispiel #8
0
        //for filling up  empty unit of spawnManager
        public static UnitCreep GetFirstPrefab()
        {
            GameObject obj = Resources.Load("DB_TDTK/CreepDB", typeof(GameObject)) as GameObject;

                        #if UNITY_EDITOR
            if (obj == null)
            {
                obj = CreatePrefab();
            }
                        #endif

            CreepDB instance = obj.GetComponent <CreepDB>();
            return(instance.creepList.Count == 0 ? null : instance.creepList[0]);
        }
Beispiel #9
0
        private int _NewItem(UnitCreep creep)
        {
            if (CreepDB.GetList().Contains(creep))
            {
                return(selectID);
            }

            creep.prefabID = TDE.GenerateNewID(CreepDB.GetPrefabIDList());

            CreepDB.GetList().Add(creep);
            CreepDB.UpdateLabel();

            return(CreepDB.GetList().Count - 1);
        }
Beispiel #10
0
        private static void New2()
        {
            CreateEmptyScene();

            GameObject obj = (GameObject)Instantiate(Resources.Load("ScenePrefab/TDTK_OpenPath", typeof(GameObject)));

            obj.name = "TDTK_OpenPath";

            SpawnManager spawnManager = (SpawnManager)FindObjectOfType(typeof(SpawnManager));

            if (spawnManager.waveList[0].subWaveList[0].unit == null)
            {
                spawnManager.waveList[0].subWaveList[0].unit = CreepDB.GetFirstPrefab().gameObject;
            }
        }
Beispiel #11
0
        public static void Init(int prefabID = -1)
        {
            window         = (UnitCreepEditorWindow)EditorWindow.GetWindow(typeof(UnitCreepEditorWindow), false, "CreepEditor");
            window.minSize = new Vector2(420, 300);

            TDE.Init();

            InitLabel();

            if (prefabID >= 0)
            {
                window.selectID = CreepDB.GetPrefabIndex(prefabID);
            }

            window.SelectItem(window.selectID);
        }
Beispiel #12
0
        static void New2()
        {
            EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects);
            GameObject camObj = Camera.main.gameObject;       DestroyImmediate(camObj);

            GameObject obj = (GameObject)Instantiate(Resources.Load("ScenePrefab/Template_OpenPath", typeof(GameObject)));

            obj.name = "TDTK_OpenPath";

            SpawnManager spawnManager = (SpawnManager)FindObjectOfType(typeof(SpawnManager));

            if (spawnManager.waveList[0].subWaveList[0].unit == null)
            {
                spawnManager.waveList[0].subWaveList[0].unit = CreepDB.GetFirstPrefab().gameObject;
            }
        }
		private static void LoadCreep(){
			creepDBPrefab=CreepDB.LoadDB();
			creepList=creepDBPrefab.creepList;
			
			for(int i=0; i<creepList.Count; i++){
				//creepList[i].prefabID=i;
				if(creepList[i]!=null){
					creepIDList.Add(creepList[i].prefabID);
					if(creepList[i].stats.Count==0) creepList[i].stats.Add(new UnitStat());
				}
				else{
					creepList.RemoveAt(i);
					i-=1;
				}
			}
			
			UpdateCreepNameList();
		}
Beispiel #14
0
        public static void LoadCreep()
        {
            creepDB = CreepDB.LoadDB();

            for (int i = 0; i < creepDB.creepList.Count; i++)
            {
                if (creepDB.creepList[i] != null)
                {
                    creepIDList.Add(creepDB.creepList[i].prefabID);
                }
                else
                {
                    creepDB.creepList.RemoveAt(i);    i -= 1;
                }
            }

            UpdateLabel_Creep();

            TDEditorWindow.SetCreepDB(creepDB, creepIDList, creepLabel);
            TDEditorInspector.SetCreepDB(creepDB, creepIDList, creepLabel);
        }
Beispiel #15
0
        public static void Init()
        {
            if (init)
            {
                return;
            }

            init = true;                //Debug.Log(" - Init Editor - ");

            damageTableDB = DamageTableDB.Init();
            rscDB         = RscDB.Init();
            towerDB       = TowerDB.Init();
            creepDB       = CreepDB.Init();
            abilityDB     = AbilityDB.Init();
            perkDB        = PerkDB.Init();
            effectDB      = EffectDB.Init();

            DamageTableDB.UpdateLabel();
            TowerDB.UpdateLabel();
            CreepDB.UpdateLabel();
            AbilityDB.UpdateLabel();
            PerkDB.UpdateLabel();
            EffectDB.UpdateLabel();
        }
Beispiel #16
0
        private Vector2 DrawUnitConfigurator(float startX, float startY, UnitCreep unit)
        {
            float maxX = startX;

            startY = TDE.DrawBasicInfo(startX, startY, unit);

            int type = (int)unit.creepType;

            cont  = new GUIContent("Creep Type:", "Type of the creep. Each type of creep serve a different function");
            contL = TDE.SetupContL(creepTypeLabel, creepTypeTooltip);
            EditorGUI.LabelField(new Rect(startX + 12, startY, width, height), cont);
            type           = EditorGUI.Popup(new Rect(startX + spaceX + 12, startY, width, height), new GUIContent(""), type, contL);
            unit.creepType = (UnitCreep._CreepType)type;

            showTypeDesp = EditorGUI.ToggleLeft(new Rect(startX + spaceX + width + 12, startY, width, 20), "Show Description", showTypeDesp);
            if (showTypeDesp)
            {
                EditorGUI.HelpBox(new Rect(startX, startY += spaceY, width + spaceX, 40), creepTypeTooltip[(int)unit.creepType], MessageType.Info);
                startY += 45 - height;
            }


            startY = DrawGeneralSetting(startX, startY + spaceY + 10, unit);

            startY = DrawMovementSetting(startX, startY + spaceY, unit);


            startY += spaceY * 2;


            _EType cType = _EType.CDefault;

            if (unit.IsTurret())
            {
                cType = _EType.CTurret;
            }
            else if (unit.IsAOE())
            {
                cType = _EType.CAOE;
            }
            else if (unit.IsSupport())
            {
                cType = _EType.CSupport;
            }
            else if (unit.IsSpawner())
            {
                cType = _EType.CSpawner;
            }

            string text = "Unit Stats ";          //+ !foldStats ? "(show)" : "(hide)" ;

            foldStats = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldStats, text, TDE.foldoutS);
            if (foldStats)
            {
                startY = DrawStats(startX, startY + spaceY, unit.statsList[0], cType) - spaceY;

                if (unit.IsSpawner())
                {
                    startX += 12;     startY += 10;

                    TDE.Label(startX, startY += spaceY, width, height, "Spawn Prefab:", "Creep prefab to be spawned");
                    int idx = CreepDB.GetPrefabIndex(unit.spawnerPrefab);
                    idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, CreepDB.label);
                    unit.spawnerPrefab = CreepDB.GetItem(idx);
                    if (unit.spawnerPrefab == unit)
                    {
                        unit.spawnerPrefab = null;
                    }

                    if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
                    {
                        unit.spawnOnDestroyed = null;
                    }

                    TDE.Label(startX, startY += spaceY, width, height, " - Num to Spawn:", "The amount of SpawnOnDestroyed creep to spawn when this unit is destroyed");
                    if (unit.spawnerPrefab != null)
                    {
                        unit.spawnerCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.spawnerCount);
                    }
                    else
                    {
                        TDE.Label(startX + spaceX, startY, widthS, height, "-");
                    }

                    bool valid = unit.spawnerPrefab != null && unit.spawnerCount > 0;

                    startY = DrawSpawnOverride(startX, startY, unit.spawnerOverride, valid, foldSpawnerOverride, SetFoldSpawnerOverride);

                    startX -= 12;
                }
            }


            startY = DrawCreepVisualEffect(startX, startY + spaceY, unit);

            startY = DrawUnitAnimation(startX, startY + spaceY, unit);

            startY += spaceY;


            GUIStyle style = new GUIStyle("TextArea");        style.wordWrap = true;

            cont = new GUIContent("Unit description (for runtime and editor): ", "");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 400, 20), cont);
            unit.desp = EditorGUI.TextArea(new Rect(startX, startY + spaceY - 3, 270, 150), unit.desp, style);


            return(new Vector2(maxX, startY + 170));
        }
Beispiel #17
0
 public static void SetCreepDB(CreepDB db, List <int> IDList, string[] label)
 {
     creepDB     = db;
     creepIDList = IDList;
     creepLabel  = label;
 }
Beispiel #18
0
        public void OnGUI()
        {
            TDE.InitGUIStyle();

            if (!CheckIsPlaying())
            {
                return;
            }
            if (window == null)
            {
                Init();
            }


            List <UnitCreep> creepList = CreepDB.GetList();

            Undo.RecordObject(this, "window");
            Undo.RecordObject(CreepDB.GetDB(), "creepDB");
            if (creepList.Count > 0)
            {
                Undo.RecordObject(creepList[selectID], "creep");
            }


            if (GUI.Button(new Rect(Math.Max(260, window.position.width - 120), 5, 100, 25), "Save"))
            {
                TDE.SetDirty();
            }

            UnitCreep newCreep = null;

            TDE.Label(5, 7, 150, 17, "Add New Creep:", "Drag creep prefab to this slot to add it to the list");
            newCreep = (UnitCreep)EditorGUI.ObjectField(new Rect(115, 7, 150, 17), newCreep, typeof(UnitCreep), false);
            if (newCreep != null)
            {
                Select(NewItem(newCreep));
            }


            float startX = 5; float startY = 55;

            if (minimiseList)
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), ">>"))
                {
                    minimiseList = false;
                }
            }
            else
            {
                if (GUI.Button(new Rect(startX, startY - 20, 30, 18), "<<"))
                {
                    minimiseList = true;
                }
            }

            Vector2 v2 = DrawCreepList(startX, startY, creepList);

            startX = v2.x + 25;

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


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

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

            v2            = DrawUnitConfigurator(startX, startY, creepList[selectID]);
            contentWidth  = v2.x - startX;
            contentHeight = v2.y - 55;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                TDE.SetDirty();
            }
        }
Beispiel #19
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            if (instance == null)
            {
                Awake(); return;
            }

            GUI.changed = false;

            EditorGUILayout.Space();

            PrefabType type = PrefabUtility.GetPrefabType(instance);

            if (type == PrefabType.Prefab || type == PrefabType.PrefabInstance)
            {
                UnitCreep prefab = instance;
                if (type == PrefabType.PrefabInstance)
                {
                    prefab = (UnitCreep)PrefabUtility.GetCorrespondingObjectFromSource(instance);
                }
                bool existInDB = CreepDB.GetPrefabIndex(prefab) >= 0;

                if (!existInDB)
                {
                    if (instance.prefabID >= 0)
                    {
                        instance.prefabID = -1; EditorUtility.SetDirty(instance);
                    }

                    EditorGUILayout.Space();

                    EditorGUILayout.HelpBox("This prefab hasn't been added to database hence it won't be accessible to the game.", MessageType.Warning);
                    GUI.color = new Color(1f, 0.7f, .2f, 1f);
                    if (GUILayout.Button("Add Prefab to Database"))
                    {
                        UnitCreepEditorWindow.Init();
                        UnitCreepEditorWindow.NewItem(instance);
                        UnitCreepEditorWindow.Init();                                   //call again to select the instance in editor window
                    }
                    GUI.color = Color.white;
                }
                else
                {
                    EditorGUILayout.HelpBox("Editing creep using Inspector is not recommended.\nPlease use the editor window instead", MessageType.Info);
                    if (GUILayout.Button("Creep Editor Window"))
                    {
                        UnitCreepEditorWindow.Init(instance.prefabID);
                    }
                }

                EditorGUILayout.Space();
            }
            else
            {
                if (instance.prefabID >= 0)
                {
                    instance.prefabID = -1; EditorUtility.SetDirty(instance);
                }

                string text = "Creep object won't be available to be deployed to game, or accessible in TDTK editor until it's made a prefab and added to TDTK database.";
                text += "\n\nYou can still edit the creep using default inspector. However it's not recommended";
                EditorGUILayout.HelpBox(text, MessageType.Warning);

                EditorGUILayout.Space();
                if (GUILayout.Button("Creep Editor Window"))
                {
                    UnitCreepEditorWindow.Init(instance.prefabID);
                }
            }


            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Beispiel #20
0
 protected override void DeleteItem()
 {
     CreepDB.GetList().RemoveAt(deleteID);
     CreepDB.UpdateLabel();
 }
Beispiel #21
0
        private float DrawSubWaveBlock(float startX, float startY, SubWave subWave, int index, int wIdx)
        {
            float spaceX = 60;        float cachedY = startY;           width -= 10;

            subWaveBlockWidth = spaceX + width + 5;
            GUI.Box(new Rect(startX, startY, subWaveBlockWidth, subWaveBlockHeight), "");

            startX += 3; startY += 3;

            //TDE.Label(startX, startY, width, height, "Prefab: ", "");
            //subWave.prefab=(UnitCreep)EditorGUI.ObjectField(new Rect(startX+spaceX, startY, width, height), subWave.prefab, typeof(UnitCreep), true);	startY+=spaceY

            //int index=subWave.prefab!=null ? TDEditor.GetCreepIndex(subWave.unitC.prefabID) : 0 ;
            index = CreepDB.GetPrefabIndex(subWave.prefab);
            TDE.Label(startX, startY, width, height, "Prefab:", "The creep prefab to be spawned");
            index          = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), index, CreepDB.label);
            subWave.prefab = CreepDB.GetItem(index);

            if (subWave.prefab == null)
            {
                GUI.Box(new Rect(startX + subWaveBlockWidth - 5 - height * 2, startY + spaceY, height * 2, height * 2), "");
            }
            else
            {
                TDE.DrawSprite(new Rect(startX + subWaveBlockWidth - 7 - height * 2, startY + spaceY, height * 2, height * 2), subWave.prefab.icon);
            }


            TDE.Label(startX, startY += spaceY, width, height, "Delay: ", "The delay (in second) before the subwave start spawning");
            subWave.delay             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.delay);

            TDE.Label(startX, startY += spaceY, width, height, "Count: ", "How many creep will be spawned for the subwave");
            subWave.spawnCount        = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), subWave.spawnCount);

            TDE.Label(startX, startY += spaceY, width, height, "Spacing: ", "The spawn spacing (in second) between each individual creep");
            subWave.spacing           = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.spacing);

            TDE.Label(startX, startY += spaceY, width, height, "Path: ", "OPTIONAL: The path to used for this subwave. If left unassigned, a random path will be used");
            subWave.path              = (Path)EditorGUI.ObjectField(new Rect(startX + spaceX, startY, width, height), subWave.path, typeof(Path), true);


            if (showOverrideSetting)
            {
                TDE.Label(startX, startY += spaceY + 5f, width, height, "Override Setting:", "Attribute on the default prefab that will be overriden", TDE.headerS);        spaceX += 10;

                TDE.Label(startX, startY += spaceY, width, height, " - HitPoint: ", "");  GUI.color = subWave.HP > 0 ? GUI.color : grey;
                subWave.HP = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.HP);   GUI.color = white;

                TDE.Label(startX, startY += spaceY, width, height, " - Shield: ", "");    GUI.color = subWave.SH >= 0 ? GUI.color : grey;
                subWave.SH = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.SH);   GUI.color = white;

                TDE.Label(startX, startY += spaceY, width, height, " - Speed: ", "");     GUI.color = subWave.speed > 0 ? GUI.color : grey;
                subWave.speed             = EditorGUI.FloatField(new Rect(startX + spaceX, startY, widthS, height), subWave.speed);     GUI.color = white;


                TDE.Label(startX, startY += spaceY, width, height, " - Rsc Gain: ", "");

                RscManager.MatchRscList(subWave.rscGain, -1);

                subWave.overrideRscGain = true;
                for (int i = 0; i < subWave.rscGain.Count; i++)
                {
                    if (subWave.rscGain[i] < 0)
                    {
                        subWave.overrideRscGain = false;
                    }
                }

                float cachedX = startX;                 //startY+=spaceY;
                for (int i = 0; i < RscDB.GetCount(); i++)
                {
                    if (i > 0 && i % 3 == 0)
                    {
                        startX = cachedX - widthS - 2; startY += spaceY;
                    }
                    if (i > 0)
                    {
                        startX += widthS + 2;
                    }

                    TDE.DrawSprite(new Rect(startX + spaceX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                    GUI.color          = subWave.overrideRscGain ? GUI.color : grey;
                    subWave.rscGain[i] = EditorGUI.IntField(new Rect(startX + spaceX + height, startY, widthS - height, height), subWave.rscGain[i]);
                    GUI.color          = white;

                    if (subWave.rscGain[i] < 0 && subWave.overrideRscGain)
                    {
                        subWave.overrideRscGain = false;
                    }
                }
                startX = cachedX;
            }

            width += 10;
            subWaveBlockHeight = startY - cachedY + spaceY + 2;

            return(startY + spaceY);
        }
Beispiel #22
0
        protected float DrawGeneralSetting(float startX, float startY, UnitCreep unit)
        {
            string textF = "General Creep Setting ";          //+(!foldBasicSetting ? "(show)" : "(hide)");

            foldBasicSetting = EditorGUI.Foldout(new Rect(startX, startY, spaceX, height), foldBasicSetting, textF, TDE.foldoutS);
            if (!foldBasicSetting)
            {
                return(startY);
            }

            startX += 12;

            //~ TDE.Label(startX, startY+=spaceY, width, height, "Flying:", "Check to set the creep as flying unit");
            //~ unit.flying=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.flying);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "Turret:", "");
            //~ unit.isTurret=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isTurret);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "AOE:", "");
            //~ unit.isAOE=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isAOE);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "Support:", "");
            //~ unit.isSupport=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSupport);
            //~ TDE.Label(startX, startY+=spaceY, width, height, "Spawner:", "");
            //~ unit.isSpawner=EditorGUI.Toggle(new Rect(startX+spaceX, startY, widthS, height), unit.isSpawner);

            //~ startY+=10;

            TDE.Label(startX, startY += spaceY, width, height, "Immuned Effect:", "The list of effects the unit is immune to");
            for (int i = 0; i < unit.effectImmunityList.Count; i++)
            {
                TDE.Label(startX + spaceX - height, startY, width, height, "-");

                int effIdx = EffectDB.GetPrefabIndex(unit.effectImmunityList[i]);
                effIdx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), effIdx, EffectDB.label);
                if (effIdx >= 0)
                {
                    int effID = EffectDB.GetItem(effIdx).prefabID;
                    if (effID >= 0 && !unit.effectImmunityList.Contains(effID))
                    {
                        unit.effectImmunityList[i] = effID;
                    }
                }

                if (effIdx < 0 || GUI.Button(new Rect(startX + spaceX + width + 3, startY, height, height), "-"))
                {
                    unit.effectImmunityList.RemoveAt(i);
                }

                startY += spaceY;
            }

            int newEffID = -1;

            newEffID = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), newEffID, EffectDB.label);
            if (newEffID >= 0)
            {
                newEffID = EffectDB.GetPrefab(newEffID).prefabID;
            }
            if (newEffID >= 0 && !unit.effectImmunityList.Contains(newEffID))
            {
                unit.effectImmunityList.Add(newEffID);
            }


            startY += 10;


            TDE.Label(startX, startY  += spaceY, width, height, "Life Lost On Dest:", "The amount of life player will lose if the creep reach destination");
            unit.lifeLostOnDestination = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeLostOnDestination);
            unit.lifeLostOnDestination = Mathf.Max(1, unit.lifeLostOnDestination);

            startY += 5;

            TDE.Label(startX, startY += spaceY, width, height, "Gain On Destroyed:", "");

            TDE.Label(startX, startY += spaceY, width, height, " - Life (chance):", "The amount of life player will gain when the creep is destroyed, subject to a chance (takes value from 0-1 with 0.3 being 30%)");
            if (unit.lifeGainedOnDestroyed <= 0)
            {
                GUI.color = grey;
            }
            unit.lifeGainedOnDestroyed = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.lifeGainedOnDestroyed);     GUI.color = white;
            if (unit.lifeGainedOnDestroyedChance <= 0)
            {
                GUI.color = grey;
            }
            unit.lifeGainedOnDestroyedChance = EditorGUI.FloatField(new Rect(startX + spaceX + widthS + 2, startY, widthS, height), unit.lifeGainedOnDestroyedChance);      GUI.color = white;

            //TDE.Label(startX, startY+=spaceY, width, height, " - Expericene:", "Check to set the creep as flying unit");
            //if(unit.expGainOnDestroyed<=0) GUI.color=grey;
            //unit.expGainOnDestroyed=EditorGUI.IntField(new Rect(startX+spaceX, startY, widthS, height), unit.expGainOnDestroyed);	GUI.color=white;

            RscManager.MatchRscList(unit.rscGainOnDestroyed, 0);

            TDE.Label(startX, startY += spaceY, width, height, " - Resource:", "The amount of resource the player will gain when the creep is destroyed");
            float cachedX = startX;   startX += spaceX;

            for (int i = 0; i < RscDB.GetCount(); i++)
            {
                //if(unit.rscGainOnDestroyed[i]==0) GUI.color=grey;

                if (i > 0 && i % 2 == 0)
                {
                    startX = cachedX; startY += spaceY;
                }
                if (i > 0)
                {
                    startX += widthS + 2;
                }
                TDE.DrawSprite(new Rect(startX, startY, height, height), RscDB.GetIcon(i), RscDB.GetName(i));
                unit.rscGainOnDestroyed[i] = EditorGUI.IntField(new Rect(startX + height, startY, widthS - height, height), unit.rscGainOnDestroyed[i]);      GUI.color = white;
            }
            startX = cachedX;

            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "SpawnOnDestroyed:", "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");
            int idx = CreepDB.GetPrefabIndex(unit.spawnOnDestroyed);

            idx = EditorGUI.Popup(new Rect(startX + spaceX, startY, width, height), idx, CreepDB.label);
            unit.spawnOnDestroyed = CreepDB.GetItem(idx);
            if (unit.spawnOnDestroyed == unit)
            {
                unit.spawnOnDestroyed = null;
            }

            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, height, height), "-"))
            {
                unit.spawnOnDestroyed = null;
            }

            TDE.Label(startX, startY += spaceY, width, height, " - Num to Spawn:", "The amount of SpawnOnDestroyed creep to spawn when this unit is destroyed");
            if (unit.spawnOnDestroyed != null)
            {
                unit.sodCount = EditorGUI.IntField(new Rect(startX + spaceX, startY, widthS, height), unit.sodCount);
            }
            else
            {
                TDE.Label(startX + spaceX, startY, widthS, height, "-");
            }

            bool valid = unit.spawnOnDestroyed != null && unit.sodCount > 0;

            startY = DrawSpawnOverride(startX, startY, unit.sodOverride, valid, foldSodOverride, SetFoldSodOverride);


            startY += 10;

            TDE.Label(startX, startY += spaceY, width, height, "Flying:", "Check to set the creep as flying");
            unit.flying = EditorGUI.Toggle(new Rect(startX + spaceX, startY, widthS, height), unit.flying);

            startY = DrawUnitSetting(startX - 12, startY, unit);

            return(startY);
        }
 public static void SetCreepDB(CreepDB db, List <int> IDList, string[] label)            //override by SpawnManagerEditor
 {
     creepDB     = db;
     creepIDList = IDList;
     creepLabel  = label;
 }