public Action clickCancelCallBack; //取消回调 /// <summary> /// 购买指定礼物界面 /// </summary> /// <param name="item">指定的礼物</param> /// <param name="defultAmount">默认数量</param> /// <param name="buySucceedCallBack">购买成功回调</param> /// <param name="clickCancelCallBack">点击取消回调</param> public async void ShowBuyView(ImpulseGiftGoods item, int defultAmount, Action <int> buySucceedCallBack = null, Action clickCancelCallBack = null) { this.gameObject.SetActive(true);//显示界面 this.giftInfo = item; Title.text = $"你还没有{ StaticData.GetMultiLanguageByGameItemId(giftInfo.goodsID)}哦,要购买吗";//TODO goodsIcon.sprite = await ABManager.GetAssetAsync <Sprite>(giftInfo.goodsIcon); goodsName.text = $"{StaticData.GetMultiLanguageByGameItemId(giftInfo.goodsID)}"; n2pAddValue.text = $"+{giftInfo.NpcAddValue}"; p2nAddValue.text = $"+{giftInfo.playerAddValue}"; int id = giftInfo.goodsPriceBuy[0].ID; //取到钻石图片的id priceAmount = (int)giftInfo.goodsPriceBuy[0].Count; //取到数量 Sprite sprite = await ZillionaireToolManager.LoadItemSprite(id); propIcon.sprite = sprite; this.buySucceedCallBack = buySucceedCallBack; this.clickCancelCallBack = clickCancelCallBack; amountComponent._defaultValue = defultAmount.ToString(); amountComponent.inputFiled.text = defultAmount.ToString(); amountComponent.act = BuyAmount; amountComponent._changeAction = ChangeAct; //取消事件 cancelBtn.onClick.RemoveAllListeners(); cancelBtn.onClick.AddListener(Cancel); //初始价格显示 默认数量*指定礼物价格 Price.text = (priceAmount * defultAmount).ToString(); }
/// <summary> /// 购买指定礼物界面 /// </summary> /// <param name="item">指定的礼物</param> /// <param name="defultAmount">默认数量</param> /// <param name="buySucceedCallBack">购买成功回调</param> /// <param name="clickCancelCallBack">点击取消回调</param> public async void ShowBuyView(int defultAmount, Action buySucceedCallBack = null, Action clickCancelCallBack = null, Action buyFailure = null) { this.gameObject.SetActive(true);//显示界面 Title.text = $"{ StaticData.GetMultilingual(120074)}{StaticData.GetMultilingual(2000002)}"; goodsName.text = $"{StaticData.GetMultiLanguageByGameItemId(StaticData.configExcel.GetVertical().PurpleGoldsId)}"; var zjbData = StaticData.configExcel.GetStoreByShopId(StaticData.configExcel.GetVertical().PurpleGoldsId); int id = zjbData.OriginalPrice[0].ID; //取到钻石图片的id priceAmount = (int)zjbData.OriginalPrice[0].Count; //取到数量 Sprite sprite = await ZillionaireToolManager.LoadItemSprite(id); this.buySucceedCallBack = buySucceedCallBack; this.clickCancelCallBack = clickCancelCallBack; this.buyFailureCallBack = buyFailure; amountComponent._defaultValue = defultAmount.ToString(); amountComponent.inputFiled.text = defultAmount.ToString(); amountComponent.act = BuyAmount; amountComponent._changeAction = ChangeAct; //初始价格显示 默认数量*指定礼物价格 Price.text = (priceAmount * defultAmount).ToString(); }
async void UnlockView(SectionDefine chapterInfo, Action ClickCallBack) { int id = chapterInfo.UnlockPrice[0].ID; //取到钻石图片的id int count = (int)chapterInfo.UnlockPrice[0].Count; //取到数量 Sprite sprite = await ZillionaireToolManager.LoadItemSprite(id); string str = string.Format(StaticData.GetMultilingual(120241), unlockLevel);//该章节需要解锁,是否提前解锁//钻石不足,需要购买吗 StaticData.OpenCommonBuyTips(str, sprite, count, () => ClickCallBACK(count, ClickCallBack)); }
/// <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> 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); }); }); }); }; }
/// <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); }