Exemple #1
0
        private void HandleSharkExplosionEnded(SharkExplosion explosion)
        {
            // Now the explosion has finished unsubscribe from the event.
            explosion.OnExplosionEnded -= HandleSharkExplosionEnded;

            // Return the explosion to its object pool.
            m_SharkExplosionObjectPool.ReturnGameObjectToPool(explosion.gameObject);
        }
Exemple #2
0
        private void HandleSharkHit(Shark shark)
        {
            // Remove the asteroid when it's hit.
            HandleSharkRemoval(shark);

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

            explosion.transform.position = shark.transform.position;

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

            sharkExplosion.Restart();

            // Subscribe to the asteroid explosion's event.
            sharkExplosion.OnExplosionEnded += HandleSharkExplosionEnded;
        }