public virtual void PostUpdate(float deltaTime)
 {
     if (!Brain.main.PointInArea(transform.position))
     {
         BulletManager.DestroyBullet(this);
     }
 }
 public override void PostUpdate(float deltaTime)
 {
     if (Vector3.Distance(transform.localPosition, source) >= 9f)
     {
         BulletManager.DestroyBullet(this);
     }
 }
Exemplo n.º 3
0
 //удаление снаряда-пули
 private void DeleteBollet()
 {
     if (Explosive)
     {
         GameObject go = BulletManager.CreateBoomEffect();
         if (go == null)
         {
             go = Instantiate(Boom_effect);
         }
         go.transform.position = transform.position;
         go.SetActive(true);
         go.GetComponent <ParticleSystem>().Play();
     }
     BulletManager.DestroyBullet(_type, this.transform.gameObject);
 }
Exemplo n.º 4
0
    /// <summary>
    /// Handles collisions between asteroids and the players bullets.
    /// </summary>
    public void CollideAsteroidsBullets()
    {
        //get the asteroids and the players bullets
        List <GameObject> asteroids = asteroidManager.AsteroidsList;
        List <GameObject> bullets   = bulletManager.BulletsList;

        //loop through the asteroids
        for (int i = asteroids.Count - 1; i >= 0; i--)
        {
            //get the asteroids collision circle then loop through the bullets
            CollisionCircle curr = asteroids [i].GetComponent <CollisionCircle> ();
            for (int j = bullets.Count - 1; j >= 0; j--)
            {
                //check for collision
                if (curr.TestCollisionCircle(bullets[j].GetComponent <CollisionCircle>()))
                {
                    //if there is a collision destroy both the asteroid and the bullet then and stop looping through bullets
                    asteroidManager.DestroyAsteroid(asteroids[i]);
                    bulletManager.DestroyBullet(j);
                    j = -1;
                }
            }
        }
    }