Exemplo n.º 1
0
    void Update()
    {
        if (m_device == null)
        {
            return;
        }

        if (m_device.GetPressDown(Valve.VR.EVRButtonId.k_EButton_ApplicationMenu))
        {
            SpectatorCamera specCamera = FindObjectOfType <SpectatorCamera>();
            if (specCamera != null)
            {
                specCamera.MoveCamera(transform.position, transform.rotation);
            }
        }

        if (m_heldObject != null)
        {
            if (((m_device.GetPressDown(Valve.VR.EVRButtonId.k_EButton_Grip) && m_heldObject.Attachable) || (!m_device.GetPress(Valve.VR.EVRButtonId.k_EButton_SteamVR_Trigger) && !m_itemAttached)) && !m_attachedThisFrame)
            {
                DetachItem();
            }
        }
        m_attachedThisFrame = false;
    }
Exemplo n.º 2
0
    void ChangeStateInternal(E_State state)
    {
        switch (state)
        {
        case E_State.Spectator_Free:

            CameraBehaviour = null;
            IgnoredCollider = null;

            BloodManagerSetNormalizedHealth();

            // prepare spectator cameras
            SpectatorCamera.SetSpectatorMode(SpectatorCamera.Mode.Free);

            BloodManagerSetNormalizedHealth();

            break;

        case E_State.Player:

            if (null != Player.LocalInstance)
            {
                CameraBehaviour = Player.LocalInstance.GetComponent <CameraBehaviour>();
                IgnoredCollider = Player.LocalInstance.Owner.CharacterController;

                if (CameraBehaviour)
                {
                    Transform desiredTransform = CameraBehaviour.GetDesiredCameraTransform();
                    if (desiredTransform)
                    {
                        PrevDist = (desiredTransform.position - CameraBehaviour.CameraOrigin.position).magnitude;
                    }
                }
            }

            SpectatorCamera.SetSpectatorMode(SpectatorCamera.Mode.None);

            break;

        case E_State.Spectator_FollowPlayer:

            CameraBehaviour = null;
            IgnoredCollider = null;

            SpectatorCamera.SetSpectatorMode(SpectatorCamera.Mode.FollowPlayer);

            break;
        }

        State = state;

        // immediate camera update to prevent camera glitches
        UpdateCamera();
    }
Exemplo n.º 3
0
    public static void SetSpectatorMode(Mode NewMode)
    {
        if (mCurrentMode == NewMode)
        {
            return;
        }

        mCurrentMode = NewMode;

        switch (mCurrentMode)
        {
        case Mode.Free:

            RestorePreviousCamera();

            if (mSpectatorCameras.Count > 0)
            {
                mCurrentSpectatorCamera = mSpectatorCameras[Random.Range(0, mSpectatorCameras.Count)];

                if (null != mCurrentSpectatorCamera)
                {
                    mPreviousCamera = Camera.main;

                    mCurrentSpectatorCamera.Activate(true);

                    if (null != mPreviousCamera)
                    {
                        mPreviousCamera.enabled = false;

                        SetupAudioListeners(mPreviousCamera.gameObject, false);
                    }
                }
            }

            break;

        case Mode.FollowPlayer:

            RestorePreviousCamera();

            break;

        default:

            RestorePreviousCamera();

            mAutoSwitch = true;

            break;
        }
    }
Exemplo n.º 4
0
    static void RestorePreviousCamera()
    {
        if (null != mPreviousCamera)
        {
            mPreviousCamera.enabled = true;

            SetupAudioListeners(mPreviousCamera.gameObject, true);

            if (null != mCurrentSpectatorCamera)
            {
                mCurrentSpectatorCamera.Activate(false);

                mCurrentSpectatorCamera = null;
            }

            mPreviousCamera = null;
        }
    }
Exemplo n.º 5
0
 private void Update()
 {
     if (this.listenerPos == null)
     {
         SpectatorCamera spectatorCamera = UnityEngine.Object.FindObjectOfType <SpectatorCamera>();
         if (spectatorCamera != null)
         {
             this.listenerPos = spectatorCamera.cam.transform;
         }
     }
     if (this.listenerPos.position.y > 900f && !this.isOutside)
     {
         this.isOutside = true;
         this.SetOutside(true);
     }
     if (this.listenerPos.position.y < 900f && this.isOutside)
     {
         this.isOutside = false;
         this.SetOutside(false);
     }
 }
