Hi all,
In my game a scorepanel will pop-up after dying. When a highscore is made, I’m trying to show another highscore panel instead of the standard scorepanel. The problem is that it works correctly but sometimes when a highscore is made, the standard scorepanel will pop-up as well. So both panels will pop-up after a highscore. Not everytime, but most of the times. I can’t seem to figure out what is wrong in my code.
Is there anybody that may have a suggestion to find the problem?
Below is the if statement code for the panels to show after dying.
public void GameOverShowpanel ()
{
// shows the standard score panel after dying
if (ScoreManager.instance.GetPrevHighScore () >= ScoreManager.instance.GetScore ()) {
Debug.Log(" PrevHighScore was: " + ScoreManager.instance.GetPrevHighScore() + ", Score now is : " + ScoreManager.instance.GetScore());
gameOverAnim = gameOverpanel.GetComponent<Animator> ();
scoreText.SetActive (false);
scoreTextCoin.SetActive (false);
imageCoinOnGame.SetActive (false);
powerBar.SetActive (false);
gameOverpanel.SetActive (true);
gameOverAnim.Play ("FadeIn");
finalScore.text = "Score: " + "" + ScoreManager.instance.GetScore ();
finalHighScore.text = "High Score: " + "" + ScoreManager.instance.GetHighScore ();
finalCoinScore.text = "" + ScoreManager.instance.GetCoinScore();
// Shows the High Score Panel if a High Score is made
} else if (ScoreManager.instance.GetPrevHighScore () < ScoreManager.instance.GetScore ()) {
Debug.Log(" PrevHighScore was: " + ScoreManager.instance.GetPrevHighScore() + ", Score now is : " + ScoreManager.instance.GetScore());
scoreText.SetActive (false);
newHighPanel.SetActive (true);
newHighAnim = newHighPanel.GetComponent<Animator> ();
newHighAnim.Play ("PanelHolderTransparentAnim");
audio2.PlayOneShot (partyHornAU, 0.8f);
StartCoroutine (PartyParticles ());
newHighTextOnPanel.text = "" + ScoreManager.instance.GetHighScore ();
ScoreManager.instance.UpdatePrev();
}
}