Esempio n. 1
0
 // Update is called once per frame
 void Update()
 {
     if (delay > 0)
     {
         delay -= Time.deltaTime;
     }
     else
     if (Mathf.Abs(gameManager.GetDragon().transform.position.x - transform.position.x) < triggerWidth ||
         (Mathf.Abs(gameManager.GetDragon().transform.position.z - transform.position.z) < triggerHeight && Mathf.Abs(gameManager.GetDragon().transform.position.x - transform.position.x) < 3))
     {
         GetComponent <Death>().Die();
     }
 }
Esempio n. 2
0
    void FixedUpdate()
    {
        if (preparation > 0)
        {
            preparation -= Time.fixedDeltaTime;
            if (preparation < 0)
            {
                Vector3 target = gameManager.GetDragon().transform.position;
                target.y  = transform.position.y;
                direction = (target - transform.position).normalized;
            }
            return;
        }
        if (fuel > 0)
        {
            velocity += direction * acceleration * Time.fixedDeltaTime;
            fuel     -= Time.fixedDeltaTime;
        }
        else
        {
            velocity += Vector3.back * Time.fixedDeltaTime * 2;
        }
        if (velocity.magnitude > maxSpeed)
        {
            velocity = velocity.normalized * maxSpeed;
        }
        transform.LookAt(transform.position + velocity * Time.deltaTime);
        transform.localRotation *= Quaternion.Euler(0, 90, 0);

        transform.position += velocity * Time.fixedDeltaTime;
    }
Esempio n. 3
0
 // Use this for initialization
 void Start()
 {
     speed       = new Vector3(0, 0, -0.3f);
     gameManager = GameObject.Find("GameManager").GetComponent <FlightGameManager>();
     direction   = Vector3.back;
     if (homing)
     {
         direction = -(transform.position - gameManager.GetDragon().transform.position).normalized;
     }
 }
Esempio n. 4
0
 protected Vector2 FindDragonPosition()
 {
     return(new Vector2(0.5f + gameManager.GetDragon().transform.position.x / (gameManager.worldBounds.extents.x * 2), 0.5f + gameManager.GetDragon().transform.position.z / (gameManager.worldBounds.extents.z * 2)));
 }