Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void CreateCustomMatch() {
- RoomOptions option = new RoomOptions();
- TypedLobby lobby = new TypedLobby();
- maxPlayers = option.maxPlayers = (byte)((playersDropDown.value + 1) * 4);
- option.customRoomProperties = new ExitGames.Client.Photon.Hashtable();
- option.customRoomProperties.Add("GT", (int)gameType);
- if (PhotonNetwork.room != null) {
- PhotonNetwork.LeaveRoom();
- }
- PhotonNetwork.JoinOrCreateRoom(roomName.ToString(), option, lobby);
- isReadyToStartGame = true;
- DisableMenus();
- if (PageChanged != null) {
- PageChanged(this, EventArgs.Empty);
- }
- }
- public override void OnConnectedToMaster() {
- if (isMatchMaking && isReadyToStartGame) {
- UnityEngine.Debug.Log("Connected to matchmaking.");
- UnityEngine.Debug.Log(string.Format("Attemting to join game with game type {0}. Attempt {1}", gameType.ToString(), retryAttempts));
- waitingMenuText.text = string.Format("Locating Match, Attempt {0}.", retryAttempts);
- ExitGames.Client.Photon.Hashtable expectedCustomRoomProperties = new ExitGames.Client.Photon.Hashtable() { { "GT", (int)gameType } };
- PhotonNetwork.JoinRandomRoom(expectedCustomRoomProperties, 16);
- }
- if (isCustomGame && isReadyToStartGame) {
- CreateCustomMatch();
- }
- }
- void OnPhotonRandomJoinFailed() {
- if (isMatchMaking) {
- if (retryAttempts++ < 5) {
- OnConnectedToMaster();
- } else {
- RoomOptions options = new RoomOptions();
- TypedLobby lobby = new TypedLobby();
- options.isOpen = true;
- options.isVisible = true;
- playersRequiredToStartMatch = maxPlayers = options.maxPlayers = 16;
- options.customRoomProperties = new ExitGames.Client.Photon.Hashtable();
- options.customRoomProperties.Add("GT", (int)gameType);
- PhotonNetwork.CreateRoom(null, options, lobby);
- UnityEngine.Debug.Log("No rooms found. Creating a new one.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment