示例#1
0
        // This is called by the hook of playerData SyncVar above
        void PlayerDataChanged(float _, float newPlayerData)
        {
            //Debug.Log(newPlayerData.ToString());
            //cylinder.transform.position = new Vector3(0, 0, 0);
            Vector3 changeInPosition = new Vector3(0, 0, playerData);

            cylinder.transform.localPosition = cylinderStartPosition + changeInPosition;
            OnPlayerDataChanged?.Invoke(newPlayerData);
        }
示例#2
0
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            // Activate the main panel
            ((BasicNetManager)NetworkManager.singleton).mainPanel.gameObject.SetActive(true);

            // Instantiate the player UI as child of the Players Panel
            playerUI = Instantiate(playerUIPrefab, ((BasicNetManager)NetworkManager.singleton).playersPanel);

            // Set this player object in PlayerUI to wire up event handlers
            playerUI.GetComponent <PlayerUI>().SetPlayer(this, isLocalPlayer);

            // Invoke all event handlers with the current data
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);
        }
示例#3
0
文件: Player.cs 项目: zabszk/Mirror
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            Debug.Log("OnStartClient");

            // Instantiate the player UI as child of the Players Panel
            playerUIObject = Instantiate(playerUIPrefab, CanvasUI.instance.playersPanel);
            playerUI       = playerUIObject.GetComponent <PlayerUI>();

            // wire up all events to handlers in PlayerUI
            OnPlayerNumberChanged = playerUI.OnPlayerNumberChanged;
            OnPlayerColorChanged  = playerUI.OnPlayerColorChanged;
            OnPlayerDataChanged   = playerUI.OnPlayerDataChanged;

            // Invoke all event handlers with the initial data from spawn payload
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);
        }
示例#4
0
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            // Instantiate the player UI as child of the Players Panel
            playerUIObject = Instantiate(playerUIPrefab, CanvasUI.instance.playersPanel);
            PlayerUI playerUI = playerUIObject.GetComponent <PlayerUI>();

            // wire up all events to handlers in PlayerUI
            OnPlayerNumberChanged = playerUI.OnPlayerNumberChanged;
            OnPlayerColorChanged  = playerUI.OnPlayerColorChanged;
            OnPlayerDataChanged   = playerUI.OnPlayerDataChanged;

            // Invoke all event handlers with the initial data from spawn payload
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);

            // Set isLocalPlayer for this Player in UI for background shading
            if (isLocalPlayer)
            {
                playerUI.SetLocalPlayer();
            }
        }
示例#5
0
        /// <summary>
        /// Called on every NetworkBehaviour when it is activated on a client.
        /// <para>Objects on the host have this function called, as there is a local client on the host. The values of SyncVars on object are guaranteed to be initialized correctly with the latest state from the server when this function is called on the client.</para>
        /// </summary>
        public override void OnStartClient()
        {
            // Activate the main panel
            ((BasicNetManager)NetworkManager.singleton).mainPanel.gameObject.SetActive(true);

            // Instantiate the player UI as child of the Players Panel
            playerUI = Instantiate(playerUIPrefab, ((BasicNetManager)NetworkManager.singleton).playersPanel);

            // this fixes the ar camera issue for multiple cameras
            if (GameObject.Find("ARCamera(Clone)") == null)
            {
                GameObject arcam = Instantiate(arCameraPrefab);
            }

            // Set this player object in PlayerUI to wire up event handlers
            playerUI.GetComponent <PlayerUI>().SetPlayer(this, isLocalPlayer);

            // Invoke all event handlers with the current data
            OnPlayerNumberChanged.Invoke(playerNumber);
            OnPlayerColorChanged.Invoke(playerColor);
            OnPlayerDataChanged.Invoke(playerData);
        }
示例#6
0
 // This is called by the hook of playerData SyncVar above
 void PlayerDataChanged(ushort _, ushort newPlayerData)
 {
     OnPlayerDataChanged?.Invoke(newPlayerData);
 }
示例#7
0
 // This is called by the hook of playerData SyncVar above
 void PlayerDataChanged(int _, int newPlayerData)
 {
     OnPlayerDataChanged?.Invoke(newPlayerData);
 }