Exemplo n.º 1
0
        public override void OnPlayerLeftRoom(Player otherPlayer)
        {
            Debug.Log($"On Photon Player disconnected ID {otherPlayer.ActorNumber}");

            OnPlayerDisconnected?.Invoke(CreatePlayerID(otherPlayer.ActorNumber));
        }
Exemplo n.º 2
0
 public void PlayerDisconnected(Player player)
 {
     OnPlayerDisconnected?.Invoke(player, EventArgs.Empty);
 }
Exemplo n.º 3
0
        internal void OnServerDisconnect(NetworkConnection conn)
        {
            if (!NetworkServer.active)
            {
                return;
            }

            // Invoke OnPlayerDisconnected on all instances of MatchController
            OnPlayerDisconnected?.Invoke(conn);

            Guid matchId;

            if (playerMatches.TryGetValue(conn, out matchId))
            {
                playerMatches.Remove(conn);
                openMatches.Remove(matchId);

                foreach (NetworkConnection playerConn in matchConnections[matchId])
                {
                    PlayerInfo _playerInfo = playerInfos[playerConn];
                    _playerInfo.ready       = false;
                    _playerInfo.matchId     = Guid.Empty;
                    playerInfos[playerConn] = _playerInfo;
                    playerConn.Send(new ClientMatchMessage {
                        clientMatchOperation = ClientMatchOperation.Departed
                    });
                }
            }

            foreach (KeyValuePair <Guid, HashSet <NetworkConnection> > kvp in matchConnections)
            {
                kvp.Value.Remove(conn);
            }

            PlayerInfo playerInfo = playerInfos[conn];

            if (playerInfo.matchId != Guid.Empty)
            {
                MatchInfo matchInfo;
                if (openMatches.TryGetValue(playerInfo.matchId, out matchInfo))
                {
                    matchInfo.players--;
                    openMatches[playerInfo.matchId] = matchInfo;
                }

                HashSet <NetworkConnection> connections;
                if (matchConnections.TryGetValue(playerInfo.matchId, out connections))
                {
                    PlayerInfo[] infos = connections.Select(playerConn => playerInfos[playerConn]).ToArray();

                    foreach (NetworkConnection playerConn in matchConnections[playerInfo.matchId])
                    {
                        if (playerConn != conn)
                        {
                            playerConn.Send(new ClientMatchMessage {
                                clientMatchOperation = ClientMatchOperation.UpdateRoom, playerInfos = infos
                            });
                        }
                    }
                }
            }

            SendMatchList();
        }
 public override void OnPlayerLeftRoom(Player otherPlayer)
 {
     OnPlayerDisconnected?.Invoke(otherPlayer);
 }