Hi all,
I need some help if possible… i have the code above and every time you play the game will win stars, so if you play level 1 for instance and win 2 stars this will be posted on the menu and show you that you got 2 stars for level 1. But if you play again the level 1 and you get 1 star, that will update and will show you on menu that level 1 have 1 star… is it possible to update only if the stars you get are bigger then the previous one ?
Here is the code that does the trick for the stars !
public void GameOver(int starCount)
{
if (starCount > 0)
{
levelStatusText.text = "Level " + (LevelSystemManager.Instance.CurrentLevel + 1) + " Complete";
LevelSystemManager.Instance.LevelComplete(starCount);
}
else
{
levelStatusText.text = "Level " + (LevelSystemManager.Instance.CurrentLevel + 1) + " Failed";
}
SetStar(starCount);
}
public void LevelComplete(int starAchieved)
{
levelData.levelItemArray[currentLevel].starAchieved = starAchieved;
if (levelData.lastUnlockedLevel < (currentLevel + 1))
{
levelData.lastUnlockedLevel = currentLevel + 1;
levelData.levelItemArray[levelData.lastUnlockedLevel].unlocked = true;
}
}
/// <param name="starAchieved"></param>
private void SetStar(int starAchieved)
{
for (int i = 0; i < starsArray.Length; i++)
{
if (i < starAchieved)
{
starsArray[i].color = unlockColor;
}
else
{
starsArray[i].color = lockColor;
}
}
}