Ejemplo n.º 1
0
        private void RoomPacketReceived(RoomPacket roomPacket, NetPeer peer)
        {
            Player playerSending = _playersManager.GetConnectedPlayer(peer);

            if (playerSending == null)
            {
                return;
            }

            switch (roomPacket.RoomCommand)
            {
            case RoomCommand.CREATE_ROOM:
                _roomsController.CreateRoom(playerSending, roomPacket.RoomName);
                break;

            case RoomCommand.CREATE_ROOM_CONFIRMATION:
                _roomsController.UpdateRoom(_roomsController.Rooms.Find(x => x.RoomId == roomPacket.RoomId));
                break;

            case RoomCommand.JOIN_ROOM:
                _roomsController.AssignPlayerToRoom(playerSending, roomPacket.RoomId);
                break;

            case RoomCommand.JOIN_ROOM_CONFIRM:
                break;

            case RoomCommand.ROOM_UPDATE:
                break;

            case RoomCommand.LOAD_GAME_SCENE_CONFIRM:
                _roomsController.SetPlayerLoaded(playerSending, roomPacket.RoomId);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }