/// <summary> /// 通关章节 /// </summary> /// <param name="id">通关的章节id</param> public void PassChpter(int id) { if (id <= this.passChapterID) { return; } CSClearance cSClearance = new CSClearance() { SectionId = id }; //bool receive = false;等待返回 ProtocalManager.Instance().SendCSClearance(cSClearance, (x) => { this.passChapterID = id; ChapterHelper.PassChapter(this.passChapterID); foreach (var item in chapterItems) { if (item.GetItemID() == this.passChapterID) { item.SetWatchOver(true);//当前章节看完 } if (item.GetItemID() == this.passChapterID + 1) { item.SetBeforeWatchOver(true);//下一章的前一章标记看完 } } }, (ErrorInfo e) => { Debug.Log("请求过关章节失败"); }); }
/// <summary> /// 请求通关章节 /// </summary> public void RequestPassChapter() { if (StaticData.playerInfoData.userInfo.SectionId >= this._ChapterIndex) { Debug.Log("之前已读过该章节"); return; } //请求读完当前章节 CSClearance cSClearance = new CSClearance() { SectionId = this._ChapterIndex }; ProtocalManager.Instance().SendCSClearance(cSClearance, (SCEmptyClearance empty) => { ChapterHelper.PassChapter(this._ChapterIndex); RedDotManager.UpdateRedDot(RedDotManager.RedDotKey.Chapter); }, (ErrorInfo e) => { Debug.Log("请求过关章节失败"); }); }
/// <summary> /// 点击进入下一章章节按钮 /// </summary> public void OnClickNextChapterBtn(Button btn) { if (ChapterHelper.NextChapterIsUnlock(curChapterID)) {//进入下一章 btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => {//请求读完章节 CSClearance cSClearance = new CSClearance() { SectionId = curChapterID }; ProtocalManager.Instance().SendCSClearance(cSClearance, (x) => { ChapterHelper.PassChapter(curChapterID); //打开下一个章节 ChapterHelper.EnterIntoChapter(curChapterID + 1); Destroy(gameObject);//销毁自身 }, (ErrorInfo e) => { Debug.Log("请求过关章节失败"); }); }); } else {//打开解锁页面 btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(async() => { var chapterInfo = StaticData.configExcel.GetSectionBySectionId(curChapterID + 1); int id = chapterInfo.UnlockPrice[0].ID; //取到钻石图片的id int count = (int)chapterInfo.UnlockPrice[0].Count; //取到数量 Sprite sprite = await ZillionaireToolManager.LoadItemSprite(id); string str = $"你的等级不够解锁下一章了哦"; StaticData.OpenCommonBuyTips(str, sprite, count, () => { ClickCallBACK((count), () => {//购买成功扣掉钻石后直接进入下一章节 ChapterHelper.EnterIntoChapter(curChapterID + 1); Destroy(this.gameObject); }); }); }); }; }