void ShowChapter() { btnLeft.SetActive(ConfigMng.Instance.GetChapterRefData(EndMng.CurChapterID - 1) != null); btnRigth.SetActive(ConfigMng.Instance.GetChapterRefData(EndMng.CurChapterID + 1) != null); ShowRestTime(); foreach (EndLessTrialsItemUI go in listEndItem) { go.gameObject.SetActive(false); } foreach (GameObject go in listLine) { go.SetActive(false); } ChapterRef dataList = ConfigMng.Instance.GetChapterRefData(EndMng.CurChapterID); if (dataList == null) { return; } CreateLine(); CreateItem(dataList); nameText.text = dataList.name; //totalStar.text = EndMng.GetTotalStar().ToString(); ConfigMng.Instance.GetBigUIIcon(dataList.icon, delegate(Texture2D texture){ if (textIcon != null) { textIcon.mainTexture = texture; } }); }
protected ChapterReward GetReward(ChapterRef _ChapterRef) { for (int i = 0, len = _ChapterRef.rewardData.Count; i < len; i++) { if (!GameCenter.endLessTrialsMng.GetStarReward(curChapterId, _ChapterRef.rewardData[i].starNum))//显示还没领取的 { return(_ChapterRef.rewardData[i]); } } return(null); }
public void LoadCustomChapters() { Debug.Log(TAG + "loading the user made chapters"); LevelManager.LevelCon[] folder = levelManager.GetCustomLevelFolder(); customChapters = new ChapterRef[folder.Length]; for (int i = 0; i < folder.Length; i++) { string chapterName = folder[i].GetFolderName(); int r = Random.Range(0, 3); customChapters[i] = new ChapterRef(chapterName, i.ToString(), r); } LoadChapters(customChapterCon, customScrollBox, customChapters, levelManager.GetCustomLevelFolder(), true, customLevelSelect); }
public void SetUp() { Debug.Log(TAG + "setting up."); Debug.Log(TAG + "creating the chapters."); normalChapters = new ChapterRef[10]; normalChapters[0] = new ChapterRef("Novas", "Chapter 1", 0); normalChapters[1] = new ChapterRef("Cubes and Diamonds", "Chapter 2", 1); normalChapters[2] = new ChapterRef("Tricky", "Chapter 3", 2); normalChapters[3] = new ChapterRef("Beams", "Chapter 4", 1); normalChapters[4] = new ChapterRef("Shapes", "Chapter 5", 0); normalChapters[5] = new ChapterRef("Tangeled", "Chapter 6", 2); normalChapters[6] = new ChapterRef("The Vortex", "Chapter 7", 1); normalChapters[7] = new ChapterRef("Twisted", "Chapter 8", 0); normalChapters[8] = new ChapterRef("The Great Pyramid", "Chapter 9", 1); normalChapters[9] = new ChapterRef("The Last One", "Chapter 10", 2); }
// Use this for initialization void Awake() { GameCenter.endLessTrialsMng.C2S_EndList(); mutualExclusion = true; Layer = GUIZLayer.TOPWINDOW; itemEty.SetActive(false); lineEty.SetActive(false); UIEventListener.Get(btnSweeping).onClick = delegate { if (!EndMng.IsSweepingEndless) { return; } GameCenter.endLessTrialsMng.C2S_SweepReward(2, 0); }; UIEventListener.Get(btnClose).onClick = delegate { GameCenter.uIMng.SwitchToUI(GUIType.NONE); }; UIEventListener.Get(btnLeft).onClick = delegate { if (ConfigMng.Instance.GetChapterRefData(EndMng.CurChapterID - 1) != null) { EndMng.CurChapterID--; } GameCenter.endLessTrialsMng.CountRedPoint(); }; UIEventListener.Get(btnRigth).onClick = delegate { ChapterRef refData = ConfigMng.Instance.GetChapterRefData(EndMng.CurChapterID + 1); if (refData != null && EndMng.GetItemDataCurFront(refData.allLevels[0])) { EndMng.CurChapterID++; } else { GameCenter.messageMng.AddClientMsg(179); } GameCenter.endLessTrialsMng.CountRedPoint(); }; curChapterId = EndMng.CurChapterID; if (resetBtn != null) { UIEventListener.Get(resetBtn.gameObject).onClick = ClickResetBtn; } }
protected override void OnClose() { base.OnClose(); EndMng.OnCurChapterUpdate -= ShowChapter; EndMng.OnRestRefreshTimeUpdate -= ShowRestTime; EndMng.OnCurChapterStarUpdate -= ShowBoxReward; //for(int i=0,len=stars.Length;i<len;i++){ // UIEventListener.Get(stars[i].gameObject).onClick -= OnClickStars; //} if (textIcon != null) { textIcon.mainTexture = null; } ChapterRef dataList = ConfigMng.Instance.GetChapterRefData(EndMng.CurChapterID); ConfigMng.Instance.RemoveBigUIIcon(dataList.icon); GameCenter.endLessTrialsMng.CountRedPoint(); }
void CreateItem(ChapterRef dataList) { CheckPointRef refData = null; int i = 0, len = 0; GameObject go = null; EndLessTrialsItemUI endLess = null; for (i = 0, len = dataList.allLevels.Count; i < len; i++) { refData = ConfigMng.Instance.GetCheckPointRef(dataList.allLevels[i]); if (refData == null) { continue; } if (listEndItem.Count <= i) { go = (GameObject)GameObject.Instantiate(itemEty); go.transform.parent = lineEty.transform.parent; go.transform.localPosition = new Vector3(refData.coordinate.x, refData.coordinate.y, -1f); go.transform.localScale = Vector3.one; go.name = "EndLessTrialsItem" + refData.id; endLess = go.GetComponent <EndLessTrialsItemUI>(); endLess.SetEndItem(refData); UIEventListener.Get(go).onClick = OnClickEndItem; UIEventListener.Get(go).parameter = refData; listEndItem.Add(endLess); go.SetActive(true); } else { listEndItem[i].gameObject.name = "EndLessTrialsItem" + refData.id; listEndItem[i].SetEndItem(refData); listEndItem[i].transform.localPosition = new Vector3(refData.coordinate.x, refData.coordinate.y, -1f); UIEventListener.Get(listEndItem[i].gameObject).onClick = OnClickEndItem; UIEventListener.Get(listEndItem[i].gameObject).parameter = refData; listEndItem[i].gameObject.SetActive(true); } } }
void ShowBoxReward() { ChapterReward chapterReward = null; curChapterId = 1; ChapterRef ChapterRef = ConfigMng.Instance.GetChapterRefData(curChapterId); chapterReward = GetReward(ChapterRef); while (isGetReward(ChapterRef) && curChapterId < ConfigMng.Instance.GetChapterRefTable().Count) { ++curChapterId; ChapterRef = ConfigMng.Instance.GetChapterRefData(curChapterId); chapterReward = GetReward(ChapterRef); } if (stars != null) { if (chapterReward != null) { stars.gameObject.SetActive(true); stars.SetStar(chapterReward, curChapterId); if (stars != null) { UIEventListener.Get(stars.gameObject).onClick -= OnClickStars; UIEventListener.Get(stars.gameObject).onClick += OnClickStars; UIEventListener.Get(stars.gameObject).parameter = chapterReward; } } else { stars.gameObject.SetActive(false); } } //ChapterRef dataList = ConfigMng.Instance.GetChapterRefData(EndMng.CurChapterID); //if (dataList == null) return; //bool isGetAll = true; //for (int i = 0, len = dataList.rewardData.Count; i < len; i++) //{ // if (!GameCenter.endLessTrialsMng.GetStarReward(GameCenter.endLessTrialsMng.CurChapterID, dataList.rewardData[i].starNum))//显示还没领取的 // { // if (stars != null) // { // stars.gameObject.SetActive(true); // stars.SetStar(dataList.rewardData[i]); // if (stars != null) // { // UIEventListener.Get(stars.gameObject).onClick -= OnClickStars; // UIEventListener.Get(stars.gameObject).onClick += OnClickStars; // UIEventListener.Get(stars.gameObject).parameter = dataList.rewardData[i]; // } // } // isGetAll = false; // break; // } //} //if (isGetAll) //{ // if (stars != null) stars.gameObject.SetActive(false); //} }
public void LoadChapters(RectTransform container, RectTransform box, ChapterRef[] chapters, LevelManager.LevelCon[] levelConFolder, bool isCustom, RectTransform menu) { Debug.Log(TAG + "setting container size."); int numToLoad = chapters.Length; if (menuManager.GetIsDemo() && !isCustom) { numToLoad = 3; } chapterButtons = new Chapter[numToLoad]; float screenWidth = menu.rect.width; float padL, chapterConWidth; padL = screenWidth * 0.15f; //15%of screen size chapterConWidth = screenWidth * 0.6f; //70% screen size Debug.Log(TAG + "loading chapters."); float x1, x2, y1, y2; float chapterWidth, chapterHeight; chapterWidth = chapterConWidth; chapterHeight = 100; x1 = 0; y1 = -chapterHeight; x2 = x1 + chapterWidth; y2 = y1 + chapterHeight; for (int i = 0; i < numToLoad; i++) { GameObject g = Instantiate(chapterPrefab); g.transform.SetParent(container.transform); RectTransform r = g.GetComponent <RectTransform>(); r.offsetMin = new Vector2(x1, y1); r.offsetMax = new Vector2(x2, y2); Chapter chapter = g.GetComponent <Chapter>(); //------------ //y1 += chapter.SetUp(chapterWidth,levelManager.GetLevels(i),i,menuManager); y1 += chapter.SetUp(chapterWidth, levelConFolder[i].GetLevels(), i, menuManager, isCustom); y2 = y1 + chapterHeight; ChapterRef c = chapters[i]; chapter.SetName(i + 1, c.GetName(), 20.0f); chapterButtons[i] = chapter; } y1 = CheckDemoInfo(y1, isCustom, chapterWidth, container); container.offsetMin = new Vector2(padL, y1); container.offsetMax = new Vector2(padL + chapterConWidth, 0); box.offsetMin = new Vector2(0, y1); box.offsetMax = new Vector2(600, 0); }