Exemple #1
0
        private void HandleOpponentHit(Opponent opponent)
        {
            // Remove the opponent when it's hit.
            HandleOpponentRemoval(opponent);

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

            explosion.transform.position = opponent.transform.position;

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

            obstacleExplosion.Restart();

            // Subscribe to the asteroid explosion's event.
            obstacleExplosion.OnExplosionEnded += HandleOpponentExplosionEnded;
        }
Exemple #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.
            ObstacleExplosion asteroidExplosion = explosion.GetComponent <ObstacleExplosion>();

            asteroidExplosion.Restart();

            // Subscribe to the asteroid explosion's event.
            asteroidExplosion.OnExplosionEnded += HandleAsteroidExplosionEnded;
        }