Exemple #1
0
    void OnJoinedRoom()
    {
        Debug.Log("OnJoinedRoom");
        state = AutoState.JoinedRoom;

        StartCoroutine("WaitForPlayers");
    }
Exemple #2
0
 void Excute(string eventName)
 {
     _state = AutoState.Null;
     if (OnAutoHandler != null)
     {
         OnAutoHandler(eventName);
     }
 }
Exemple #3
0
    void OnJoinedLobby()
    {
        Debug.Log("OnJoinedLobby");
        state            = AutoState.JoinedLobby;
        statusLabel.text = "Searching for a game...";

        JoinRandomRoom();
    }
Exemple #4
0
 void JoinRandomRoom()
 {
     Debug.Log("JoinRandomRoom");
     if (state == AutoState.JoinedLobby)
     {
         Debug.Log("JoinRandomRoom -> state == JoinedLobby");
         state = AutoState.JoiningRoom;
         PhotonNetwork.JoinRandomRoom();
         Debug.Log("Trying PhotonNetwork.JoinRandomRoom()");
     }
 }
Exemple #5
0
    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);
    }
Exemple #6
0
    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);
        }
    }
Exemple #7
0
 void OnFailedToConnectToPhoton()
 {
     statusLabel.text = "Failed to connect, try later.";
     state            = AutoState.Failed;
 }
Exemple #8
0
 void OnPhotonCreateRoomFailed()
 {
     state            = AutoState.Failed;
     statusLabel.text = "Failed to create a game, try later.";
 }
Exemple #9
0
 //
 public AutoFight()
 {
     kAutoState = CreateAutoState();
 }