private void HandleMystExplosionEnded(MystExplosion explosion) { // Now the explosion has finished unsubscribe from the event. explosion.OnExplosionEnded -= HandleMystExplosionEnded; // Return the explosion to its object pool. m_MystExplosionObjectPool.ReturnGameObjectToPool(explosion.gameObject); }
private void HandleMystHit(Myst myst) { // Remove the pearl when it's hit. HandleMystRemoval(myst); // Get an explosion from the object pool and put it at the asteroids position. GameObject explosion = m_MystExplosionObjectPool.GetGameObjectFromPool(); explosion.transform.position = myst.transform.position; // Get the pearl explosion component and restart it. MystExplosion mystExplosion = explosion.GetComponent <MystExplosion>(); mystExplosion.Restart(); // Subscribe to the asteroid explosion's event. mystExplosion.OnExplosionEnded += HandleMystExplosionEnded; }