/// <summary> /// 生成时初始化课程 /// </summary> /// <param name="titile">标题</param> /// <param name="subtitle">子标题</param> /// <param name="progress">当前进度</param> public void Construct(string titile, string subtitle, int progress) { _progressRing = GetComponentInChildren <ProgressRing>(); transform.GetChild(0).GetComponent <Text>().text = titile; transform.GetChild(1).GetComponent <Text>().text = subtitle; _progressRing.SetProgress(progress); }
public override void OnShowing(object data) { // Set the progress rings percentage to the number of completed levels from all categories int totalNumberOfLevels = 0; int totalNumberOfCompletedLevels = 0; for (int i = 0; i < GameManager.Instance.CategoryInfos.Count; i++) { CategoryInfo categoryInfo = GameManager.Instance.CategoryInfos[i]; // Only include levels that are not part of the paily puzzle category if (categoryInfo.name != GameManager.dailyPuzzleId) { totalNumberOfLevels += categoryInfo.levelInfos.Count; totalNumberOfCompletedLevels += GameManager.Instance.GetCompletedLevelCount(categoryInfo); } } progressRing.SetProgress((float)totalNumberOfCompletedLevels / (float)totalNumberOfLevels); // Set the Continue button to the active category if (string.IsNullOrEmpty(GameManager.Instance.ActiveCategory) || GameManager.Instance.ActiveCategory == GameManager.dailyPuzzleId) { bool foundUncompletedLevel = false; for (int i = 0; i < GameManager.Instance.CategoryInfos.Count; i++) { CategoryInfo categoryInfo = GameManager.Instance.CategoryInfos[i]; if (categoryInfo.name == GameManager.dailyPuzzleId) { continue; } for (int j = 0; j < categoryInfo.levelInfos.Count; j++) { if (!GameManager.Instance.IsLevelCompleted(categoryInfo, j)) { continueBtnCategory = categoryInfo.name; continueBtnLevelIndex = j; foundUncompletedLevel = true; break; } } if (foundUncompletedLevel) { break; } } // If all levels are completed then set the button to the first category and first level if (!foundUncompletedLevel) { continueBtnCategory = GameManager.Instance.CategoryInfos[0].name; continueBtnLevelIndex = 0; } continueBtnTopText.text = "PLAY"; continueBtnBottomText.text = string.Format("{0} LEVEL {1}", continueBtnCategory.ToUpper(), continueBtnLevelIndex + 1); continueBtnImage.sprite = GameManager.Instance.GetCategoryInfo(continueBtnCategory).icon; } else { continueBtnCategory = GameManager.Instance.ActiveCategory; continueBtnLevelIndex = GameManager.Instance.ActiveLevelIndex; continueBtnTopText.text = "CONTINUE"; continueBtnBottomText.text = string.Format("{0} LEVEL {1}", continueBtnCategory.ToUpper(), continueBtnLevelIndex + 1); continueBtnImage.sprite = GameManager.Instance.GetCategoryInfo(continueBtnCategory).icon; } }