/// <summary> /// Called to notify end minigame with result (pushed continue button on UI). /// </summary> /// <param name="_stars">The stars.</param> public void EndMinigame(int _stars) { if (TeacherAI.I.CurrentMiniGame == null) { return; } EndsessionResultData res = new EndsessionResultData(_stars, TeacherAI.I.CurrentMiniGame.GetIconResourcePath(), TeacherAI.I.CurrentMiniGame.GetBadgeIconResourcePath()); EndSessionResults.Add(res); }
internal void Show(List <EndsessionResultData> _sessionData) { int totGames = _sessionData.Count; // Fill + Reset/set foreach (EndsessionMinigame minigame in minigames) { minigame.Reset(); } while (minigames.Count < totGames) { EndsessionMinigame mg = Instantiate(MinigamePrefab); mg.GetComponent <RectTransform>().SetParent(MinigamePrefab.transform.parent, false); mg.gameObject.SetActive(true); minigames.Add(mg); } for (int i = 0; i < minigames.Count; ++i) { EndsessionMinigame mg = minigames[i]; if (i < totGames) { EndsessionResultData data = _sessionData[i]; mg.gameObject.SetActive(i < totGames); mg.SetIcon(Resources.Load <Sprite>(data.MinigameIconResourcesPath)); mg.SetStars(data.Stars); } else { mg.gameObject.SetActive(false); } } // Tween showTween.PlayForward(); minigamesTween = DOTween.Sequence(); for (int i = 0; i < totGames; ++i) { EndsessionMinigame mg = minigames[i]; float startPos = i * 0.1f; minigamesTween.InsertCallback(startPos, () => AudioManager.I.PlaySfx(EndsessionResultPanel.I.SfxMinigamePopup)) .Join(mg.Bubble.DOScale(0.0001f, 0.35f).From().SetEase(Ease.OutBack)); int starsLen = mg.Stars.Length; for (int c = 0; c < starsLen; ++c) { Image star = mg.Stars[c]; minigamesTween.Insert(startPos + 0.2f + (starsLen - c - 1) * 0.1f, star.GetComponent <RectTransform>().DOAnchorPosX(0, 0.45f).From().SetEase(Ease.OutBack)); minigamesTween.Join(star.DOFade(0, 0.35f).From().SetEase(Ease.Linear)); } } }