Exemplo n.º 6
0
    // =================================================================================================================
    // ===  internal  ==================================================================================================

    // update state of 'follow player' and 'free' spectator buttons
    void UpdateButtonsState()
    {
        bool canFollowPlayer = SpectatorCamera.Spectator_CanFollowPlayer();

        m_FollowPlayer_Button.SetNewText(FollowingPlayer ? 0502019 : 0502018);
        m_FollowPlayer_Button.SetDisabled(!canFollowPlayer);

        Client client = Client.Instance;

        if (client != null)
        {
            bool disable  = client.GameState.State == Client.ClientGameState.Running || WaitingForSpawn;
            bool canSpawn = true;

            switch (client.GameState.GameType)
            {
            case E_MPGameType.DeathMatch:
                canSpawn = Client.TimeToRespawn <= client.GameState.DMInfo.RestTimeSeconds ? true : false;
                break;

            case E_MPGameType.ZoneControl:
                PlayerPersistantInfo localPPI = PPIManager.Instance.GetLocalPPI();
                canSpawn = localPPI.Team != E_Team.None && localPPI.ZoneIndex >= 0 ? true : false;
                break;

            default:
                Debug.LogError("Unknown Game Type ");
                break;
            }

            m_Cancel_Button.SetDisabled(disable);
            m_Spawn_Button.SetDisabled(disable || !client.IsReadyForSpawn() || GameCloudManager.isBusy || !canSpawn);

            if (canSpawn == false)
            {
                UpdateControlsVisibility();
            }
        }
    }
Exemplo n.º 7
0
    protected override void OnViewUpdate()
    {
        base.OnViewUpdate();

        if (m_Score.IsVisible == true)
        {
            m_Score.UpdateView();
        }

        if (WaitingForSpawn == false)
        {
            int    minutes = Client.TimeToRespawn / 60;
            int    seconds = Client.TimeToRespawn % 60;
            string time    = string.Format("{0:00}:{1:00}", minutes, seconds);

            // Get time to next spawn...
            m_NextSpawn_Label.SetNewText(time);

            if (m_NextSpawn_Label.Widget.Visible == false)
            {
                UpdateControlsVisibility();
            }
        }

        // update following player name
        if (FollowingPlayer == true)
        {
            m_PlayerName_Label.SetNewText(GuiBaseUtils.FixNameForGui(SpectatorCamera.GetSpectatedPlayerName()));
        }

        // update state of 'follow player' and 'free' spectator buttons
        UpdateButtonsState();
        UpdateZoneControlState();
        UpdateDeathMatchState();

        SetAnticheatButtonVisibility(SecurityTools.UserHasAnticheatManagementPermissions());
    }
Exemplo n.º 8
0
 void OnNextPlayer(GUIBase_Widget inWidget)
 {
     SpectatorCamera.NextPlayer();
 }
Exemplo n.º 9
0
 void OnPrevPlayer(GUIBase_Widget inWidget)
 {
     SpectatorCamera.PrevPlayer();
 }
Exemplo n.º 10
0
    void UpdateCamera()
    {
        if (State == E_State.Spectator_Free)
        {
            // disable camera effects
            BloodManagerSetNormalizedHealth();

            return;
        }

        if (State == E_State.Spectator_FollowPlayer)
        {
            if (SpectatorCamera.Spectator_CanFollowPlayer())
            {
                if (null == CameraBehaviour)
                {
                    AgentHuman Owner = SpectatorCamera.SelectNextAgentToFollow();

                    if (null != Owner)
                    {
                        CameraBehaviour = Owner.GetComponent <CameraBehaviour>();
                        IgnoredCollider = Owner.CharacterController;

                        if (CameraBehaviour)
                        {
                            Transform desiredTransform = CameraBehaviour.GetDesiredCameraTransform();

                            if (desiredTransform)
                            {
                                PrevDist = (desiredTransform.position - CameraBehaviour.CameraOrigin.position).magnitude;
                            }
                        }
                    }
                }
                else
                {
                    // already watching one
                    if (!SpectatorCamera.UpdateFollowPlayer())
                    {
                        GameCamera.ChangeMode(GameCamera.E_State.Spectator_FollowPlayer);
                    }
                }
            }
            else
            {
                ChangeStateInternal(E_State.Spectator_Free);
            }
        }

        if (DisabledTime >= Time.timeSinceLevelLoad)
        {
            return;
        }

        if (Time.deltaTime == 0 || !CameraBehaviour)
        {
            return;
        }

        //Collide camera
//		CollideCamera();
        CollideCamera5();
    }
Exemplo n.º 11
0
 private void Start()
 {
     m_topDown   = GetComponent <TopDownCamera> ();
     m_death     = GetComponent <DeathCamera> ();
     m_spectator = GetComponent <SpectatorCamera> ();
 }