protected override void UpdateDirection()
    {
        Vector3 dir = (Vector2)(player.transform.position - transform.position);

        dir        = MyUtility.GetAxisOriented(dir);
        dir        = (player.transform.position + dir * MinPlayerDistance) - transform.position;
        direction += (Vector2)dir;
        direction.Normalize();
    }
Beispiel #2
0
    private void Shoot()
    {
        GameObject o = Instantiate(Arrow);

        o.transform.position = transform.position;
        ArrowBehaviour arr = o.GetComponent <ArrowBehaviour>();
        Vector2        dir = MyUtility.GetAxisOriented(PlayerController.get().transform.position - transform.position);

        arr.Shoot(controller, dir.normalized, ArrowSpeed);
    }
    protected override bool UpdateMovementInput()
    {
        Vector2 dist = transform.position - player.transform.position;

        dist            -= PlayerHeight * Vector2.up;
        distanceToPlayer = dist.magnitude;
        if (distanceToPlayer < MaxPlayerDistance)
        {
            Vector2 dir = MyUtility.GetAxisOriented(dist);
            direction  = player.transform.position + PreferredDistance * (Vector3)dir - transform.position;
            direction += PlayerHeight * Vector2.up;
            if (direction.magnitude > MinPlayerDistance)
            {
                direction.Normalize();
                preferedPos = false;
                return(true);
            }
            preferedPos = true;
        }

        return(false);
    }