/// <summary> /// Creates a new Photon room with the given options. The matchmaker's state must be <see cref="ConnectionState.Connected"/>. /// </summary> /// See <see cref="LoadBalancingClient.OpCreateRoom"/> for more information. /// /// <inheritdoc cref="IMatchmaker.CreateGame"/> /// <param name="options">The <see cref="PhotonCreateGameOptions"/> used to create the room</param> /// <returns>An observable resolving with the <see cref="PhotonAlreadyJoinedGame"/> that was joined with the given query.</returns> /// <exception cref="ArgumentException">If <see cref="options"/> is not of type <see cref="PhotonCreateGameOptions"/></exception> public virtual IObservable <IGame> CreateGame(ICreateGameOptions options) { var photonOptions = options as PhotonCreateGameOptions; if (photonOptions == null) { throw new ArgumentException($"{nameof(options)} must be of type {nameof(PhotonCreateGameOptions)}.", nameof(options)); } if (_photonClient.State != ClientState.ConnectedToMasterserver && _photonClient.State != ClientState.JoinedLobby) { return(Observable.Throw <IGame>(new InvalidOperationException($"Operation failed: Invalid state '{_photonClient.State}'." + " Please make sure you are connected to Photon."))); } var observable = PhotonUtils.CreateObservableForExpectedStateChange <IGame>(_photonClient, expectedState: ClientState.Joined, returnValue: new PhotonAlreadyJoinedGame(_photonClient)); _photonClient.OpCreateRoom(new EnterRoomParams { RoomName = photonOptions.RoomName, RoomOptions = photonOptions, Lobby = photonOptions.PhotonLobby, ExpectedUsers = photonOptions.ExpectedUsers }); State = ConnectionState.JoiningRoom; return(observable); }
public void Create() { var roomOpts = _getRoomOptionsForGameType(MAX_PLAYERS, BET_MINIMAL, Connecting.GameType.OneVsOne); // get the lobby var lobby = LobbyMain; // try to create the game _loadBalancingClient.OpCreateRoom(_roomName + UnityEngine.Random.Range(0, 99), roomOpts, lobby); }
private void CreateRoom() { RoomOptions roomOptions = new RoomOptions(); roomOptions.MaxPlayers = 2; EnterRoomParams enterRoomParams = new EnterRoomParams(); enterRoomParams.RoomOptions = roomOptions; loadBalancingClient.OpCreateRoom(enterRoomParams); }
private void CreateRankedRoom(byte maxPlayerCount, byte rank, bool isOpen, bool isVisible) { RoomOptions roomOptions = new RoomOptions(); roomOptions.IsOpen = isOpen; roomOptions.IsVisible = isVisible; roomOptions.MaxPlayers = maxPlayerCount; roomOptions.PublishUserId = true; roomOptions.CustomRoomProperties = new ExitGames.Client.Photon.Hashtable { { "Ranked", rank } }; EnterRoomParams enterRoomParams = new EnterRoomParams(); enterRoomParams.RoomName = "Ranked Room" + Random.Range(0, 10000); enterRoomParams.RoomOptions = roomOptions; loadBalancingClient.OpCreateRoom(enterRoomParams); }