Beispiel #1
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();
        }
        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(480, 620);

            int enumLength = Enum.GetValues(typeof(SpawnManager._SpawnLimit)).Length;
            spawnLimitLabel=new string[enumLength];
            spawnLimitTooltip=new string[enumLength];
            for(int i=0; i<enumLength; i++){
                spawnLimitLabel[i]=((SpawnManager._SpawnLimit)i).ToString();
                if((SpawnManager._SpawnLimit)i==SpawnManager._SpawnLimit.Finite) spawnLimitTooltip[i]="Finite number of waves";
                if((SpawnManager._SpawnLimit)i==SpawnManager._SpawnLimit.Infinite) spawnLimitTooltip[i]="Infinite number of waves (for survival or endless mode)";
            }

            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 #3
0
        public static void Init(SpawnManager smInstance = null)
        {
            // Get existing open window or if none, make a new one:
            window         = (SpawnEditorWindow)EditorWindow.GetWindow(typeof(SpawnEditorWindow), false, "SpawnEditor");
            window.minSize = new Vector2(500, 300);

            TDE.Init();

            InitLabel();

            if (smInstance != null)
            {
                instance = smInstance;
            }
        }
        public override void OnInspectorGUI()
        {
            EditorGUILayout.Space();

            int spawnMode = (int)instance.spawnMode;

            cont     = new GUIContent("Spawn Mode:", "Spawn mode in this level");
            contList = new GUIContent[spawnModeLabel.Length];
            for (int i = 0; i < contList.Length; i++)
            {
                contList[i] = new GUIContent(spawnModeLabel[i], spawnModeTooltip[i]);
            }
            spawnMode          = EditorGUILayout.Popup(cont, spawnMode, contList);
            instance.spawnMode = (SpawnManager._SpawnMode)spawnMode;


            cont = new GUIContent("Allow Skip:", "Allow player to skip ahead and spawn the next wave");
            instance.allowSkip = EditorGUILayout.Toggle(cont, instance.allowSkip);


            cont = new GUIContent("Auto Start: ", "Check to have the spawning start on a fixed timer. Rather than waiting for player initiation");
            instance.autoStart = EditorGUILayout.Toggle(cont, instance.autoStart);

            if (instance.autoStart)
            {
                cont = new GUIContent(" - Start Delay: ", "The duration to wait in second before the spawning start");
                instance.autoStartDelay = EditorGUILayout.FloatField(cont, instance.autoStartDelay);
            }

            cont = new GUIContent("Auto-Gen Wave:", "Check to have the SpawnManager automatically generate the wave in runtime as opposed to using preset data");
            instance.procedurallyGenerateWave = EditorGUILayout.Toggle(cont, 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");
            instance.defaultPath = (PathTD)EditorGUILayout.ObjectField(cont, instance.defaultPath, typeof(PathTD), true);

            EditorGUILayout.Space();


            EditorGUILayout.HelpBox("Editing of spawnInfo via Inspector is not recommended. Please use SpawnEditorWindow instead", MessageType.Info);


            if (GUILayout.Button("Open SpawnEditorWindow"))
            {
                SpawnEditorWindow.Init();
            }

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("", GUILayout.MaxWidth(10));
            showDefaultFlag = EditorGUILayout.Foldout(showDefaultFlag, "Show default editor");
            EditorGUILayout.EndHorizontal();
            if (showDefaultFlag)
            {
                DrawDefaultInspector();
            }


            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

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

            GUI.changed = false;

            Undo.RecordObject(instance, "SpawnManager");

            EditorGUILayout.Space();

            cont = new GUIContent("Endless Mode:", "Check to enable endless mode");
            instance.endlessMode = EditorGUILayout.Toggle(cont, instance.endlessMode);

            cont = new GUIContent("Generate On Start:", "Check to have the waves regenerated at the start of game. All preset setting will be overwritten.");
            if (instance.endlessMode)
            {
                EditorGUILayout.LabelField("Generate On Start:", "-");
            }
            else
            {
                instance.genWaveOnStart = EditorGUILayout.Toggle(cont, instance.genWaveOnStart);
            }


            int spawnCDType = (int)instance.spawnCDType;

            cont                 = new GUIContent("Spawn CD Type:", "Spawn CD Type used in this level");
            contL                = TDE.SetupContL(spawnCDTypeLabel, spawnCDTypeTooltip);
            spawnCDType          = EditorGUILayout.Popup(cont, spawnCDType, contL);
            instance.spawnCDType = (SpawnManager._SpawnCDType)spawnCDType;

            cont = new GUIContent("Skippable:", "Allow player to skip ahead and spawn the next wave");
            if (instance.spawnCDType == SpawnManager._SpawnCDType.None)
            {
                EditorGUILayout.LabelField("Skippable:", "-");
            }
            else
            {
                instance.skippable = EditorGUILayout.Toggle(cont, instance.skippable);
            }


            cont = new GUIContent("Auto Start:", "Check to start the game on a timer instead of waiting for player initiation");
            instance.autoStart = EditorGUILayout.Toggle(cont, instance.autoStart);

            cont = new GUIContent(" - Start Timer:", "Delay in second before the spawn start automatically");
            if (!instance.autoStart)
            {
                EditorGUILayout.LabelField(" - Start Timer:", "-");
            }
            else
            {
                instance.startTimer = EditorGUILayout.FloatField(cont, instance.startTimer);
            }

            EditorGUILayout.Space();

            EditorGUILayout.HelpBox("Editing wave Information using Inspector is not recommended.\nPlease use SpawnEditorWindow instead", MessageType.Info);
            if (GUILayout.Button("Open SpawnEditorWindow"))
            {
                SpawnEditorWindow.Init();
            }

            EditorGUILayout.Space();

            DefaultInspector();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(instance);
            }
        }
