Ejemplo n.º 1
0
    private void DistanceAttack()
    {
        Vector3 aim = new Vector3(InputManager.Instance.GetHorizontal(), InputManager.Instance.GetVertical(), 0f);

        if (aim.magnitude > 0f && InputManager.Instance.GetDistanceAttack() ||
            aim.magnitude == 0 && InputManager.Instance.GetDistanceAttack())
        {
            Stop();

            GameObject arrow = Instantiate(projectile, transform.position, Quaternion.identity);

            Vector2 shootingDirection = GetShootingDirection(aim);
            shootingDirection.Normalize();

            arrow.GetComponent <Projectile>().Init(shootingDirection, gameObject, inventory.GetSwordBonus());
            arrow.transform.Rotate(0f, 0f, Mathf.Atan2(shootingDirection.y, shootingDirection.x) * Mathf.Rad2Deg + 90f);
        }
    }