Ejemplo n.º 1
0
    void Jump()
    {
        RaycastHit2D hit = Physics2D.Raycast(transform.position, Vector2.right * direction, 1, collisionMask);

        if (hit)
        {
            movement.Jump();
        }
    }
Ejemplo n.º 2
0
    protected virtual void Update()
    {
        #region Moving
        if (Input.GetKey(currentPreset.moveLeft))
        {
            if (Input.GetKey(currentPreset.run))
            {
                mb?.RunLeft();
            }
            else
            {
                mb?.MoveLeft();
            }
        }
        else if (Input.GetKey(currentPreset.moveRight))
        {
            if (Input.GetKey(currentPreset.run))
            {
                mb?.RunRight();
            }
            else
            {
                mb?.MoveRight();
            }
        }
        else
        {
            mb?.Stop();
        }

        if (Input.GetKey(currentPreset.jump))
        {
            mb?.Jump();
        }
        #endregion

        #region Shooting
        if (Input.GetKeyDown(currentPreset.shoot))
        {
            sb?.Shoot();
        }
        if (Input.GetKeyDown(currentPreset.reload))
        {
            sb?.Reload();
        }
        if (Input.GetKeyDown(currentPreset.aimUp))
        {
            sb?.RotateGun(true);
        }
        if (Input.GetKeyDown(currentPreset.aimDown))
        {
            sb?.RotateGun(false);
        }
        #endregion
    }