public void LevelComplete() { string levelTime = levelTimer.SendEndTime(); string bestTime = levelManager.completedLevelList[levelNumber - 1].bestTime; int bestTimeint; int levelTimeint; int.TryParse(levelTime, out levelTimeint); int.TryParse(bestTime, out bestTimeint); if (levelTimeint <= bestTimeint) { levelManager.completedLevelList[levelNumber - 1].bestTime = levelTime; levelManager.SaveProgress(); } foreach (CompletedLevels level in levelManager.completedLevelList) { if (level.levelUnlocked == levelNumber + 1) { levelManager.GoToLevelSelect(); return; } } levelManager.completedLevelList.Add(new CompletedLevels { levelUnlocked = levelNumber + 1, bestTime = "99999999" }); levelManager.SaveProgress(); levelManager.GoToLevelSelect(); }