void ClickCallBACK(int unlockPrice, Action ClickCallBack) { if (StaticData.GetWareHouseDiamond() >= unlockPrice) { //扣除资源 //刷新章节 StaticData.UpdateWareHouseDiamond(-unlockPrice); CSBuySection cSBuySection = new CSBuySection() { SectionId = curChapterID + 1 }; ProtocalManager.Instance().SendCSBuySection(cSBuySection, (SCBuySection x) => { StaticData.CreateToastTips("章节购买成功"); ChapterHelper.UnlockChapter(curChapterID + 1); foreach (var goodsInfo in x.CurrencyInfo) { StaticData.UpdateWareHouseItems(goodsInfo.GoodsId, (int)goodsInfo.Count); } ClickCallBack?.Invoke(); }, (ErrorInfo e) => { StaticData.CreateToastTips("章节购买失败"); Debug.LogError("章节购买失败" + e.webErrorCode); }, false); } else { StaticData.OpenRechargeUI(); } }
/// <summary> /// 弹出购买章节界面 /// </summary> public async static void PopupBuyChapterView(int chapterID, Action cancelCallBack) {//如果还没出下一章TODO var chapterInfo = StaticData.configExcel.GetSectionBySectionId(chapterID); if (chapterInfo == null) { StaticData.ToManorSelf(); cancelCallBack?.Invoke(); return; } 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, () => { if (StaticData.GetWareHouseDiamond() >= count) { //扣除资源 //刷新章节 StaticData.UpdateWareHouseDiamond(-count); CSBuySection cSBuySection = new CSBuySection() { SectionId = chapterID }; ProtocalManager.Instance().SendCSBuySection(cSBuySection, (SCBuySection x) => { StaticData.CreateToastTips("章节购买成功"); ChapterHelper.UnlockChapter(chapterID);//存入前端缓存 foreach (var goodsInfo in x.CurrencyInfo) { StaticData.UpdateWareHouseItems(goodsInfo.GoodsId, (int)goodsInfo.Count); } //进入下一章 EnterIntoChapter(chapterID); }, (ErrorInfo e) => { StaticData.CreateToastTips("章节购买失败"); Debug.LogError("章节购买失败" + e.webErrorCode); }, false); } else { StaticData.OpenRechargeUI(); } }, () => //取消购买直接进庄园 { cancelCallBack?.Invoke(); StaticData.ToManorSelf(); }, 120212); }
/// <summary> /// 解锁章节 /// </summary> void UnlockChapter() { this.unlockMaxChapterID += 1; ChapterHelper.UnlockChapter(this.unlockMaxChapterID); foreach (var item in chapterItems) { if (item.GetItemID() == unlockMaxChapterID) { item.SetUnlock(true); } if (item.GetItemID() == unlockMaxChapterID + 1) { item.SetBeforeUnlock(true); } } }
void ClickCallBACK(int unlockPrice, Action ClickCallBack) { if (StaticData.GetWareHouseDiamond() >= unlockPrice) { //扣除资源 //刷新章节 StaticData.UpdateWareHouseDiamond(-unlockPrice); CSBuySection cSBuySection = new CSBuySection() { SectionId = chapterID }; ProtocalManager.Instance().SendCSBuySection(cSBuySection, (SCBuySection x) => { StaticData.CreateToastTips(StaticData.GetMultilingual(120234)); //章节购买成功 ChapterHelper.UnlockChapter(this.chapterID); foreach (var goodsInfo in x.CurrencyInfo) { StaticData.UpdateWareHouseItems(goodsInfo.GoodsId, (int)goodsInfo.Count); } //ChapterHelper.ChpaterUpdateRedDot();//刷新红点 RedDotManager.UpdateRedDot(RedDotManager.RedDotKey.Chapter); UIChapterComponent.Instance.ShowChapterBtnRedDot(); ClickCallBack?.Invoke(); }, (ErrorInfo e) => { StaticData.CreateToastTips(StaticData.GetMultilingual(120235)); //("章节购买失败"); Debug.LogError("章节购买失败" + e.webErrorCode); }, false); } else { //打开钻石不足提示弹窗 string str = StaticData.GetMultilingual(120243);//钻石不足,需要购买吗 StaticData.OpenCommonTips(str, 120010, async() => { await StaticData.OpenRechargeUI(1); }, null, 120075); } }
/// <summary> /// 弹出购买章节界面 /// </summary> public async void PopupBuyChapterView(int chapterID, Action nextAction, Action cancelCallBack = null, int dealyTime = 0) { //如果还没出下一章 if (chapterID - StaticData.configExcel.Section[0].SectionId > StaticData.configExcel.GetVertical().CurVersionsChapterMaxCount - 1) { //显示未完待续页面,点击后淡出到大厅 //var expect = await ABManager.GetAssetAsync<GameObject>("ExpectTipView"); //GameObject go = GameObject.Instantiate(expect); //go.transform.SetRectTransformStretchAllWithParent(UIRoot.instance.GetUIRootCanvas().transform); //go.GetComponent<Button>().onClick.AddListener(() => //{ // go.GetComponent<Button>().enabled = false; // cancelCallBack?.Invoke(); // ChapterTool.FadeInFadeOut(go.GetComponent<CanvasGroup>(), 0, 0.01f, null, () => // { // Destroy(go.gameObject); // GameSoundPlayer.Instance.PlayBgMusic(MusicHelper.BgMusicLobby); // }); //}); cancelCallBack?.Invoke(); UIComponent.RemoveUI(UIType.UIChapter); await StaticData.ToManorSelf(); GameSoundPlayer.Instance.PlayBgMusic(MusicHelper.BgMusicManor); return; } var chapterInfo = StaticData.configExcel.GetSectionBySectionId(chapterID); int id = chapterInfo.UnlockPrice[0].ID; //取到钻石图片的id int count = (int)chapterInfo.UnlockPrice[0].Count; //取到数量 Sprite sprite = await ZillionaireToolManager.LoadItemSprite(id); string str = StaticData.GetMultilingual(120225); //$"你的等级不够解锁下一章了哦"; StaticData.OpenCommonBuyTips(str, sprite, count, () => { if (StaticData.GetWareHouseDiamond() >= count) { //扣除资源 //刷新章节 StaticData.UpdateWareHouseDiamond(-count); CSBuySection cSBuySection = new CSBuySection() { SectionId = chapterID }; ProtocalManager.Instance().SendCSBuySection(cSBuySection, async(SCBuySection x) => { StaticData.CreateToastTips(StaticData.GetMultilingual(120234)); //("章节购买成功"); ChapterHelper.UnlockChapter(chapterID); //存入前端缓存 foreach (var goodsInfo in x.CurrencyInfo) { //更新前端的货币信息 StaticData.UpdateWareHouseItems(goodsInfo.GoodsId, (int)goodsInfo.Count); } //进入下一章 EnterIntoNextChapter(chapterID, dealyTime); cancelCallBack?.Invoke(); //await ChapterHelper.EnterIntoChapter(chapterID); }, (ErrorInfo e) => { StaticData.CreateToastTips(StaticData.GetMultilingual(120235));//("章节购买失败"); Debug.LogError("章节购买失败" + e.webErrorCode); }, false); } else {//打开提示钻石不足界面 UnlockView(); } }, async() => //取消按钮改为去庄园 { nextAction?.Invoke(); if (dealyTime != 0) { await UniTask.Delay(dealyTime); } await StaticData.ToManorSelf(); Dispose(); UIComponent.RemoveUI(UIType.UIChapter); GameSoundPlayer.Instance.PlayBgMusic(MusicHelper.BgMusicManor); }, 120212, true); }