示例#1
0
        private void ShowRoundSettings(RoundManager roundManager)
        {
            if (_rounds == null)
            {
                _rounds = serializedObject.FindProperty("Rounds");
            }


            EditorGUI.BeginChangeCheck();

            SetupVisibility();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Rounds", EditorStyles.boldLabel);

            if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth))
            {
                _rounds.InsertArrayElementAtIndex(0);
                _showGeneralRoundSettings.Insert(0, true);
                _showRoundCheckpointSettings.Insert(0, true);
                _showRounds.Insert(0, true);
            }

            EditorGUILayout.EndHorizontal();


            for (int i = 0; i < _rounds.arraySize; i++)
            {
                var roundProp = _rounds.GetArrayElementAtIndex(i);

                _showRounds [i] = EditorGUILayout.Foldout(_showRounds [i], "Round " + (i + 1));
                if (_showRounds [i])
                {
                    ShowInidividualRoundSettings(roundProp, i, roundManager);

                    GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));
                }
            }

            //EditorGUILayout.PropertyField (_rounds, true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
示例#2
0
        /// <summary>
        /// Invoked by RoundManager. Not required to be called manually.
        /// Called at the beginning of the round.
        /// Raises \ref RoundManager.Events.DestroyCurrentEnemiesRequestEvent "DestroyCurrentEnemiesRequestEvent"
        /// if #DestroyPreviousRoundEnemiesOnRoundStart is true.
        /// Raises \ref RoundManager.Events.RoundStartEvent "RoundStartEvent".
        /// </summary>
        /// <param name="manager">The rounds owner.</param>
        public void Enter(RoundManager manager)
        {
            _inPreparation = true;
            _timeUp        = false;
            _bossSpawned   = false;
            _bossQueued    = false;
            _manager       = manager;

            if (DestroyPreviousRoundEnemiesOnRoundStart)
            {
                RoundEvents.Instance.Raise(new DestroyCurrentEnemiesRequestEvent(this));
            }

            IncreaseCheckpoint();

            foreach (var c in Checkpoints)
            {
                _roundTime += c.CheckpointTime;
            }

            RoundEvents.Instance.Raise(new RoundStartEvent(this));
        }
示例#3
0
        private void ShowRoundManager(RoundManager roundManager)
        {
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(serializedObject.FindProperty("ShowDebugMessages"));

            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            _showRoundSettings = EditorGUILayout.Foldout(_showRoundSettings, "Round Settings");


            if (_showRoundSettings)
            {
                string roundHelpText = "Setup and add/remove rounds.\n"
                                       + string.Format("\nCurrent number of rounds: {0}", roundManager.Rounds.Length);

                AddHelpLabel(roundHelpText);
                ShowRoundSettings(roundManager);
            }
        }
示例#4
0
        private void ShowInidividualRoundSettings(SerializedProperty roundProp, int i, RoundManager roundManager)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Duplicate Or Remove Round:");


            if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth))
            {
                _rounds.InsertArrayElementAtIndex(i);
                _showGeneralRoundSettings.Insert(i, true);
                _showRoundCheckpointSettings.Insert(i, true);
                _showRounds.Insert(i, true);
            }
            if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth) && _rounds.arraySize > 0)
            {
                _rounds.DeleteArrayElementAtIndex(i);
                _showGeneralRoundSettings.RemoveAt(i);
                _showRoundCheckpointSettings.RemoveAt(i);
                _showRounds.RemoveAt(i);
                return;
            }

            EditorGUILayout.EndHorizontal();

            bool  destroyEnemiesAtStart    = false;
            bool  destroyEnemiesAtRoundEnd = false;
            float currentRoundTime         = 0f;
            float preperationTime          = 0f;
            bool  roundHasBoss             = false;
            int   numOfCheckpoints         = 0;

            if (roundManager.Rounds.Length > i)
            {
                foreach (var checkpoint in roundManager.Rounds[i].Checkpoints)
                {
                    currentRoundTime += checkpoint.CheckpointTime;
                }

                destroyEnemiesAtStart    = roundManager.Rounds [i].DestroyPreviousRoundEnemiesOnRoundStart;
                destroyEnemiesAtRoundEnd = roundManager.Rounds [i].DestroyEnemiesOnRoundEnd;
                preperationTime          = (roundManager.Rounds [i].HasPreperationTime) ? roundManager.Rounds [i].PreperationTime : 0f;
                roundHasBoss             = roundManager.Rounds [i].RoundHasBoss;
                numOfCheckpoints         = roundManager.Rounds [i].Checkpoints.Length;
            }

            string roundOverview = "Round Overview:\n" +
                                   string.Format("\nDestroy Enemies On Round Start: {0} \nDestroy Enemies On Round End: {1} \nPreperation Time: {2} seconds" +
                                                 " \nCurrent round time: {3} seconds ({4} checkpoint(s))" +
                                                 "\nRound Boss: {5}", destroyEnemiesAtStart, destroyEnemiesAtRoundEnd,
                                                 preperationTime, currentRoundTime, numOfCheckpoints, roundHasBoss);

            AddHelpLabel(roundOverview);

            _showGeneralRoundSettings [i] = EditorGUILayout.Foldout(_showGeneralRoundSettings [i], "Round General Settings");
            if (_showGeneralRoundSettings [i])
            {
                ShowGeneralRoundSettings(roundProp);
            }

            var checkProp = roundProp.FindPropertyRelative("Checkpoints");

            if (_showIndividualCheckpoints == null)
            {
                _showIndividualCheckpoints = new List <RoundCheckpintVisibilitySettings> ();
            }


            if (_showIndividualCheckpoints.Count <= i)
            {
                _showIndividualCheckpoints.Insert(i, new RoundCheckpintVisibilitySettings(checkProp.arraySize));
            }


            _showRoundCheckpointSettings [i] = EditorGUILayout.Foldout(_showRoundCheckpointSettings [i], "Checkpoints");
            if (_showRoundCheckpointSettings [i])
            {
                ShowCheckpointSettings(checkProp, i);
            }
        }
 void Awake()
 {
     _manager = RoundManager.Instance;
 }