private void EndRound()
 {
     _gameTicker.EndRound();
     _chatManager.DispatchServerAnnouncement($"Restarting in 10 seconds.");
     _checkTimerCancel.Cancel();
     Timer.Spawn(TimeSpan.FromSeconds(10), () => _gameTicker.RestartRound());
 }
        private void EndRound(Victory victory)
        {
            string text;

            switch (victory)
            {
            case Victory.Innocents:
                text = Loc.GetString("The innocents have won!");
                break;

            case Victory.Traitors:
                text = Loc.GetString("The traitors have won!");
                break;

            default:
                text = Loc.GetString("Nobody wins!");
                break;
            }

            _gameTicker.EndRound(text);

            var restartDelay = 10;

            _chatManager.DispatchServerAnnouncement(Loc.GetString("Restarting in {0} seconds.", restartDelay));
            _checkTimerCancel.Cancel();

            Timer.Spawn(TimeSpan.FromSeconds(restartDelay), () => _gameTicker.RestartRound());
        }
Example #3
0
        private void EndRound()
        {
            OnRoundEndCountdownFinished?.Invoke();
            _gameTicker.EndRound();

            _chatManager.DispatchServerAnnouncement(Loc.GetString("Restarting the round in {0} seconds...", RestartRoundTime));

            Timer.Spawn(TimeSpan.FromSeconds(RestartRoundTime), () => _gameTicker.RestartRound(), CancellationToken.None);
        }
        private void _checkForWinner()
        {
            _checkTimerCancel = null;

            if (!_cfg.GetCVar <bool>("game.enablewin"))
            {
                return;
            }

            IPlayerSession winner = null;

            foreach (var playerSession in _playerManager.GetAllPlayers())
            {
                if (playerSession.AttachedEntity == null ||
                    !playerSession.AttachedEntity.TryGetComponent(out IDamageableComponent damageable))
                {
                    continue;
                }

                if (damageable.CurrentDamageState != DamageState.Alive)
                {
                    continue;
                }

                if (winner != null)
                {
                    // Found a second person alive, nothing decided yet!
                    return;
                }

                winner = playerSession;
            }

            if (winner == null)
            {
                _chatManager.DispatchServerAnnouncement("Everybody is dead, it's a stalemate!");
            }
            else
            {
                // We have a winner!
                _chatManager.DispatchServerAnnouncement($"{winner} wins the death match!");
            }

            _chatManager.DispatchServerAnnouncement($"Restarting in 10 seconds.");

            Timer.Spawn(TimeSpan.FromSeconds(10), () => _gameTicker.RestartRound());
        }
Example #5
0
        private void _checkForWinner()
        {
            _checkTimerCancel = null;

            if (!_cfg.GetCVar(CCVars.GameLobbyEnableWin))
            {
                return;
            }

            IPlayerSession?winner = null;

            foreach (var playerSession in _playerManager.GetAllPlayers())
            {
                var playerEntity = playerSession.AttachedEntity;
                if (playerEntity == null ||
                    !playerEntity.TryGetComponent(out IMobStateComponent? state))
                {
                    continue;
                }

                if (!state.IsAlive())
                {
                    continue;
                }

                if (winner != null)
                {
                    // Found a second person alive, nothing decided yet!
                    return;
                }

                winner = playerSession;
            }

            _chatManager.DispatchServerAnnouncement(winner == null
                ? Loc.GetString("Everybody is dead, it's a stalemate!")
                : Loc.GetString("{0} wins the death match!", winner));

            var restartDelay = 10;

            _chatManager.DispatchServerAnnouncement(Loc.GetString("Restarting in {0} seconds.", restartDelay));

            Timer.Spawn(TimeSpan.FromSeconds(restartDelay), () => _gameTicker.RestartRound());
        }
Example #6
0
        private void EndRound(Victory victory)
        {
            string text;

            switch (victory)
            {
            case Victory.Innocents:
                text = "The innocents have won!";
                break;

            case Victory.Traitors:
                text = "The traitors have won!";
                break;

            default:
                text = "Nobody wins!";
                break;
            }

            _gameTicker.EndRound(text);
            _chatManager.DispatchServerAnnouncement($"Restarting in 10 seconds.");
            _checkTimerCancel.Cancel();
            Timer.Spawn(TimeSpan.FromSeconds(10), () => _gameTicker.RestartRound());
        }