void OnJoinedRoom() { Debug.Log("OnJoinedRoom"); state = AutoState.JoinedRoom; StartCoroutine("WaitForPlayers"); }
void Excute(string eventName) { _state = AutoState.Null; if (OnAutoHandler != null) { OnAutoHandler(eventName); } }
void OnJoinedLobby() { Debug.Log("OnJoinedLobby"); state = AutoState.JoinedLobby; statusLabel.text = "Searching for a game..."; JoinRandomRoom(); }
void JoinRandomRoom() { Debug.Log("JoinRandomRoom"); if (state == AutoState.JoinedLobby) { Debug.Log("JoinRandomRoom -> state == JoinedLobby"); state = AutoState.JoiningRoom; PhotonNetwork.JoinRandomRoom(); Debug.Log("Trying PhotonNetwork.JoinRandomRoom()"); } }
void OnJoinedRoomFailed() { Debug.Log("OnJoinRoomFailed"); statusLabel.text = "Creating Game"; state = AutoState.CreatingRoom; RoomOptions options = new RoomOptions() { isOpen = true, isVisible = true, maxPlayers = 2 }; PhotonNetwork.CreateRoom(null, options, null); }
IEnumerator WaitForPlayers() { while (PhotonNetwork.room != null) { int maxPlayers = PhotonNetwork.room.maxPlayers; int currPlayers = PhotonNetwork.room.playerCount; if (currPlayers < maxPlayers) { statusLabel.text = "Waiting on " + (maxPlayers - currPlayers).ToString() + " players."; } else { state = AutoState.StartingGame; statusLabel.text = "Starting game"; PhotonNetwork.LoadLevel("OnlineGameScene"); break; } yield return(null); } }
void OnFailedToConnectToPhoton() { statusLabel.text = "Failed to connect, try later."; state = AutoState.Failed; }
void OnPhotonCreateRoomFailed() { state = AutoState.Failed; statusLabel.text = "Failed to create a game, try later."; }
// public AutoFight() { kAutoState = CreateAutoState(); }