Exemplo n.º 1
0
    void Start()
    {
        // Hardcoded designated playerID, only applicable for 2 players. Might need to research better solution.
        if (isServer)
        {
            if (isLocalPlayer)
            {
                playerID = 1;
            }
            else
            {
                playerID = 2;
            }
        }
        else
        {
            if (isLocalPlayer)
            {
                playerID = 2;
            }
            else
            {
                playerID = 1;
            }
        }

        // Initialize Variable
        offlineUIManager       = FindObjectOfType <UIMultiplayerManager>();
        networkButtonUIManager = FindObjectOfType <NetworkButtonFunctions>();

        // Get panel position based on playerID
        playerPanelPosition = FindObjectOfType <LobbyUIManager>().GetPanelPosition(playerID);

        // Enable public canvas (for local AND non-local players)
        transform.GetChild(PUBLIC_CANVAS_INT).gameObject.SetActive(true);

        // Non-local player to run the next method within and exit immediately
        if (!isLocalPlayer)
        {
            NonLocalPlayerInitialStatus(isThisPlayerReady);
            return;
        }

        // Only accessible by local player
        currentLocalInstance = this;

        offlineUIManager.OpenMultiplayerRoomPanel(true);
        networkButtonUIManager.OnSuccessfulConnectedToRoom();
        transform.GetChild(PRIVATE_CANVAS_INT).gameObject.SetActive(true);
        CmdIsPlayerReady(false);

        UpdatePlayerIdentity();

        // Show only the room's host IP Address
        if (isServer)
        {
            playerIPAddress.text = "IP Address is: " + LocalIPAddress();
        }
        else
        {
            playerIPAddress.text = "IP Address is: " + NetworkManager.singleton.networkAddress;
        }
    }