Пример #1
0
        private void HandleAsteroidExplosionEnded(AsteroidExplosion explosion)
        {
            // Now the explosion has finished unsubscribe from the event.
            explosion.OnExplosionEnded -= HandleAsteroidExplosionEnded;

            // Return the explosion to its object pool.
            m_AsteroidExplosionObjectPool.ReturnGameObjectToPool(explosion.gameObject);
        }
Пример #2
0
        private void HandleAsteroidHit(Asteroid asteroid)
        {
            // Remove the asteroid when it's hit.
            HandleAsteroidRemoval(asteroid);

            // Get an explosion from the object pool and put it at the asteroids position.
            GameObject explosion = m_AsteroidExplosionObjectPool.GetGameObjectFromPool();

            explosion.transform.position = asteroid.transform.position;

            // Get the asteroid explosion component and restart it.
            AsteroidExplosion asteroidExplosion = explosion.GetComponent <AsteroidExplosion>();

            asteroidExplosion.Restart();

            // Subscribe to the asteroid explosion's event.
            asteroidExplosion.OnExplosionEnded += HandleAsteroidExplosionEnded;
        }
Пример #3
0
        private void HandleExplosionEnded(AsteroidExplosion explosion)
        {
            // Now the explosion has finished unsubscribe from the event.
            explosion.OnExplosionEnded -= HandleExplosionEnded;

            // Return the explosion to its object pool.
            m_AsteroidExplosionObjectPool.ReturnGameObjectToPool (explosion.gameObject);
        }