Exemple #1
0
 public void AddPlayer(LobbyPlayerScript plrScript)
 {
     Debug.Log("[Lobby] Player Added");
     plrScript.gameObject.transform.SetParent(this.transform, false);
     plrScript.gameObject.transform.localPosition = new Vector3(0, 145 - (INDEX * 32), 0);
     INDEX++;
 }
Exemple #2
0
 // Use this for initialization
 void Start()
 {
     if (hasAuthority)
     {
         playerScript = this;
         CmdTestCommand();
     }
 }
 // Use this for initialization
 void Start()
 {
     if (hasAuthority)
     {
         playerScript = this;
         CmdTestCommand();
     }
 }
Exemple #4
0
    public override void OnServerAddPlayer(NetworkConnection conn)
    {
        if (SceneManager.GetActiveScene().path == menuScene)
        {
            bool isHost = m_roomPlayers.Count == 0;

            LobbyPlayerScript roomPlayerInstance = Instantiate(roomPlayerPrefab);

            roomPlayerInstance.IsHost = isHost;

            NetworkServer.AddPlayerForConnection(conn, roomPlayerInstance.gameObject);
            roomPlayerInstance.GetComponent <NetworkIdentity>().AssignClientAuthority(conn);
        }
    }
    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;
        }
    }
 void Awake()
 {
     GameObject.Find("Lobby").GetComponent <Lobby>().AddGameObject(gameObject);
     lobbyplayerScript = transform.GetComponent <LobbyPlayerScript>();
 }
 void Awake()
 {
     GameObject.Find("Lobby").GetComponent<Lobby>().AddGameObject(gameObject);
     lobbyplayerScript = transform.GetComponent<LobbyPlayerScript>();
 }