Example #1
0
        void RemovePlayer(Player player)
        {
            if (Players[player.LocalId] == null)
            {
                return;
            }
            Players[player.LocalId] = null;
            var peer = player.PeerTcp;

            if (peer != null)
            {
                peer.CleanExtension();
                peer.Disconnect("");
            }

            player.PeerTcp = null;
            peer           = player.PeerUdp;
            if (peer != null)
            {
                peer.CleanExtension();
                peer.Disconnect("");
            }

            player.PeerUdp = null;

            var curCount = CurPlayerCount;

            if (curCount == 0)
            {
                Log("All players left, stopping current simulation...");
                IsRunning = false;
                State     = EGameState.Idle;
                _gameServer.OnGameEmpty(this);
            }
            else
            {
                Log(curCount + " players remaining.");
            }
        }