示例#1
0
        private void HandleOpponentExplosionEnded(ObstacleExplosion explosion)
        {
            // Now the explosion has finished unsubscribe from the event.
            explosion.OnExplosionEnded -= HandleOpponentExplosionEnded;

            // Return the explosion to its object pool.
            m_OpponentExplosionObjectPool.ReturnGameObjectToPool(explosion.gameObject);
        }
示例#2
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;
        }
示例#3
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;
        }