Exemplo n.º 1
0
        // Update is called once per frame
        private void Update()
        {
            RotateView();
            // the jump state needs to read here to make sure it is not missed
            if (!m_Jump)
            {
                //m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
                if (!UnityEngine.XR.XRDevice.isPresent)
                {
                    m_Jump = Input.GetKeyDown(KeyBindingScript.buttons["Jump"]) || Input.GetKeyDown(KeyBindingScript.controller["C_Jump"]);
                }
                else
                {
                    m_Jump = KeyBindingScript.JumpPressedVR();
                }
            }

            if (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
            {
                StartCoroutine(m_JumpBob.DoBobCycle());
                PlayLandingSound();
                m_MoveDir.y = 0f;
                m_Jumping   = false;
            }
            if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
            {
                m_MoveDir.y = 0f;
            }

            m_PreviouslyGrounded = m_CharacterController.isGrounded;
        }
Exemplo n.º 2
0
    void Update()
    {
        if (!jumpPushed)
        {
            if (KeyBindingScript.LeftController != null && KeyBindingScript.RightController != null)
            {
                jumpPushed = KeyBindingScript.JumpPressedVR();
            }
            else
            {
                jumpPushed = false;
            }
        }
        if (!wasGrounded && controller.isGrounded)
        {
            yVelocity = 0f;
            IsJumping = false;
        }
        if (!controller.isGrounded && !IsJumping && wasGrounded)
        {
            yVelocity = 0f;
        }

        wasGrounded = controller.isGrounded;
    }
Exemplo n.º 3
0
    public void TryThrow()
    {
        bool attemptThrow;

        if (!UnityEngine.XR.XRDevice.isPresent)
        {
            attemptThrow = (Input.GetKeyDown(KeyBindingScript.buttons["Throw"]) || Input.GetKey(KeyBindingScript.controller["C_Throw"]));
        }
        else
        {
            if (KeyBindingScript.LeftController != null && KeyBindingScript.RightController != null)
            {
                attemptThrow = KeyBindingScript.ThrowPressedVR();
            }
            else
            {
                attemptThrow = false;
            }
        }

        if (attemptThrow && PlayerInventory.CanUse(ItemType.Ofuda))
        {
            ThrowOfuda();
        }
        else
        {
            thrown = false;
        }
    }
Exemplo n.º 4
0
    public void TryDraw()
    {
        bool attemptDraw;

        if (!UnityEngine.XR.XRDevice.isPresent)
        {
            attemptDraw = (Input.GetKey(KeyBindingScript.buttons["Draw"]) || Input.GetKey(KeyBindingScript.controller["C_Draw"])); // TODO move this all into KeyBindScript with one function to call
        }
        else
        if (KeyBindingScript.LeftController != null && KeyBindingScript.RightController != null)     // TODO move this into KeyBindScript
        {
            attemptDraw = KeyBindingScript.DrawPressedVR();
        }
        else
        {
            attemptDraw = false;
        }

        if (attemptDraw && PlayerInventory.CanUse(ItemType.Chalk))
        {
            DrawChalk();
        }
        else
        {
            drawing = false;
        }

        // analytics
        if (drawing)
        {
            if (!isDrawingToPush)
            {
                isDrawingToPush = true;
                drawingEventID  = GameManager.Instance.UsedItem(ItemType.Chalk);
            }

            lastDrawTime = Time.time;
        }
        else if (isDrawingToPush && Time.time > lastDrawTime + TimeBetweenDrawings)
        {
            GameManager.Instance.MarkDrawn(drawingEventID, linesToPush);
            linesToPush.Clear();
            isDrawingToPush = false;
        }
    }
Exemplo n.º 5
0
    private Vector2 getAnalog()
    {
        Vector2 move = Vector2.zero;

        move.x = CrossPlatformInputManager.GetAxis("Horizontal");
        move.y = CrossPlatformInputManager.GetAxis("Vertical");
        if (move.sqrMagnitude > 1)
        {
            move.Normalize();
        }

        if (KeyBindingScript.LeftController != null && KeyBindingScript.RightController != null)
        {
            IsWalking = !KeyBindingScript.RunPressedVR(); // TODO VR Button
        }
        else
        {
            IsWalking = true;
        }

        return(move);
    }
Exemplo n.º 6
0
        private void GetInput(out float speed)
        {
            // Read input
            float horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            float vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            bool waswalking = m_IsWalking;

#if !MOBILE_INPUT
            // On standalone builds, walk/run speed is modified by a key press.
            // keep track of whether or not the character is walking or running
            if (!UnityEngine.XR.XRDevice.isPresent)
            {
                m_IsWalking = !(Input.GetKey(KeyBindingScript.buttons["Run"]) || Input.GetKey(KeyBindingScript.controller["C_Run"]));
            }
            else
            {
                m_IsWalking = !KeyBindingScript.RunPressedVR();
            }
#endif
            // set the desired speed to be walking or running
            speed   = m_IsWalking ? m_WalkSpeed : m_RunSpeed;
            m_Input = new Vector2(horizontal, vertical);

            // normalize input if it exceeds 1 in combined length:
            if (m_Input.sqrMagnitude > 1)
            {
                m_Input.Normalize();
            }

            // handle speed change to give an fov kick
            // only if the player is going to a run, is running and the fovkick is to be used
            if (m_IsWalking != waswalking && m_UseFovKick && m_CharacterController.velocity.sqrMagnitude > 0)
            {
                StopAllCoroutines();
                StartCoroutine(!m_IsWalking ? m_FovKick.FOVKickUp() : m_FovKick.FOVKickDown());
            }
        }