title: Switch case vs. Events: On game state update (UNITY, C#)
body: <p>Let's say that I have a <em>Unity</em> game with multiple managers <code>(Game, GUI, Sounds, Camera, Inputs, Terrain, ...)</code> instantiated through the <em>Singleton pattern</em>.</p>
  
  <p>When the <em>GameManager</em> calls (or gets called) to change the game state <code>(Intro, Tutorial, Gameplay, ...)</code>, should it informs other managers of the new game state through <strong>events</strong> or rather handle it and perform specific action on each manager within a <strong>switch case</strong>?</p>
  
  <p>Using <em>switch case</em>:</p>
  
  <pre><code>public static GameState currentGameState;
  public static GameState previousGameState;
  
  public void ChangeGameState(GameState newGameState)
  {
      switch(state)
      {
      case GameState.Intro:
      //do stuff
      break;
  
      case GameState.Tutorial:
      //do stuff
      break;
  
      case GameState.Gameplay:
      //do stuff
      break;
  
      //and so on
  
      }
  
      previousGameState = currentGameState;
      currentGameState = newGameState;
  }
  </code></pre>
  
  <p>Or using <em>events</em>:</p>
  
  <pre><code>public static GameState currentGameState;
  public static GameState previousGameState;
  
  public delegate void GameStateChanged(GameState prev, GameState curr, GameState new);
  public static event GameStateChanged OnGameStateChanged;
  
  public void ChangeGameState(GameState newGameState)
  {
      OnGameStateChanged(previousGameState, currentGameState, newGameState);
  
      previousGameState = currentGameState;
      currentGameState = newGameState;
  }
  </code></pre>
  
  <p>Which is the best practice/maintainable pattern here?</p>