示例#1
0
    public void PlayerJoinRoom(int PlayerConnectionID, Vector3 Position)
    {
        Player player = PlayerManager.Instance.GetPlayer(PlayerConnectionID);

        player.OnPlayerChangeRooms(this);
        if (!PlayerConnectionIDsInRoom.Contains(PlayerConnectionID))
        {
            PlayerConnectionIDsInRoom.Add(PlayerConnectionID);
        }

        if (NetworkDetails.IsLocalConnectionID(PlayerConnectionID))
        {
            for (int i = 0; i < PlayerConnectionIDsInRoom.Count; i++)
            {
                PlayerManager.Instance.GetPlayer(PlayerConnectionIDsInRoom[i]).SetIsVisible(true);
            }
        }

#if SERVER
        NetworkPacketSender.SendRoomData(PlayerConnectionID, RoomIndex);
        NetworkPacketSender.AddPlayerToRoom(PlayerConnectionID, this, Position);
#endif

        player.transform.position = Position;
        player.SetIsVisible(true);
    }
示例#2
0
    public void PlayerLeaveRoom(int PlayerConnectionID)
    {
#if SERVER
        NetworkPacketSender.RemovePlayerFromRoom(PlayerConnectionID, this);
#endif

        PlayerConnectionIDsInRoom.Remove(PlayerConnectionID);
        if (NetworkDetails.IsLocalConnectionID(PlayerConnectionID))
        {
            for (int i = 0; i < PlayerConnectionIDsInRoom.Count; i++)
            {
                PlayerManager.Instance.GetPlayer(PlayerConnectionIDsInRoom[i]).SetIsVisible(false);
            }
        }
        else
        {
            PlayerManager.Instance.GetPlayer(PlayerConnectionID).SetIsVisible(false);
        }
    }