public void FindPlayers() { if (!PhotonNetwork.IsConnected) { RoomManager.Instance.Connect(); return; } else if (!PhotonNetwork.InLobby) { RoomManager.Instance.JoinLobby(); return; } Player.NickName = Panel.Find <PanelStart>().txtNickname.text; //*** MULTIPLAYER CODE //STEP 1: Setup basic information about your player: PhotonNetwork.NickName = Player.NickName; PhotonNetwork.LocalPlayer.CustomProperties["SelectedCharacter"] = Player.SelectedCharacter; //STEP 2: Define the settings used when looking for a matching Room: OpJoinRandomRoomParams joinRoomParams = new OpJoinRandomRoomParams(); joinRoomParams.ExpectedMaxPlayers = RoomManager.MaxPlayers; //STEP 3: Define the settings used when creating a Room: EnterRoomParams createRoomParams = new EnterRoomParams(); createRoomParams.RoomOptions = new RoomOptions(); createRoomParams.RoomOptions.MaxPlayers = RoomManager.MaxPlayers; //STEP 4: Find players. Photon will automatically join or create a room as needed: PhotonNetwork.NetworkingClient.OpJoinRandomOrCreateRoom(joinRoomParams, createRoomParams); }
bool CallJoinRoom() { OpJoinRandomRoomParams opJoinRandomRoomParams = new OpJoinRandomRoomParams() { }; opJoinRandomRoomParams.ExpectedMaxPlayers = 2; // joining a random room with the map we selected before return(this.OpJoinRandomRoom(opJoinRandomRoomParams)); }
private void JoinRankedRoom(byte maxPlayerCount, byte rank) { OpJoinRandomRoomParams opJoinRandomRoomParams = new OpJoinRandomRoomParams(); opJoinRandomRoomParams.ExpectedMaxPlayers = maxPlayerCount; opJoinRandomRoomParams.ExpectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable { { "Rank", rank } }; loadBalancingClient.OpJoinRandomRoom(opJoinRandomRoomParams); }
public override void OnJoinedLobby() { if (!PhotonNetwork.InRoom) { Debug.Log("Joined Lobby"); SetupMyPlayer(); var joinRoomParams = new OpJoinRandomRoomParams(); var createRoomParams = new EnterRoomParams(); PhotonNetwork.NetworkingClient.OpJoinRandomOrCreateRoom(joinRoomParams, createRoomParams); } }
public void QuickStart() { if (roomSize == 0) // if quickstart button is pressed { PhotonNetwork.JoinRandomRoom(); } else { quickStartButton.SetActive(false); quickCancelButton.SetActive(true); OpJoinRandomRoomParams opJoinRandomRoomParams = new OpJoinRandomRoomParams(); opJoinRandomRoomParams.ExpectedMaxPlayers = roomSize; lbc.OpJoinRandomRoom(); } Debug.Log("Quick start"); // Tries to join an existing room }
public virtual bool OpJoinRandomRoom(OpJoinRandomRoomParams opJoinRandomRoomParams) { if (this.DebugOut >= 3) { this.get_Listener().DebugReturn((DebugLevel)3, "OpJoinRandomRoom()"); } Hashtable hashtable = new Hashtable(); ((IDictionary)hashtable).MergeStringKeys((IDictionary)opJoinRandomRoomParams.ExpectedCustomRoomProperties); if ((int)opJoinRandomRoomParams.ExpectedMaxPlayers > 0) { hashtable.set_Item((object)byte.MaxValue, (object)opJoinRandomRoomParams.ExpectedMaxPlayers); } Dictionary <byte, object> dictionary = new Dictionary <byte, object>(); if (((Dictionary <object, object>)hashtable).Count > 0) { dictionary[(byte)248] = (object)hashtable; } if (opJoinRandomRoomParams.MatchingType != MatchmakingMode.FillRoom) { dictionary[(byte)223] = (object)opJoinRandomRoomParams.MatchingType; } if (opJoinRandomRoomParams.TypedLobby != null && !string.IsNullOrEmpty(opJoinRandomRoomParams.TypedLobby.Name)) { dictionary[(byte)213] = (object)opJoinRandomRoomParams.TypedLobby.Name; dictionary[(byte)212] = (object)opJoinRandomRoomParams.TypedLobby.Type; } if (!string.IsNullOrEmpty(opJoinRandomRoomParams.SqlLobbyFilter)) { dictionary[(byte)245] = (object)opJoinRandomRoomParams.SqlLobbyFilter; } if (opJoinRandomRoomParams.ExpectedUsers != null && opJoinRandomRoomParams.ExpectedUsers.Length > 0) { dictionary[(byte)238] = (object)opJoinRandomRoomParams.ExpectedUsers; } return(this.OpCustom((byte)225, dictionary, true)); }
// Token: 0x06003BBC RID: 15292 RVA: 0x0012C930 File Offset: 0x0012AD30 public virtual bool OpJoinRandomRoom(OpJoinRandomRoomParams opJoinRandomRoomParams) { if (this.DebugOut >= DebugLevel.INFO) { base.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()"); } Hashtable hashtable = new Hashtable(); hashtable.MergeStringKeys(opJoinRandomRoomParams.ExpectedCustomRoomProperties); if (opJoinRandomRoomParams.ExpectedMaxPlayers > 0) { hashtable[byte.MaxValue] = opJoinRandomRoomParams.ExpectedMaxPlayers; } Dictionary <byte, object> dictionary = new Dictionary <byte, object>(); if (hashtable.Count > 0) { dictionary[248] = hashtable; } if (opJoinRandomRoomParams.MatchingType != MatchmakingMode.FillRoom) { dictionary[223] = (byte)opJoinRandomRoomParams.MatchingType; } if (opJoinRandomRoomParams.TypedLobby != null && !string.IsNullOrEmpty(opJoinRandomRoomParams.TypedLobby.Name)) { dictionary[213] = opJoinRandomRoomParams.TypedLobby.Name; dictionary[212] = (byte)opJoinRandomRoomParams.TypedLobby.Type; } if (!string.IsNullOrEmpty(opJoinRandomRoomParams.SqlLobbyFilter)) { dictionary[245] = opJoinRandomRoomParams.SqlLobbyFilter; } if (opJoinRandomRoomParams.ExpectedUsers != null && opJoinRandomRoomParams.ExpectedUsers.Length > 0) { dictionary[238] = opJoinRandomRoomParams.ExpectedUsers; } return(this.OpCustom(225, dictionary, true)); }
public virtual bool OpJoinRandomRoom(OpJoinRandomRoomParams opJoinRandomRoomParams) { if (this.DebugOut >= 3) { base.get_Listener().DebugReturn(3, "OpJoinRandomRoom()"); } Hashtable hashtable = new Hashtable(); hashtable.MergeStringKeys(opJoinRandomRoomParams.ExpectedCustomRoomProperties); if (opJoinRandomRoomParams.ExpectedMaxPlayers > 0) { hashtable.set_Item(255, opJoinRandomRoomParams.ExpectedMaxPlayers); } Dictionary <byte, object> dictionary = new Dictionary <byte, object>(); if (hashtable.get_Count() > 0) { dictionary.set_Item(248, hashtable); } if (opJoinRandomRoomParams.MatchingType != MatchmakingMode.FillRoom) { dictionary.set_Item(223, (byte)opJoinRandomRoomParams.MatchingType); } if (opJoinRandomRoomParams.TypedLobby != null && !string.IsNullOrEmpty(opJoinRandomRoomParams.TypedLobby.Name)) { dictionary.set_Item(213, opJoinRandomRoomParams.TypedLobby.Name); dictionary.set_Item(212, (byte)opJoinRandomRoomParams.TypedLobby.Type); } if (!string.IsNullOrEmpty(opJoinRandomRoomParams.SqlLobbyFilter)) { dictionary.set_Item(245, opJoinRandomRoomParams.SqlLobbyFilter); } if (opJoinRandomRoomParams.ExpectedUsers != null && opJoinRandomRoomParams.ExpectedUsers.Length > 0) { dictionary.set_Item(238, opJoinRandomRoomParams.ExpectedUsers); } return(this.OpCustom(225, dictionary, true)); }
/// <summary> /// Operation to join a random, available room. Overloads take additional player properties. /// This is an async request which triggers a OnOperationResponse() call. /// If all rooms are closed or full, the OperationResponse will have a returnCode of ErrorCode.NoRandomMatchFound. /// If successful, the OperationResponse contains a gameserver address and the name of some room. /// </summary> /// <returns>If the operation could be sent currently (requires connection).</returns> public virtual bool OpJoinRandomRoom(OpJoinRandomRoomParams opJoinRandomRoomParams) { if (this.DebugOut >= DebugLevel.INFO) { this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()"); } Hashtable expectedRoomProperties = new Hashtable(); expectedRoomProperties.MergeStringKeys(opJoinRandomRoomParams.ExpectedCustomRoomProperties); if (opJoinRandomRoomParams.ExpectedMaxPlayers > 0) { expectedRoomProperties[GamePropertyKey.MaxPlayers] = opJoinRandomRoomParams.ExpectedMaxPlayers; } Dictionary<byte, object> opParameters = new Dictionary<byte, object>(); if (expectedRoomProperties.Count > 0) { opParameters[ParameterCode.GameProperties] = expectedRoomProperties; } if (opJoinRandomRoomParams.MatchingType != MatchmakingMode.FillRoom) { opParameters[ParameterCode.MatchMakingType] = (byte) opJoinRandomRoomParams.MatchingType; } if (opJoinRandomRoomParams.TypedLobby != null && !string.IsNullOrEmpty(opJoinRandomRoomParams.TypedLobby.Name)) { opParameters[ParameterCode.LobbyName] = opJoinRandomRoomParams.TypedLobby.Name; opParameters[ParameterCode.LobbyType] = (byte) opJoinRandomRoomParams.TypedLobby.Type; } if (!string.IsNullOrEmpty(opJoinRandomRoomParams.SqlLobbyFilter)) { opParameters[ParameterCode.Data] = opJoinRandomRoomParams.SqlLobbyFilter; } if (opJoinRandomRoomParams.ExpectedUsers != null && opJoinRandomRoomParams.ExpectedUsers.Length > 0) { opParameters[ParameterCode.Add] = opJoinRandomRoomParams.ExpectedUsers; } // UnityEngine.Debug.LogWarning("OpJoinRandom: " + opParameters.ToStringFull()); return this.OpCustom(OperationCode.JoinRandomGame, opParameters, true); }
/// <summary>NetworkingPeer.OpJoinRandomRoom</summary> /// <remarks>this override just makes sure we have a mRoomToGetInto, even if it's blank (the properties provided in this method are filters. they are not set when we join the game)</remarks> public override bool OpJoinRandomRoom(OpJoinRandomRoomParams opJoinRandomRoomParams) { enterRoomParamsCache = new EnterRoomParams(); // this is used when the client arrives on the GS and joins the room enterRoomParamsCache.Lobby = opJoinRandomRoomParams.TypedLobby; this.mLastJoinType = JoinType.JoinRandomGame; return base.OpJoinRandomRoom(opJoinRandomRoomParams); }
/// <summary> /// Attempts to join an open room with fitting, custom properties but fails if none is currently available. /// </summary> /// <remarks> /// Rooms can be created in arbitrary lobbies which get created on demand. /// You can join rooms from any lobby without actually joining the lobby with this overload. /// /// This method will only match rooms attached to one lobby! If you use many lobbies, you /// might have to repeat JoinRandomRoom, to find some fitting room. /// This method looks up a room in the specified lobby or the currently active lobby (if none specified) /// or in the default lobby (if none active). /// /// If this fails, you can still create a room (and make this available for the next who uses JoinRandomRoom). /// Alternatively, try again in a moment. /// /// In offlineMode, a room will be created but no properties will be set and all parameters of this /// JoinRandomRoom call are ignored. The event/callback OnJoinedRoom gets called (see enum PhotonNetworkingMessage). /// /// You can define an array of expectedUsers, to block player slots in the room for these users. /// The corresponding feature in Photon is called "Slot Reservation" and can be found in the doc pages. /// </remarks> /// <param name="expectedCustomRoomProperties">Filters for rooms that match these custom properties (string keys and values). To ignore, pass null.</param> /// <param name="expectedMaxPlayers">Filters for a particular maxplayer setting. Use 0 to accept any maxPlayer value.</param> /// <param name="matchingType">Selects one of the available matchmaking algorithms. See MatchmakingMode enum for options.</param> /// <param name="typedLobby">The lobby in which you want to lookup a room. Pass null, to use the default lobby. This does not join that lobby and neither sets the lobby property.</param> /// <param name="sqlLobbyFilter">A filter-string for SQL-typed lobbies.</param> /// <param name="expectedUsers">Optional list of users (by UserId) who are expected to join this game and who you want to block a slot for.</param> /// <returns>If the operation got queued and will be sent.</returns> public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter, string[] expectedUsers = null) { if (offlineMode) { if (offlineModeRoom != null) { Debug.LogError("JoinRandomRoom failed. In offline mode you still have to leave a room to enter another."); return false; } EnterOfflineRoom("offline room", null, true); return true; } if (networkingPeer.Server != ServerConnection.MasterServer || !connectedAndReady) { Debug.LogError("JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster."); return false; } typedLobby = typedLobby ?? ((networkingPeer.insideLobby) ? networkingPeer.lobby : null); // use given lobby, or active lobby (if any active) or none OpJoinRandomRoomParams opParams = new OpJoinRandomRoomParams(); opParams.ExpectedCustomRoomProperties = expectedCustomRoomProperties; opParams.ExpectedMaxPlayers = expectedMaxPlayers; opParams.MatchingType = matchingType; opParams.TypedLobby = typedLobby; opParams.SqlLobbyFilter = sqlLobbyFilter; opParams.ExpectedUsers = expectedUsers; return networkingPeer.OpJoinRandomRoom(opParams); }