Ejemplo n.º 1
0
    private void Start()
    {
        // in case we started this demo with the wrong scene being active, simply load the menu scene
        if (!PhotonNetwork.IsConnected)
        {
            SceneManager.LoadScene("TitleScreen");

            return;
        }

        currentRoom = PhotonNetwork.CurrentRoom;

        if (!PhotonNetwork.IsMasterClient)
        {
            StartButton.SetActive(false);
        }
        else
        {
            currentRoom.MaxPlayers = (byte)maxPlayers;
        }

        Debug.LogError(PlayerPrefs.GetInt("PlayerType"));

        localAgent = PhotonNetwork.Instantiate(agentPrefabs[PlayerPrefs.GetInt("PlayerType")].name, lobbyLocations[currentRoom.PlayerCount - 1].position, Quaternion.Euler(0, 180, 0));
        Debug.Log(currentRoom.PlayerCount);

        UpdateLobbyText();
    }
Ejemplo n.º 2
0
    private void Update()
    {
        // Check if all players are ready to start the game
        if (inMatchMaking)
        {
            Photon.Realtime.Room currentRoom = PhotonNetwork.CurrentRoom;
            if (currentRoom == null)
            {
                return;
            }
            mainMenu.matchMakingText.text = "Waiting for players... " + currentRoom.PlayerCount + "/" + MaxPlayer;

            if (currentRoom.PlayerCount == MaxPlayer && !isInGame)
            {
                // All players ready, start the game
                StartGame();
            }
        }
    }