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

            EditorDBManager.Init();

            InitLabel();
            UpdateObjectHierarchyList();
        }
Exemple #3
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);
        }
Exemple #4
0
        public static void Init(int prefabID = -1)
        {
            // Get existing open window or if none, make a new one:
            window         = (UnitCreepEditorWindow)EditorWindow.GetWindow(typeof(UnitCreepEditorWindow), false, "Creep Editor");
            window.minSize = new Vector2(420, 300);

            LoadDB();

            InitLabel();

            if (prefabID >= 0)
            {
                window.selectID = TDEditor.GetCreepIndex(prefabID) - 1;
            }

            window.SetupCallback();
        }
        public void OnGUI()
        {
            TDE.InitGUIStyle();

            //if(!CheckIsPlaying()) return;
            if (window == null)
            {
                Init();
            }
            if (instance == null && !GetSpawnManager())
            {
                return;
            }

            Undo.RecordObject(this, "window");
            Undo.RecordObject(instance, "SpawnManager");

            //if(GUI.Button(new Rect(window.position.width-130, 5, 125, 25), "Save")) TDE.SetDirty();
            if (GUI.Button(new Rect(window.position.width - 130, 5, 125, 25), "Creep Editor"))
            {
                UnitCreepEditorWindow.Init();
            }
            //if(GUI.Button(new Rect(window.position.width-130, 35, 125, 25), "Generate")) instance.GenerateWave();

            if (!instance.endlessMode && !instance.genWaveOnStart)
            {
                string text = configureGenerator ? "Wave List" : "Configure";
                if (GUI.Button(new Rect(window.position.width - 130, 35, 125, 25), text))
                {
                    configureGenerator = !configureGenerator;
                }
            }
            else
            {
                configureGenerator = false;
            }


            float startX = 5; float startY = 5; width = 150;

            startY = DrawGeneralSetting(startX, startY) + 5;

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

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

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

            if (!instance.endlessMode && !instance.genWaveOnStart && !configureGenerator)
            {
                startY       = DrawWaveList(startX, startY + 5);
                contentWidth = (subWaveBlockWidth + 10) * maxSubWaveSize + 20;
            }
            else
            {
                startY       = DrawGeneratorParameter(startX, startY + 5);
                contentWidth = (RscDB.GetCount() + 5) * (genAttBlockWidth + 10) + 75;
            }

            contentHeight = startY - visibleRect.y - spaceY * 2;

            GUI.EndScrollView();


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
            if (GUI.changed)
            {
                TDE.SetDirty();
            }
        }
Exemple #6
0
 static void OpenCreepEditor()
 {
     UnitCreepEditorWindow.Init();
 }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            EditorGUILayout.Space();



            PrefabType type = PrefabUtility.GetPrefabType(instance);

            if (type == PrefabType.Prefab || type == PrefabType.PrefabInstance)
            {
                bool existInDB = false;
                if (type == PrefabType.PrefabInstance)
                {
                    existInDB = TDEditor.ExistInDB((UnitCreep)PrefabUtility.GetPrefabParent(instance));
                }
                else if (type == PrefabType.Prefab)
                {
                    existInDB = TDEditor.ExistInDB(instance);
                }

                if (!existInDB)
                {
                    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
            {
                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);
            }
        }
Exemple #8
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }
            if (instance == null)
            {
                EditorGUI.LabelField(new Rect(5, 5, 350, 18), "No SpawnManager in current scene");
                GetSpawnManager();
                return;
            }

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


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

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

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


            float startX = 5;
            float startY = 5;


            int spawnMode = (int)instance.spawnMode;

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

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


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

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


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

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

            cont = new GUIContent("Waves Size: " + instance.waveList.Count, "Number of waves in the level");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, 15), cont);
            if (GUI.Button(new Rect(startX + spaceX, startY - 1, 40, 15), "-1"))
            {
                if (instance.waveList.Count > 1)
                {
                    instance.waveList.RemoveAt(instance.waveList.Count - 1);
                    waveFoldList.RemoveAt(waveFoldList.Count - 1);
                }
            }
            if (GUI.Button(new Rect(startX + spaceX + 50, startY - 1, 40, 15), "+1"))
            {
                instance.waveList.Add(instance.waveList[instance.waveList.Count - 1].Clone());
                waveFoldList.Add(true);
            }


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

            startY += 35;
            float waveConfigStartY = startY;

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

            contentWidth = 0;
            //~ if(instance.spawnLimit==SpawnManager._SpawnLimit.Finite){
            GUI.color = new Color(.8f, .8f, .8f, 1f);
            GUI.Box(visibleRect, "");
            GUI.color = Color.white;
            //~ }

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

            startX += 5;
            startY += 10;

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

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

            startX = cachedX;
            startY = v2.y;

            GUI.EndScrollView();

            //EditorGUI.LabelField(new Rect(startX, startY, width, height), "---------------------------------------");
            contentHeight = startY - waveConfigStartY;

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
        public override bool OnGUI()
        {
            if (!base.OnGUI())
            {
                return(true);
            }

            if (window == null)
            {
                Init();
            }

            if (instance == null && !GetSpawnManager())
            {
                return(true);
            }

            Undo.RecordObject(this, "window");
            Undo.RecordObject(instance, "SpawnManager");

            UpdateProceduralUnitList();

            configureProcedural = instance.spawnLimit == SpawnManager._SpawnLimit.Infinite | configureProceduralSetting | instance.procedurallyGenerateWave;

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

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

            if (GUI.Button(new Rect(window.position.width - 130, 110, 125, 25), "Save"))
            {
                SetDirtyTD();
            }

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


            float startX = 5; float startY = 5;

            startY = DrawGeneralSetting(startX, startY) + 10;

            if (!configureProcedural)
            {
                EditorGUI.LabelField(new Rect(startX, startY, 2 * width, height), "Spawn Info (wave list)", headerStyle);
            }
            else
            {
                EditorGUI.LabelField(new Rect(startX, startY, 2 * width, height), "Procedural Wave Generation Parameters", headerStyle);
            }


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


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


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

            if (configureProcedural)
            {
                startY = DrawProceduralSetting(startX += 5, startY += 5) + 10;

                contentWidth  = proUnitItemWidth + 10;
                contentHeight = startY - visibleRect.y;
            }
            else
            {
                startY = DrawSpawnInfo(startX += 5, startY += 5);

                maxSubWaveSize = 1;
                for (int i = 0; i < instance.waveList.Count; i++)
                {
                    maxSubWaveSize = Mathf.Max(instance.waveList[i].subWaveList.Count, maxSubWaveSize);
                }

                contentWidth  = (subWaveBoxWidth + 10) * maxSubWaveSize + 60;
                contentHeight = startY - visibleRect.y;
            }

            GUI.EndScrollView();


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

            return(true);
        }