Skip to content

Commit

Permalink
Fixed graph not disappearing on campaign levels
Browse files Browse the repository at this point in the history
  • Loading branch information
MCJack123 committed Jan 6, 2021
1 parent baf6868 commit 78dec42
Showing 1 changed file with 26 additions and 10 deletions.
36 changes: 26 additions & 10 deletions PerformanceMeterController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public class PerformanceMeterController : MonoBehaviour {
ScoreController scoreController;
GameEnergyCounter energyCounter;
RelativeScoreAndImmediateRankCounter rankCounter;
ResultsViewController resultsController;
GameObject panel;
ILevelEndActions endActions;
bool levelOk = false;
Expand Down Expand Up @@ -85,23 +84,36 @@ public void ShowResults() {
#region Monobehaviour Messages
IEnumerator WaitForMenu() {
bool loaded = false;
while (!loaded) {
if (resultsController == null) resultsController = Resources.FindObjectsOfTypeAll<ResultsViewController>().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<ResultsViewController>().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<MissionResultsViewController>().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");
}

void DismissGraph(ResultsViewController vc) {
if (panel != null) {
Destroy(panel);
panel = null;
resultsController = null;
scoreController = null;
energyCounter = null;
rankCounter = null;
Expand All @@ -111,6 +123,10 @@ void DismissGraph(ResultsViewController vc) {
}
}

void DismissGraph_Mission(MissionResultsViewController vc) {
DismissGraph(null);
}

public void GetControllers() {
averageHitValue = 0.0f;
averageHitValueSize = 0;
Expand Down

0 comments on commit 78dec42

Please sign in to comment.