Beispiel #6
0
 static void OpenSpawnEditor()
 {
     SpawnEditorWindow.Init();
 }
Beispiel #7
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            GUI.changed = false;

            Undo.RecordObject(instance, "SpawnManager");

            EditorGUILayout.Space();


            int spawnMode = (int)instance.spawnMode;

            cont  = new GUIContent("Spawn Mode:", "Spawn mode in this level");
            contL = new GUIContent[spawnModeLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(spawnModeLabel[i], spawnModeTooltip[i]);
            }
            spawnMode          = EditorGUILayout.Popup(cont, spawnMode, contL);
            instance.spawnMode = (SpawnManager._SpawnMode)spawnMode;

            int spawnLimit = (int)instance.spawnLimit;

            cont  = new GUIContent("Spawn Count:", "Spawn count in this level. Infinite (endless mode) must use procedural wave generation");
            contL = new GUIContent[spawnLimitLabel.Length];
            for (int i = 0; i < contL.Length; i++)
            {
                contL[i] = new GUIContent(spawnLimitLabel[i], spawnLimitTooltip[i]);
            }
            spawnLimit          = EditorGUILayout.Popup(cont, spawnLimit, contL);
            instance.spawnLimit = (SpawnManager._SpawnLimit)spawnLimit;

            cont = new GUIContent("Allow Skip:", "Allow player to skip ahead and spawn the next wave");
            instance.allowSkip = EditorGUILayout.Toggle(cont, instance.allowSkip);


            EditorGUILayout.Space();


            cont = new GUIContent("Auto Start: ", "Check to have the spawning start on a fixed timer. Rather than waiting for player initiation");
            instance.autoStart = EditorGUILayout.Toggle(cont, instance.autoStart);

            cont = new GUIContent(" - Start Delay: ", "The duration to wait in second before the spawning start");
            if (instance.autoStart)
            {
                instance.autoStartDelay = EditorGUILayout.FloatField(cont, instance.autoStartDelay);
            }
            else
            {
                EditorGUILayout.LabelField(cont, new GUIContent("-", ""));
            }



            EditorGUILayout.Space();


            cont = new GUIContent("Auto-Gen Wave:", "Check to have the SpawnManager automatically generate the wave in runtime as opposed to using preset data");
            if (instance.spawnLimit == SpawnManager._SpawnLimit.Finite)
            {
                instance.procedurallyGenerateWave = EditorGUILayout.Toggle(cont, instance.procedurallyGenerateWave);
            }
            else
            {
                EditorGUILayout.LabelField(cont, new GUIContent("-", ""));
            }

            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");
            instance.defaultPath = (PathTD)EditorGUILayout.ObjectField(cont, instance.defaultPath, typeof(PathTD), true);


            EditorGUILayout.Space();


            EditorGUILayout.HelpBox("Editing Spawn Information using Inspector is not recommended.\nPlease use SpawnEditorWindow instead", MessageType.Info);
            if (GUILayout.Button("Open SpawnEditorWindow"))
            {
                SpawnEditorWindow.Init();
            }


            EditorGUILayout.Space();

            DefaultInspector();

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