private IEnumerator <float> C_ShowUnlockedSongs(float delay) { //record current number of stars int oldStar = HighScoreManager.Instance.TotalStars; //wait 1 frame to collect new star record as other actions are going on yield return(1); int newStar = HighScoreManager.Instance.TotalStars; if (isNavigatingAway) { yield break; } //check for newly unlocked songs with star required falls between oldStar and newStar if (oldStar < newStar) { //list of newly unlocked songs List <SongDataModel> unlockedSongs = new List <SongDataModel>(5); var allsongs = GameManager.Instance.StoreData.listAllSongs; for (int i = 0; i < allsongs.Count; i++) { if ((allsongs[i].starsToUnlock > oldStar) && (allsongs[i].starsToUnlock <= newStar)) { if (!IsBought(allsongs[i].storeID)) { unlockedSongs.Add(allsongs[i]); } } } //prepare to open unlocked scene NewlyUnlockedSongModel songs = new NewlyUnlockedSongModel(); songs.newlyUnlockedSongs = unlockedSongs; if (unlockedSongs.Count >= 1) { hasNewSongsUnlocked = true; GameManager.Instance.SessionData.needAttentionSongList = true; yield return(Timing.WaitForSeconds(delay)); AchievementHelper.Instance.LogAchievement("numSongPlayed", unlockedSongs.Count); //call open unlocked scene SceneManager.Instance.OpenPopup(ProjectConstants.Scenes.SongUnlockedPopup, songs); } } }
public override void OnSet(object data) { newSongs = (NewlyUnlockedSongModel)data; ShouldProcessSongItemClick = true; if (newSongs == null) { Debug.LogWarning("Trying to show new unlocked songs without any data. Closing scene"); SceneManager.Instance.CloseScene(); return; } songsGrid.enabled = false; contentTween.cachedTransform.localPosition = Vector3.zero; //hide all song item views before showing animation for (int i = 0; i < listSongItems.Count; i++) { listSongItems[i].gameObject.SetActive(false); listSongItems[i].transform.localPosition = new Vector3(0, -800 - 400 * i); } Timing.RunCoroutine(ShowNewlyUnlockedSongs()); buttonClose.SetActive(false); }