void OnLvlLoaded(Lvl _, int index) { numberOfLvlScore = 0; currentLvlIndex = index; var highScore = currentLvlIndex >= allScores.scoreList.Count ? 10 : allScores.scoreList[currentLvlIndex]; OnLoadScore.Invoke(currentLvlIndex, highScore); if (allScores.scoreList.Count >= currentLvlIndex + 1) { OnBestScoreLoaded.Invoke(allScores.scoreList[currentLvlIndex]); } else { OnBestScoreLoaded.Invoke(1000); } }
void UpdateHighScore(bool isBot, bool scoreLimit) { if (!isBot && !scoreLimit) { if (allScores.scoreList.Count > currentLvlIndex) { if (allScores.scoreList[currentLvlIndex] > numberOfLvlScore) { allScores.scoreList[currentLvlIndex] = numberOfLvlScore; } } else { allScores.scoreList.Add(numberOfLvlScore); } OnBestScoreLoaded.Invoke(allScores.scoreList[currentLvlIndex]); allScores.SaveScore(); } }