示例#1
0
    public void Init(NetworkInstanceId playerAskingID)
    {
        if (_init)
        {
            return;
        }

        _init = true;

        PlayerNetwork[] playerNetworks = FindObjectsOfType <PlayerNetwork>();
        for (int i = 0; i < playerNetworks.Length; i++)
        {
            if (playerNetworks[i].netId == playerAskingID)
            {
                playerObserver = playerNetworks[i].gameObject;
                break;
            }
        }

        _playerNetwork = playerObserver.GetComponent <PlayerNetwork>();
        _playerLife    = GetComponentInChildren <PlayerLife>();
        _playerLife.SetPlayerNetwork(_playerNetwork);
        _playerMovement = GetComponent <PlayerMovement>();
        _playerFire     = GetComponent <PlayerFire>();
        _playerFire.SetPlayerNetwork(_playerNetwork);
        _playerCamera = GetComponent <PlayerCamera>();
        GameManager.GetInstance().localPlayerNetwork = _playerNetwork;
        if (isServer)
        {
            GameManager.GetInstance().PlayerJoin(this);
            GameManager.GetInstance().ShowLog(_playerNetwork.playerName + " joined the fight !");
        }
    }