예제 #1
0
    void Update()
    {
        player.SetDirectionalInput(new Vector2(InputManager.MainHorizontal(playerID), InputManager.MainVertical(playerID)), InputManager.RightBumper(playerID));

        if (InputManager.AButtonDown(playerID))
        {
            player.OnJumpInputDown();
        }
        if (InputManager.AButtonUp(playerID))
        {
            player.OnJumpInputUp();
        }
    }
예제 #2
0
    void Update()
    {
        //Rotation

        transform.rotation = Quaternion.Euler(0f, 0f, 0f);


        // Movement

        float axisX = InputManager.MainHorizontal();

        transform.Translate(new Vector3(axisX, 0) * Time.deltaTime * speed);
        if (axisX < 0)
        {
            Player.flipX    = true;
            BodyCol.offset  = new Vector2(-0.1f, 0.05f);
            FeetCol.offset  = new Vector2(-0.15f, -0.5f);
            SwordCol.offset = new Vector2(-0.85f, 0);
        }
        else if (axisX > 0)
        {
            Player.flipX    = false;
            BodyCol.offset  = new Vector2(0.1f, 0.05f);
            FeetCol.offset  = new Vector2(0.15f, -0.5f);
            SwordCol.offset = new Vector2(0.85f, 0);
        }

        if (InputManager.RBButton())
        {
            if (countGranade != 0)
            {
                Instantiate(granada, transform.position + new Vector3(0f, 1f, 0f), Quaternion.identity);
            }
            else
            {
                Invoke("Counter", 18000);
            }
        }
        // Jump

        if (InputManager.AButtonDown() && Onfloor)
        {
            jumpKeyHeld = true;
            GetComponent <Rigidbody2D>().AddForce(Vector3.up * jumpImpulse, ForceMode2D.Impulse);
        }

        if (InputManager.AButtonUp())
        {
            countDown   = 0.3f;
            jumpKeyHeld = false;
        }

        else if (InputManager.AButton())
        {
            countDown -= Time.deltaTime;
            if (jumpKeyHeld && countDown > 0f)
            {
                GetComponent <Rigidbody2D>().AddForce(Vector3.up * 10 * jumpForce, ForceMode2D.Force);
            }
        }

        if (GetComponent <Rigidbody2D>().velocity.y < 0)
        {
            GetComponent <Rigidbody2D>().velocity += Vector2.up * Physics2D.gravity.y * (fall) * Time.deltaTime;
        }
    }