Beispiel #1
0
        /// <summary>
        /// Handles the player kicked message
        /// </summary>
        /// <param name="inMsg">The message to decode</param>
        private void HandlePlayerKicked(NetIncomingMessage inMsg)
        {
            byte   playerId = inMsg.ReadByte();
            string reason   = inMsg.ReadString();

            if (playerId != myPlayerId)
            {
                OnPlayerKicked?.Invoke(this, myKnownPlayers[playerId], reason);
                OnPlayerLeft?.Invoke(this, myKnownPlayers[playerId], reason);

                myKnownPlayers[playerId] = null;
            }
            else
            {
                myConnectedServer = null;

                OnKicked?.Invoke(this, reason);
            }
        }
        private void HandlePlayerDisconnected()
        {
            var playerID = lobbyReader.ReadInt32();
            var isLeave  = lobbyReader.ReadBoolean();
            var isBot    = lobbyReader.ReadBoolean();

            Chat.MutedPlayers.Remove(ConnectedServer.Players[playerID].IPAddress);

            if (ConnectedServer.State == ServerState.InGame)
            {
                ConnectedServer.Players[playerID].IsBot = isBot;
                OnPlayerDisconnectedGame.Invoke(playerID, isLeave, isBot);
                OnPlayerKicked.Invoke();
            }
            else
            {
                ConnectedServer.RemovePlayer(playerID);
                OnPlayerDisconnectedLobby.Invoke(playerID);
            }
        }
 private void Awake()
 {
     _closeButton.onClick.AddListener(() => { OnPlayerKicked?.Invoke(_player); });
 }