diff --git a/PerformanceMeterController.cs b/PerformanceMeterController.cs index 002d95a..45941e6 100644 --- a/PerformanceMeterController.cs +++ b/PerformanceMeterController.cs @@ -28,7 +28,6 @@ public class PerformanceMeterController : MonoBehaviour { ScoreController scoreController; GameEnergyCounter energyCounter; RelativeScoreAndImmediateRankCounter rankCounter; - ResultsViewController resultsController; GameObject panel; ILevelEndActions endActions; bool levelOk = false; @@ -85,15 +84,29 @@ public void ShowResults() { #region Monobehaviour Messages IEnumerator WaitForMenu() { bool loaded = false; - while (!loaded) { - if (resultsController == null) resultsController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); - if (resultsController != null) loaded = true; - else yield return new WaitForSeconds(0.1f); + if (endActions is StandardLevelGameplayManager) { + ResultsViewController resultsController = null; + while (!loaded) { + if (resultsController == null) resultsController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (resultsController != null) loaded = true; + else yield return new WaitForSeconds(0.1f); + } + + yield return new WaitForSeconds(0.1f); + resultsController.continueButtonPressedEvent += DismissGraph; + resultsController.restartButtonPressedEvent += DismissGraph; + } else { + MissionResultsViewController resultsController = null; + while (!loaded) { + if (resultsController == null) resultsController = Resources.FindObjectsOfTypeAll().FirstOrDefault(); + if (resultsController != null) loaded = true; + else yield return new WaitForSeconds(0.1f); + } + + yield return new WaitForSeconds(0.1f); + resultsController.continueButtonPressedEvent += DismissGraph_Mission; + resultsController.retryButtonPressedEvent += DismissGraph_Mission; } - - yield return new WaitForSeconds(0.1f); - resultsController.continueButtonPressedEvent += DismissGraph; - resultsController.restartButtonPressedEvent += DismissGraph; Logger.log.Debug("PerformanceMeter menu created successfully"); } @@ -101,7 +114,6 @@ void DismissGraph(ResultsViewController vc) { if (panel != null) { Destroy(panel); panel = null; - resultsController = null; scoreController = null; energyCounter = null; rankCounter = null; @@ -111,6 +123,10 @@ void DismissGraph(ResultsViewController vc) { } } + void DismissGraph_Mission(MissionResultsViewController vc) { + DismissGraph(null); + } + public void GetControllers() { averageHitValue = 0.0f; averageHitValueSize = 0;