MatchmakingMode
How do I use Matchmaking Mode
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: LoadbalancingPeer.cs
Copy
212 public virtual bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
213 {
214 if (this.DebugOut >= DebugLevel.INFO)
215 {
216 this.Listener.DebugReturn(DebugLevel.INFO, "OpJoinRandomRoom()");
217 }
218
219 Hashtable expectedRoomProperties = new Hashtable();
220 expectedRoomProperties.MergeStringKeys(expectedCustomRoomProperties);
221 if (expectedMaxPlayers > 0)
222 {
223 expectedRoomProperties[GameProperties.MaxPlayers] = expectedMaxPlayers;
224 }
225
226 Dictionary
227 if (expectedRoomProperties.Count > 0)
228 {
229 opParameters[ParameterCode.GameProperties] = expectedRoomProperties;
230 }
231
232 if (playerProperties != null && playerProperties.Count > 0)
233 {
234 opParameters[ParameterCode.PlayerProperties] = playerProperties;
235 }
236
237 if (matchingType != MatchmakingMode.FillRoom)
238 {
239 opParameters[ParameterCode.MatchMakingType] = (byte)matchingType;
240 }
241
242 if (typedLobby != null)
243 {
244 opParameters[ParameterCode.LobbyName] = typedLobby.Name;
245 opParameters[ParameterCode.LobbyType] = (byte)typedLobby.Type;
246 }
247
248 if (!string.IsNullOrEmpty(sqlLobbyFilter))
249 {
250 opParameters[ParameterCode.Data] = sqlLobbyFilter;
251 }
252
253 // UnityEngine.Debug.LogWarning("OpJoinRandom: " + opParameters.ToStringFull());
254 return this.OpCustom(OperationCode.JoinRandomGame, opParameters, true);
255 }
File name: NetworkingPeer.cs
Copy
968 public override bool OpJoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, Hashtable playerProperties, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
969 {
970 this.mRoomToGetInto = new Room(null, null);
971 this.mRoomToEnterLobby = null; // join random never stores the lobby. the following join will not affect the room lobby
972 // if typedLobby is null, the server will automatically use the active lobby or default, which is what we want anyways
973
974 this.mLastJoinType = JoinType.JoinRandomGame;
975 return base.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, playerProperties, matchingType, typedLobby, sqlLobbyFilter);
976 }
File name: PhotonNetwork.cs
Copy
1644 /// This method looks up a room in the currently active lobby or (if no lobby is joined)
1650 public static bool JoinRandomRoom()
1651 {
1652 return JoinRandomRoom(null, 0, MatchmakingMode.FillRoom, null, null);
1653 }
File name: PhotonNetwork.cs
Copy
1665 /// This method looks up a room in the currently active lobby or (if no lobby is joined)
1673 public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers)
1674 {
1675 return JoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, MatchmakingMode.FillRoom, null, null);
1676 }
File name: PhotonNetwork.cs
Copy
1687 /// This method looks up a room in the specified lobby or the currently active lobby (if none specified)
1701 public static bool JoinRandomRoom(Hashtable expectedCustomRoomProperties, byte expectedMaxPlayers, MatchmakingMode matchingType, TypedLobby typedLobby, string sqlLobbyFilter)
1702 {
1703 if (offlineMode)
1704 {
1705 if (offlineModeRoom != null)
1706 {
1707 Debug.LogError("JoinRandomRoom failed. In offline mode you still have to leave a room to enter another.");
1708 return false;
1709 }
1710
1711 offlineModeRoom = new Room("offline room", null);
1712 NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom);
1713 return true;
1714 }
1715
1716
1717 if (networkingPeer.server != ServerConnection.MasterServer || !connectedAndReady)
1718 {
1719 Debug.LogError("JoinRandomRoom failed. Client is not on Master Server or not yet ready to call operations. Wait for callback: OnJoinedLobby or OnConnectedToMaster.");
1720 return false;
1721 }
1722
1723 return networkingPeer.OpJoinRandomRoom(expectedCustomRoomProperties, expectedMaxPlayers, null, matchingType, typedLobby, sqlLobbyFilter);
1724 }
MatchmakingMode 143 lượt xem
Gõ tìm kiếm nhanh...