Exemple #1
0
 public new void Fly()
 {
     if (first)
     {
         first = false;
         TargetFinding tf        = new TargetFinding();
         Vector2       direction = Vector2.zero;
         if (tf.FindSpecialTarget(ref direction, target, transform.position))
         {
             Rigidbody.MovePosition(direction.normalized * MovementSpeed * Time.fixedDeltaTime * AttRange);
         }
         else
         {
             Destroy(gameObject);
         }
     }
     else if (lifeTime > 0)
     {
         Destroy(gameObject);
     }
 }
Exemple #2
0
    public void Fly()
    {
        if (lifeTime > 0)
        {
            if (cd >= targetCooldown)
            {
                TargetFinding tf        = new TargetFinding();
                Vector2       direction = oldDirection;
                if (tf.FindSpecialTarget(ref direction, target, transform.position))
                {
                    direction    = direction.normalized * MovementSpeed * Time.fixedDeltaTime;
                    oldDirection = direction;
                }

                cd = 0;
            }
            else
            {
                cd += Time.fixedDeltaTime;
            }

            Debug.DrawRay(transform.position, oldDirection, Color.cyan, 1);
            if (((Vector2)transform.position + oldDirection).magnitude < 10000)
            {
                Rigidbody.MovePosition((Vector2)transform.position + oldDirection);
            }
            else
            {
                Destroy(gameObject);
            }
            lifeTime -= Time.fixedDeltaTime;
        }
        else
        {
            Destroy(gameObject);
        }
    }