Exemple #1
0
        protected void DrawButtons()
        {
            BeginHorizontal();
            if (GUILayout.Button("Show In Editor"))
            {
                if (target is UnitTower)
                {
                    UnitTowerEditorWindow.Init();
                    UnitTowerEditorWindow.window.Select(((Unit)target).unitName);
                }
                if (target is UnitCreep)
                {
                    UnitCreepEditorWindow.Init();
                    UnitCreepEditorWindow.window.Select(((Unit)target).unitName);
                }
            }

            if (GUILayout.Button("Apply"))
            {
                //PrefabUtility.RecordPrefabInstancePropertyModifications(target);
                EditorUtility.SetDirty(target);
                EditorUtility.SetDirty(PrefabUtility.GetPrefabObject(target));
                AssetDatabase.SaveAssets();
            }
            EndHorizontal();
        }
Exemple #2
0
        public static void Init()
        {
            // Get existing open window or if none, make a new one:
            window = (UnitCreepEditorWindow)EditorWindow.GetWindow <UnitCreepEditorWindow>("Creep Editor");
            //~ window.minSize=new Vector2(375, 449);
            //~ window.maxSize=new Vector2(375, 800);

            EditorDBManager.Init();

            InitLabel();
            UpdateObjectHierarchyList();
        }
Exemple #3
0
 public static void OpenCreepEditor()
 {
     UnitCreepEditorWindow.Init();
 }
Exemple #4
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }
            if (instance == null)
            {
                EditorGUI.LabelField(new Rect(5, 5, 350, 18), "No SpawnManager in current scene");
                GetSpawnManager();
                return;
            }

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


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

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

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


            float startX = 5;
            float startY = 5;


            int spawnMode = (int)instance.spawnMode;

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

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


            int spawnLimit = (int)instance.spawnLimit;

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

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

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

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

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

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

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

            startY += 35;
            float waveConfigStartY = startY;

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

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

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

            startX += 5;
            startY += 10;

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

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

            startX = cachedX;
            startY = v2.y;

            GUI.EndScrollView();

            contentHeight = startY - waveConfigStartY;

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