Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //Get Input
        moveVertical   = Input_Manager.GetAxis("Move Vertical " + (playerNum + 1));
        moveHorizontal = Input_Manager.GetAxis("Move Horizontal " + (playerNum + 1));
        lookVertical   = Input_Manager.GetAxis("Look Vertical " + (playerNum + 1));
        lookHorizontal = Input_Manager.GetAxis("Look Horizontal " + (playerNum + 1));
        if (Input_Manager.GetAxisRaw("Move Vertical " + (playerNum + 1)) > 0 && previousMoveVertical == 0f)
        {
            if (Time.frameCount - lastTapFrame < 20)
            {
                RollForward();
            }
            else
            {
                lastTapFrame = Time.frameCount;
            }
        }
        previousMoveVertical = Input_Manager.GetAxisRaw("Move Vertical " + (playerNum + 1));
        if (Input.GetButton("Change Weapon " + (playerNum + 1)))
        {
            ChooseAttack(moveHorizontal, moveVertical);
        }
        if (Input.GetButton("Run " + (playerNum + 1)) && CheckGrounded())
        {
            movement.runMultiplier = 1.75f;
        }
        else
        {
            movement.runMultiplier = 1f;
        }

        if (Input.GetKeyDown("k"))
        {
            movement.LockOnEnemy();
        }

        //is input greater than 0

        else if (!rolling)
        {
            if (CheckGrounded() && Vector2.SqrMagnitude(new Vector2(moveHorizontal, moveVertical)) > 0.1f)
            {
                //Moves the player using velocities
                movement.Move(moveHorizontal, moveVertical);
            }
        }
        if (Input.GetButtonDown("Jump " + (playerNum + 1)) && CheckGrounded())
        {
            movement.Jump();
        }
        Attack();
        movement.AnimateMovement();
    }