コード例 #1
0
        // constructor

        // singleton callbacks

        // unity callbacks
        void Awake()
        {
            if (m_isLocalPlayer)
            {
                // link HUD
                m_localActionsHUD = Object.FindObjectOfType(typeof(ActionsHUD)) as ActionsHUD;

                if (m_localActionsHUD != null)
                {
                    m_localActionsHUD.LocalPlayer = this;
                }
                else
                {
                    DebugUtil.LogError("Could not find local player's ActionsHUD");
                }

                // link game camera
                CameraManager.Instance.GuaranteeExists();

                if (CameraManager.Instance.GameCamera != null)
                {
                    CameraManager.Instance.GameCamera.transform.parent = m_cameraTransform;

                    // reset position/rotation
                    CameraManager.Instance.GameCamera.transform.localPosition = Vector3.zero;
                    CameraManager.Instance.GameCamera.transform.localRotation = Quaternion.identity;
                }
                else
                {
                    DebugUtil.LogError("Could not find GameCamera");
                }

                // filter our player model visibility with a layer
                LayerUtil.ChangeLayersRecursively(m_playerModel, "Player");

                // enable mouse
                m_mouseLookComponent.enabled = true;
            }
            else
            {
                m_mouseLookComponent.enabled = false;
            }

            m_playerAimComponent.enabled      = false;
            m_playerMovementComponent.enabled = false;

            // listen for my own death
            m_healthComponent.OnDied += new Health.DiedHandler(Died);
        }