Esempio n. 1
0
    void HandleMovement()
    {
        if (Input.GetButton(inputMoveButton))
        {
            Vector2 mousePosition = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            targetPosition = mousePosition;

            targetSet = true;
        }

        movementTarget.position = targetPosition;

        if (targetSet)
        {
            if (movementController is TurnAndMoveTowardsTarget)
            {
                ((TurnAndMoveTowardsTarget)movementController).target = movementTarget;
            }
        }

        if (canMoveWhileAttacking || weaponHandler == null || !weaponHandler.IsAttacking())
        {
            movementController.Move();
        }

        targetSet = false;
    }
Esempio n. 2
0
    void HandleMovement()
    {
        float horizontal = 0.0f;
        float vertical   = 0.0f;

        if (canMoveWhileAttacking || weaponHandler == null || !weaponHandler.IsAttacking())
        {
            horizontal = Input.GetAxis(inputHorizontalAxis);
            vertical   = Input.GetAxis(inputVerticalAxis);
        }

        bool doMove = false;
        bool doTurn = false;

        float horizontalMovement = 0.0f;
        float verticalMovement   = 0.0f;

        if (horizontal > 0.0f)
        {
            horizontalMovement = 1.0f;
            doTurn             = true;
        }
        else if (horizontal < 0.0f)
        {
            horizontalMovement = -1.0f;
            doTurn             = true;
        }

        if (vertical > 0.0f)
        {
            verticalMovement = 1.0f;
            doMove           = true;
        }
        else if (vertical < 0.0f)
        {
            verticalMovement = -1.0f;
            doMove           = true;
        }

        movementController.movementDirection = new Vector2(0.0f, verticalMovement);
        rotationController.movementDirection = new Vector2(horizontalMovement, 0.0f);

        if (doMove)
        {
            movementController.Move();
        }

        if (doTurn)
        {
            rotationController.Move();
        }

        if (facingHandler != null)
        {
            facingHandler.UpdateFacing();
        }
    }
Esempio n. 3
0
    void HandleMovement()
    {
        float horizontal = 0.0f;
        float vertical   = 0.0f;

        if (canMoveWhileAttacking || weaponHandler == null || !weaponHandler.IsAttacking())
        {
            horizontal = Input.GetAxisRaw("Horizontal");
            vertical   = Input.GetAxisRaw("Vertical");
        }

        movementController.movementDirection = new Vector2(horizontal, vertical);

        if (facingHandler != null)
        {
            facingHandler.UpdateFacing();
        }
    }
Esempio n. 4
0
    void HandleMovement()
    {
        float horizontal = 0.0f;
        float vertical   = 0.0f;

        if (canMoveWhileAttacking || weaponHandler == null || !weaponHandler.IsAttacking())
        {
            horizontal = Input.GetAxis(inputHorizontalAxis);
            vertical   = Input.GetAxis(inputVerticalAxis);
        }

        float horizontalMovement = 0.0f;
        float verticalMovement   = 0.0f;

        if (horizontal > 0.0f)
        {
            horizontalMovement = 1.0f;
        }
        else if (horizontal < 0.0f)
        {
            horizontalMovement = -1.0f;
        }

        if (vertical > 0.0f)
        {
            verticalMovement = 1.0f;
        }
        else if (vertical < 0.0f)
        {
            verticalMovement = -1.0f;
        }

        movementController.movementDirection = new Vector2(horizontalMovement, verticalMovement);

        if (facingHandler != null)
        {
            facingHandler.UpdateFacing();
        }
    }
 public bool IsAttacking()
 {
     return(currentWeapon.IsAttacking());
 }