Code has been updated to include logic for listening for Event: LevelManager event: onMiniGameOver
In this simple case, the event causes a scene-change to the EndScene. Logic in the EndState.cs script displays different content depending on whether GameData shows that Health is not less than or equal to 0.
using UnityEngine;using UnityEngine.UI;using UnityEngine.SceneManagement;using UnityEngine.Events;publicclassMiniGameState : IStateBase {Button btnOption1;LevelManager levelManager;/// <summary>/// The scene./// </summary>privateGameScene scene;/// <summary>/// Gets the scene number - enum/// </summary>/// <value>The scene.</value>publicGameSceneScene { get { return scene; } }/// <summary>/// Initializes a new instance of the <see cref="T:MiniGState"/> class./// </summary>publicMiniGState() { scene =GameScene.MiniGame; }publicvoidInitializeObjectRefs() { btnOption1 =GameObject.Find("ButtonOption1").GetComponent<Button>();btnOption1.onClick.AddListener(LoadEndScene); levelManager =Object.FindObjectOfType<LevelManager>();levelManager.onMiniGameOver.AddListener(LoadEndScene); }publicvoidLoadEndScene() {SceneManager.LoadScene("EndScene");StateManager.instanceRef.SwitchState(newEndState()); }} //end class