Example #1
0
 public static void pointScored(int scoreBonus)
 {
     if (eGameState == GameState.Playing)
     {
         playerScore += 5 * scoreBonus;
         AsteroidDestroyedEvent?.Invoke();
     }
 }
Example #2
0
    protected void OnCollisionEnter2D(Collision2D col)
    {
        // make those who are listening aware that we have been destroyed
        if (AsteroidDestroyedEvent != null)
        {
            AsteroidDestroyedEvent.Invoke(this, transform.position);
        }

        // play the asteroids death sound
        audioSource.PlayOneShot(deathSound);

        // hide the asteroid and disable the collider so it appears as if the asteroid has exploded
        asteroidRenderer.enabled = false;
        asteroidCollider.enabled = false;

        // create our deathParticles particles then destroy the gameobject after the death sound has finished
        Instantiate(deathParticles, col.transform.position, transform.rotation);
        Destroy(gameObject, deathSound.length);
    }
Example #3
0
 public static void PublishAsteroidDestroyedEvent(int asteroidId, Vector2 position, int size)
 {
     AsteroidDestroyedEvent?.Invoke(asteroidId, position, size);
 }