Ejemplo n.º 1
0
        public void Reset()
        {
            _Wave                = 1;
            _TotalTime           = TimeSpan.Zero;
            _TotalEntitiesKilled = 0;
            _DifficultyModifier  = 1f;
            _CurrentPhase        = ArenaPhases.Start;

            if (RemainingEntities != null)
            {
                foreach (var s in RemainingEntities)
                {
                    if (!s.IsDisposed)
                    {
                        s.Dispose();
                    }
                }
            }
            RemainingEntities = new List <Entity>();
            _BattleTimer      = TimeSpan.Zero;
            _PhaseTimer       = TimeSpan.FromSeconds(PHASE_DURATION);
            foreach (var s in EnemySpawners)
            {
                s.GetComponent <SpawnerComponent>().Reset();
            }
        }
Ejemplo n.º 2
0
        protected override void OnUpdate(GameTime Time)
        {
            //Not sure if it's a bug, but this is called multiple times before gametime is even determined.
            if (Time.TotalGameTime == TimeSpan.Zero)
            {
                return;
            }

            DeterminePlayerState();
            switch (_CurrentPhase)
            {
            case ArenaPhases.Start:
                StartPhaseUpdate();
                _PhaseTimer -= Time.ElapsedGameTime;
                if (_PhaseTimer <= TimeSpan.Zero)
                {
                    AudioManager.PlaySoundEffect("ArenaStart");
                    InitBattlePhase();
                    _BattleTimer  = TimeSpan.Zero;
                    _PhaseTimer   = TimeSpan.FromSeconds(PHASE_DURATION);
                    _CurrentPhase = ArenaPhases.Battle;
                }
                break;

            case ArenaPhases.Battle:
                BattlePhaseUpdate();
                _BattleTimer += Time.ElapsedGameTime;
                if (RemainingEntities.Count == 0)
                {
                    AudioManager.PlaySoundEffect("ArenaEnd");
                    InitEndPhase();
                    _PhaseTimer   = TimeSpan.FromSeconds(PHASE_DURATION);
                    _CurrentPhase = ArenaPhases.End;
                }
                break;

            case ArenaPhases.End:
                EndPhaseUpdate();
                _PhaseTimer -= Time.ElapsedGameTime;
                if (_PhaseTimer <= TimeSpan.Zero)
                {
                    InitStartPhase();
                    _PhaseTimer   = TimeSpan.FromSeconds(PHASE_DURATION);
                    _CurrentPhase = ArenaPhases.Start;
                }
                break;

            case ArenaPhases.GameOver:
                _PhaseTimer -= Time.ElapsedGameTime;
                if (_PhaseTimer <= TimeSpan.Zero)
                {
                    Reset();
                    _PhaseTimer   = TimeSpan.FromSeconds(PHASE_DURATION);
                    _CurrentPhase = ArenaPhases.Start;
                    CorvusGame.Instance.SceneManager.ReloadScenes(true);
                }
                break;
            }
        }
Ejemplo n.º 3
0
        public void Reset()
        {
            _Wave = 1;
            _TotalTime = TimeSpan.Zero;
            _TotalEntitiesKilled = 0;
            _DifficultyModifier = 1f;
            _CurrentPhase = ArenaPhases.Start;

            if (RemainingEntities != null)
            {
                foreach (var s in RemainingEntities)
                {
                    if(!s.IsDisposed)
                        s.Dispose();
                }
            }
            RemainingEntities = new List<Entity>();
            _BattleTimer = TimeSpan.Zero;
            _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION);
            foreach (var s in EnemySpawners)
                s.GetComponent<SpawnerComponent>().Reset();
        }
Ejemplo n.º 4
0
        private void DeterminePlayerState()
        {
            if (_CurrentPhase == ArenaPhases.GameOver)
            {
                return;
            }

            bool allplayersDisposed = true;

            foreach (var p in CorvusGame.Instance.Players)
            {
                if (!p.Character.IsDisposed)
                {
                    allplayersDisposed = false;
                    break;
                }
            }
            if (allplayersDisposed)
            {
                _TotalTime   += _BattleTimer;
                _CurrentPhase = ArenaPhases.GameOver;
                _PhaseTimer   = TimeSpan.FromSeconds(GAMEOVER_PHASE_DURATION);
            }
        }
Ejemplo n.º 5
0
        private void DeterminePlayerState()
        {
            if (_CurrentPhase == ArenaPhases.GameOver)
                return;

            bool allplayersDisposed = true;
            foreach (var p in CorvusGame.Instance.Players)
            {
                if (!p.Character.IsDisposed)
                {
                    allplayersDisposed = false;
                    break;
                }
            }
            if (allplayersDisposed)
            {
                _TotalTime += _BattleTimer;
                _CurrentPhase = ArenaPhases.GameOver;
                _PhaseTimer = TimeSpan.FromSeconds(GAMEOVER_PHASE_DURATION);
            }
        }
Ejemplo n.º 6
0
        protected override void OnUpdate(GameTime Time)
        {
            //Not sure if it's a bug, but this is called multiple times before gametime is even determined.
            if (Time.TotalGameTime == TimeSpan.Zero)
                return;

            DeterminePlayerState();
            switch (_CurrentPhase)
            {
                case ArenaPhases.Start:
                    StartPhaseUpdate();
                    _PhaseTimer -= Time.ElapsedGameTime;
                    if (_PhaseTimer <= TimeSpan.Zero)
                    {
                        AudioManager.PlaySoundEffect("ArenaStart");
                        InitBattlePhase();
                        _BattleTimer = TimeSpan.Zero;
                        _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION);
                        _CurrentPhase = ArenaPhases.Battle;
                    }
                    break;
                case ArenaPhases.Battle:
                    BattlePhaseUpdate();
                    _BattleTimer += Time.ElapsedGameTime;
                    if (RemainingEntities.Count == 0)
                    {
                        AudioManager.PlaySoundEffect("ArenaEnd");
                        InitEndPhase();
                        _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION);
                        _CurrentPhase = ArenaPhases.End;
                    }
                    break;
                case ArenaPhases.End:
                    EndPhaseUpdate();
                    _PhaseTimer -= Time.ElapsedGameTime;
                    if (_PhaseTimer <= TimeSpan.Zero)
                    {
                        InitStartPhase();
                        _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION);
                        _CurrentPhase = ArenaPhases.Start;
                    }
                    break;
                case ArenaPhases.GameOver:
                    _PhaseTimer -= Time.ElapsedGameTime;
                    if (_PhaseTimer <= TimeSpan.Zero)
                    {
                        Reset();
                        _PhaseTimer = TimeSpan.FromSeconds(PHASE_DURATION);
                        _CurrentPhase = ArenaPhases.Start;
                        CorvusGame.Instance.SceneManager.ReloadScenes(true);
                    }
                    break;
            }
        }