public void RunTick() { // Switch to pregame state if there are players connected, otherwise wait. if (!_arena.Players.Any()) { return; } // If there is no memento in the caretaker, assume that a new game will start, // otherwise, restore state. if (_context.Caretaker.Memento == null) { var pregameCountdownState = new PregameCountdownState(_arena, _context); _context.ChangeState(pregameCountdownState); } else { var previousStateMemento = _context.Caretaker.Memento; _context.RestoreFromGameStateMemento(previousStateMemento); } }
public void RunTick() { if (_ticksLeftUntilPregameStart > 0) { if (_ticksLeftUntilPregameStart % 10 == 0) { var message = $"[GAME STATE] If any players are left, the pregame countdown will start in {_ticksLeftUntilPregameStart} ticks."; Logger.Instance.LogWithColor(ConsoleColor.Blue, message); } _ticksLeftUntilPregameStart--; // If no players are connected, let the state run its course. } else { // Post-game ended, go to pregame. var pregameCountdownState = new PregameCountdownState(_arena, _context); _context.ChangeState(pregameCountdownState); } }