// Update is called once per frame
        private void Update()
        {
            this.RotateView();
            // the jump state needs to read here to make sure it is not missed
            if (!this.m_Jump)
            {
                this.m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

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

            this.m_PreviouslyGrounded = this.m_CharacterController.isGrounded;
        }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        bool isShooting = false;

        switch (Application.platform)
        {
        case RuntimePlatform.WindowsEditor:
            isShooting = Input.GetMouseButtonDown(0);
            break;

        case RuntimePlatform.Android:
            isShooting = CrossPlatformInputManager.GetButtonDown("Shoot");
            break;
        }
        if (isShooting && GameManager.gm.gameState == GameManager.GameState.Playing)
        {
            Shoot();
        }
        else
        {
            gunLine.enabled = false;
        }
    }
Ejemplo n.º 3
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_IsJumping && !m_IsSquatting)
            {
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

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

            m_PreviouslyGrounded = m_CharacterController.isGrounded;
        }
Ejemplo n.º 4
0
        private void Update()
        {
            if (!m_Jump)
            {
                // Read the jump input in Update so button presses aren't missed.
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

            if (!m_Attack)
            {
                // Read the jump input in Update so button presses aren't missed.
                m_Attack = CrossPlatformInputManager.GetButtonDown("Fire1");
            }
            else if (m_Attack)
            {
                m_Attack = false;
            }

            if (CrossPlatformInputManager.GetButtonDown("Cancel"))
            {
                SceneManager.LoadScene("Forest");
            }
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Adds tab as a form of selection.
    /// </summary>
    public override void OnUpdate()
    {
        EventSystem.current.sendNavigationEvents = !disableInput;
        UpdateCursorLocking();
        if (disableInput)
        {
            return;
        }

        if (EventSystem.current.currentSelectedGameObject)
        {
            var selected = EventSystem.current.currentSelectedGameObject.GetComponent <Selectable>();

            if (CrossPlatformInputManager.GetButtonDown("MenuSelect"))
            {
                selected = selected.FindSelectableOnDown();
                if (selected != null)
                {
                    selected.Select();
                }
            }
        }
    }
Ejemplo n.º 6
0
 private void Throw()
 {
     //Throw Animation
     if (CrossPlatformInputManager.GetButtonDown("Throw") && throwcooldowntimer == 0)
     {
         if (!KunaiFinished)
         {
             throwcooldowntimer = throwcooldown;
             anim.SetBool("IsThrowing", true);
             if (!KunaiFinished)
             {
                 var firedkunai = Instantiate(kunai, barrel.position, Quaternion.identity);
                 firedkunai.AddForce(barrel.up * throwspeed);
                 KunaiSystem.TakeLife();
                 ThrowSound.Play();
             }
         }
     }
     else
     {
         anim.SetBool("IsThrowing", false);
     }
 }
    void BasicAttack()
    {
        if (CrossPlatformInputManager.GetButtonDown("Attack") && !attacking && canAttack)
        {
            attacking             = true;
            attackTimer           = attackCooldown;
            attackTrigger.enabled = true;
        }

        if (attacking)
        {
            if (attackTimer > 0)
            {
                attackTimer -= Time.deltaTime;
            }
            else
            {
                attackTimer           = 0;
                attacking             = false;
                attackTrigger.enabled = false;
            }
        }
    }
Ejemplo n.º 8
0
        /*void SetFocus(Interactable newFocus)
         * {
         *  focus = newFocus;
         * }
         *
         * void RemoveFocus()
         * {
         *  focus = null;
         * }*/


        private void FixedUpdate()
        {
            //Update movement
            if (canMove)
            {
                rigidBody.MovePosition(rigidBody.position + moveVelocity * Time.fixedDeltaTime);

                if (moveInput != Vector3.zero)
                {
                    targetRotation        = Quaternion.LookRotation(moveInput);
                    transform.eulerAngles = Vector3.up * Mathf.MoveTowardsAngle(transform.eulerAngles.y, targetRotation.eulerAngles.y, rotationSpeed * Time.fixedDeltaTime);
                }
            }
            else if (!canMove && isInCar)
            {
                this.transform.position = interactingObject.transform.position;

                if (CrossPlatformInputManager.GetButtonDown("Use1"))
                {
                    StartCoroutine(ExitCar(interactingObject));
                }
            }
        }
Ejemplo n.º 9
0
        protected override void Update()
        {
            base.Update();

            if (this._isBeingHeld)
            {
                bool shoot  = CrossPlatformInputManager.GetButtonUp(GlobalUtilities.ATTACK_1);
                bool reload = CrossPlatformInputManager.GetButtonDown(GlobalUtilities.RELOAD);

                if (shoot)
                {
                    Shoot();
                }

                if (reload && this.NeedsReload())
                {
                    this._isReloading = true;
                }

                //check reload every frame
                Reload();
            }
        }
Ejemplo n.º 10
0
    // Update is called once per frame
    void Update()
    {
        if (isActive)   //the pause menu should be displayed
        {
            menuToDisplay.SetActive(true);
            Cursor.visible   = true;
            Cursor.lockState = CursorLockMode.None;
            Time.timeScale   = 0;
        }

        else
        {
            menuToDisplay.SetActive(false);
            Cursor.visible   = false;
            Cursor.lockState = CursorLockMode.None;
            Time.timeScale   = 1;
        }

        if (CrossPlatformInputManager.GetButtonDown("Start"))
        {
            ResumeGame();
        }
    }
Ejemplo n.º 11
0
 private void Jump()
 {
     if (playerRb.velocity.y < 0)
     {
         playerRb.velocity += Vector2.up * Physics2D.gravity.y * (fallMultiplier - 1) * Time.deltaTime;
     }
     else if (!CrossPlatformInputManager.GetButtonDown("Jump") && playerRb.velocity.y > 0)
     {
         playerRb.velocity += Vector2.up * Physics2D.gravity.y * (jumpMultiplier - 1) * Time.deltaTime;
     }
     if (!feetCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
     {
         return;
     }
     else if (feetCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
     {
         if (CrossPlatformInputManager.GetButtonDown("Jump"))
         {
             Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
             playerRb.velocity += jumpVelocityToAdd;
         }
     }
 }
        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 (!m_PreviouslyGrounded && m_CharacterController.isGrounded)
            {
                StartCoroutine(m_JumpBob.DoBobCycle());
                AkSoundEngine.PostEvent("Play_land", gameObject);
                m_MoveDir.y = 0f;
                m_Jumping   = false;
            }
            if (!m_CharacterController.isGrounded && !m_Jumping && m_PreviouslyGrounded)
            {
                m_MoveDir.y = 0f;
            }

            m_PreviouslyGrounded = m_CharacterController.isGrounded;
        }
Ejemplo n.º 13
0
    void FixedUpdate()
    {
        if (viewer.isActivated)
        {
            input = new InputObject();

            input.horizontal = CrossPlatformInputManager.GetAxis("Horizontal");
            input.vertical   = CrossPlatformInputManager.GetAxis("Vertical");

            input.isSubmitDown  = CrossPlatformInputManager.GetButtonDown("Submit");
            input.isCancelDown  = CrossPlatformInputManager.GetButtonDown("Cancel");
            input.isLeftDown    = CrossPlatformInputManager.GetButtonDown("Left");
            input.isRightDown   = CrossPlatformInputManager.GetButtonDown("Right");
            input.isZoomInDown  = CrossPlatformInputManager.GetButtonDown("ZoomIn");
            input.isZoomOutDown = CrossPlatformInputManager.GetButtonDown("ZoomOut");

            viewer.SetInput(input);
        }
        else if (CrossPlatformInputManager.GetButtonDown("Submit"))
        {
            viewer.Activate();
        }
    }
Ejemplo n.º 14
0
 void DetermineDashState()
 {
     if (CrossPlatformInputManager.GetAxis("Vertical") == 1 & CrossPlatformInputManager.GetButtonDown("Jump"))
     {
         dashState = "up";
     }
     else if (CrossPlatformInputManager.GetAxis("Vertical") == -1 & CrossPlatformInputManager.GetButtonDown("Jump"))
     {
         dashState = "down";
     }
     else if (CrossPlatformInputManager.GetAxis("Horizontal") == -1 & CrossPlatformInputManager.GetButtonDown("Jump"))
     {
         dashState = "left";
     }
     else if (CrossPlatformInputManager.GetAxis("Horizontal") == 1 & CrossPlatformInputManager.GetButtonDown("Jump"))
     {
         dashState = "right";
     }
     else if (CrossPlatformInputManager.GetButtonDown("Jump"))
     {
         dashState = "forward";
     }
 }
Ejemplo n.º 15
0
    // Update is called once per frame
    void Update()
    {
        if (equippedItem != items[currentEquipIndex])
        {
            equippedItem.SetActive(false);
            items[currentEquipIndex].SetActive(true);
            equippedItem = items[currentEquipIndex];
        }
        equippedItem = items[currentEquipIndex];

        if (isPlayer)
        {
            if (CrossPlatformInputManager.GetButton("Fire1") && equippedItem.activeInHierarchy == true)
            {
                UseItem();
            }

            if (CrossPlatformInputManager.GetButtonDown("Jump") && equippedItem.activeInHierarchy == true)
            {
                SwapItem();
            }
        }
    }
        // 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 (!_jump)
            {
                _jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

            if (!_previouslyGrounded && _characterController.isGrounded)
            {
                StartCoroutine(_jumpBob.DoBobCycle());
                PlayLandingSound();
                _moveDir.y = 0f;
                _jumping   = false;
            }
            if (!_characterController.isGrounded && !_jumping && _previouslyGrounded)
            {
                _moveDir.y = 0f;
            }

            _previouslyGrounded = _characterController.isGrounded;
        }
Ejemplo n.º 17
0
    // LET THE KNIGHT INFLICT DAMAGE WHEN WE'RE AT STRIKING DISTANCE.
    public void IsAttacking()
    {
        var knightPosition = knight.transform.position.x;

        if (knightPosition > -2.5 && knightPosition < 2.5)
        {
            if (CrossPlatformInputManager.GetButtonDown("Fire1"))
            {
                health -= damage;
                GetComponent <SpriteRenderer>().color = Color.red;

                if (health <= 0)
                {
                    Destroy(gameObject);
                    Death();
                }
            }
            else
            {
                GetComponent <SpriteRenderer>().color = Color.white;
            }
        }
    }
Ejemplo n.º 18
0
    //movement
    private void Jump()
    {
        bool verticalInputUpwards = CrossPlatformInputManager.GetButtonDown("Jump");

        if (isGrounded)
        {
            anim.SetTrigger("isNotJumping");
            groundedTimer = 0f;
        }

        if (!isGrounded)
        {
            groundedTimer += Time.deltaTime;
        }
        bool kindaGrounded = groundedTimer <= jumpTimeLimit;

        if (verticalInputUpwards && kindaGrounded && canJump)
        {
            var jumpVector = new Vector2(rb.velocity.x, jumpForce);
            rb.velocity = jumpVector;
            anim.SetTrigger("isJumping");
        }
    }
    public void Jump()
    {
        if (myFeetCollider.IsTouchingLayers(LayerMask.GetMask("Ground")) &&
            myRigidBody.velocity.y == 0)
        {
            gameSession.JumpSmallContr();

            myAnim.SetBool("IsJumping", false);
            myJumps = 0;
        }

        if (CrossPlatformInputManager.GetButtonDown("Jump") && myJumps < 2)
        {
            gameSession.JumpBigContr();

            AudioSource.PlayClipAtPoint(jumpSwing, transform.position);
            myAnim.SetBool("IsJumping", true);
            myJumps++;

            Vector2 jumpVelocityToAdd = new Vector2(0f, jumpSpeed);
            myRigidBody.velocity = jumpVelocityToAdd;
        }
    }
        protected override void Update()
        {
            if (controlEnabled)
            {
                move.x = CrossPlatformInputManager.GetAxisRaw("Horizontal");

                if (jumpState == JumpState.Grounded && CrossPlatformInputManager.GetButtonDown("Jump"))
                {
                    jumpState = JumpState.PrepareToJump;
                }
                else if (CrossPlatformInputManager.GetButtonUp("Jump"))
                {
                    stopJump = true;
                    Schedule <PlayerStopJump>().player = this;
                }
            }
            else
            {
                move.x = 0;
            }
            UpdateJumpState();
            base.Update();
        }
Ejemplo n.º 21
0
    void Update()
    {
        if (!_blockControl)
        {
            bool isJumped = false;

            if (_mobileControl)
            {
                isJumped = CrossPlatformInputManager.GetButtonDown("Jump");
            }
            else
            {
                isJumped = Input.GetButtonDown("Jump");
            }

            if (isJumped && _grounded)
            {
                Jump = true;
                //_animator.SetTrigger("toJump");
                _animator.SetBool("jump", Jump);
            }
        }
    }
Ejemplo n.º 22
0
    // Update is called once per frame
    void Update()
    {//throw idea away
        if (active)
        {
            UpdateSelectionFocusandMoveBlocks();
            HandleSelection();
            DrawSelection();
        }
        if (CrossPlatformInputManager.GetButtonDown("Submit"))
        {
            enableControls();
        }

        if (CrossPlatformInputManager.GetAxis("Horizontal") != 0)
        {
            enableControls();
        }

        if (CrossPlatformInputManager.GetAxis("Vertical") != 0)
        {
            enableControls();
        }
    }
    void Update()
    {
        isTalking   = talk.talking;
        isTalkingES = talkES.talking;
        isPaused    = pause.paused;

        if ((isTalking) || (isPaused) || (isTalkingES))
        {
            runSpeed = 0f;
            jump     = false;
        }
        else if ((!isTalking) || (!isPaused) || (!isTalkingES))
        {
            runSpeed = 40f;
            if (CrossPlatformInputManager.GetButtonDown("Jump"))
            {
                jump = true;
                jump_char_Sound.Play();
            }
        }

        horizontalMove = CrossPlatformInputManager.GetAxisRaw("Horizontal") * runSpeed;
    }
Ejemplo n.º 24
0
 // Update is called once per frame
 void Update()
 {
     if (CrossPlatformInputManager.GetButtonDown("Spawn"))
     {
         SpawnObject();
     }
     if (CrossPlatformInputManager.GetAxisRaw("DHoriz") < 0 && !dpBusy)
     {
         dpBusy            = true;
         index             = (index > 0) ? index - 1 : 0;
         selectedName.text = objectNames[index];
     }
     if (CrossPlatformInputManager.GetAxisRaw("DHoriz") > 0 && !dpBusy)
     {
         dpBusy            = true;
         index             = (index < 4) ? index + 1 : 4;
         selectedName.text = objectNames[index];
     }
     if (CrossPlatformInputManager.GetAxisRaw("DHoriz") == 0)
     {
         dpBusy = false;
     }
 }
Ejemplo n.º 25
0
        //Sets everything up once the character is spawned
        void Update()
        {
            if (aiming)
            {
                if (inVehicle)
                {
                    distance = Mathf.Lerp(distance, distanceAimVehicle, 5 * Time.deltaTime);
                }
                else
                {
                    distance = Mathf.Lerp(distance, distanceAim, 5 * Time.deltaTime);
                }
            }
            else if (!aiming)
            {
                if (inVehicle)
                {
                    distance = Mathf.Lerp(distance, distanceNormalVehicle, 5 * Time.deltaTime);
                }
                else
                {
                    distance = Mathf.Lerp(distance, distanceNormal, 5 * Time.deltaTime);
                }
            }

                        #if (CROSS_PLATFORM_INPUT)
            if (CrossPlatformInputManager.GetButtonDown("CameraViewChange") && !pause)
                        #else
            if (Input.GetKeyDown(KeyCode.V) && !pause)
                        #endif
            { firstPerson = !firstPerson; }

            if (target != null)
            {
                return;
            }
        }
Ejemplo n.º 26
0
        // Update is called once per frame
        private void Update()
        {
            if (!m_IsCaptured && Input.GetMouseButtonDown(0))
            {
                OnEnable();
            }

            if (m_IsCaptured && Input.GetKeyDown(KeyCode.Escape))
            {
                OnDisable();
            }

            if (m_IsCaptured)
            {
                RotateView();
            }

            // the jump state needs to read here to make sure it is not missed
            if (!m_Jump)
            {
                m_Jump = CrossPlatformInputManager.GetButtonDown("Jump");
            }

            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;
        }
Ejemplo n.º 27
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 (!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;

            // Lock or unlock cursor
            if (Input.GetKeyDown(KeyCode.P))
            {
                Debug.Log("Checking cursor...");
                if (Cursor.lockState == CursorLockMode.None)
                {
                    Cursor.lockState = CursorLockMode.Locked;
                }
                else
                {
                    Cursor.lockState = CursorLockMode.None;
                }
            }
        }
Ejemplo n.º 28
0
Archivo: Player.cs Proyecto: hlais/Q
    public void Jump()
    {
        if (!qCollider.IsTouchingLayers(LayerMask.GetMask("Ground")))
        {
            qAnimator.SetBool("IsJumping", false);


            qAnimator.ResetTrigger("IsAttacking");
            return;
        }

        if (qCollider.IsTouchingLayers(LayerMask.GetMask("Wall")))
        {
            qAnimator.SetBool("IsJumping", false);

            return;
        }


        if (!isKeyBoardControlsOn)
        {
            //bool isJumping = Input.GetButtonDown("Jump");
            isJumping = CrossPlatformInputManager.GetButtonDown("Jump");
        }
        else
        {
            isJumping = Input.GetButton("Jump");
        }


        if (isJumping)
        {
            Vector2 qJumpVelocity = new Vector2(0f, jumpForce);
            qRigidBody.velocity += qJumpVelocity;
            qAnimator.SetBool("IsJumping", true);
        }
    }
Ejemplo n.º 29
0
    // Update is called once per frame
    void Update()
    {
        if (health <= 0)
        {
            // Destroy(gameObject);
        }

        //for joystick
        //dirXJoystick = joystick.Horizontal;
        // transform.Translate(new Vector2(dirXJoystick * speed * Time.deltaTime, 0f));

        //for button
        dirX = CrossPlatformInputManager.GetAxis("Horizontal");
        transform.Translate(new Vector2(dirX * speed * Time.deltaTime, 0f));

        if (dirX < 0 || dirXJoystick < -0.2)
        {
            anim.SetTrigger("Walk");
            transform.localScale = new Vector3(-scaleX, transform.localScale.y, transform.localScale.z);
        }
        else if (dirX > 0 || dirXJoystick > 0.2)
        {
            anim.SetTrigger("Walk");
            transform.localScale = new Vector3(scaleX, transform.localScale.y, transform.localScale.z);
        }
        else
        {
            anim.SetTrigger("Stop");
            transform.localScale = new Vector3(transform.localScale.x, transform.localScale.y, transform.localScale.z);
        }

        if ((CrossPlatformInputManager.GetButtonDown("Jump") || joystick.Vertical > 0.5) && isGround)
        {
            rigid.velocity = Vector2.zero;
            rigid.AddForce(Vector2.up * jump);
        }
    }
Ejemplo n.º 30
0
    public void Jump()
    {
        if (isGrounded == true && CrossPlatformInputManager.GetButtonDown("Jump"))
        {
            rb.velocity = new Vector2(rb.velocity.x, jumpForce);
            anim.SetTrigger("takeOff");
            isJumping       = true;
            jumpTimeCounter = jumpTime;
        }

        if (CrossPlatformInputManager.GetButton("Jump") && isJumping == true)
        {
            if (jumpTimeCounter > 0)
            {
                rb.velocity      = new Vector2(rb.velocity.x, jumpForce);
                jumpTimeCounter -= Time.deltaTime;
            }
            else
            {
                isJumping = false;
            }
        }
        if (CrossPlatformInputManager.GetButtonUp("Jump"))
        {
            isJumping = false;
        }


        if (isGrounded == true)
        {
            anim.SetBool("isJumping", false);
        }
        else
        {
            anim.SetBool("isJumping", true);
        }
    }