|
@@ -1,8 +1,7 @@
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
-using ET;
|
|
|
|
|
|
+using System.Linq;
|
|
using FairyGUI;
|
|
using FairyGUI;
|
|
-using UI.CommonGame;
|
|
|
|
using UI.EnduringGiftBox;
|
|
using UI.EnduringGiftBox;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
|
@@ -12,59 +11,194 @@ namespace GFGGame
|
|
{
|
|
{
|
|
private UI_EnduringGiftBoxUI _ui;
|
|
private UI_EnduringGiftBoxUI _ui;
|
|
|
|
|
|
|
|
+ private int _itemId; //道具id,该页面目前只给:体力,金币使用
|
|
|
|
+ private int _count; //本次购买次数
|
|
|
|
+ private int _buyTimes = 0; //已购次数
|
|
|
|
+
|
|
|
|
+ private Action _onSuccess;
|
|
|
|
+ private int _maxTimes = 0;
|
|
|
|
+ private string _message = "";
|
|
|
|
+ private List<ShopCfg> _shopCfgList = new List<ShopCfg>();
|
|
|
|
+
|
|
public override void Dispose()
|
|
public override void Dispose()
|
|
{
|
|
{
|
|
- base.Dispose();
|
|
|
|
-
|
|
|
|
if (_ui != null)
|
|
if (_ui != null)
|
|
{
|
|
{
|
|
_ui.Dispose();
|
|
_ui.Dispose();
|
|
_ui = null;
|
|
_ui = null;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ BuyConfirmController.Dispose();
|
|
|
|
+ base.Dispose();
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnInit()
|
|
protected override void OnInit()
|
|
{
|
|
{
|
|
base.OnInit();
|
|
base.OnInit();
|
|
-
|
|
|
|
- packageName = UI_EnduringGiftBoxUI.PACKAGE_NAME;
|
|
|
|
_ui = UI_EnduringGiftBoxUI.Create();
|
|
_ui = UI_EnduringGiftBoxUI.Create();
|
|
this.viewCom = _ui.target;
|
|
this.viewCom = _ui.target;
|
|
this.viewCom.Center();
|
|
this.viewCom.Center();
|
|
this.modal = true;
|
|
this.modal = true;
|
|
-
|
|
|
|
|
|
+ //viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; //先这样写,后面再改
|
|
|
|
+
|
|
|
|
+ _ui.m_btnSure.onClick.Add(OnClickBtnSure);
|
|
|
|
+ _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
|
|
}
|
|
}
|
|
|
|
|
|
- protected override void AddEventListener()
|
|
|
|
|
|
+ public void SetParams(int itemId, int count, Action onSuccess, string message = "")
|
|
{
|
|
{
|
|
- base.AddEventListener();
|
|
|
|
|
|
+ _itemId = itemId;
|
|
|
|
+ _count = count;
|
|
|
|
+
|
|
|
|
+ _onSuccess = onSuccess;
|
|
|
|
+ _message = message;
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnShown()
|
|
protected override void OnShown()
|
|
{
|
|
{
|
|
base.OnShown();
|
|
base.OnShown();
|
|
-
|
|
|
|
UpdateView();
|
|
UpdateView();
|
|
}
|
|
}
|
|
|
|
|
|
- protected override void OnHide()
|
|
|
|
|
|
+ private void UpdateView()
|
|
{
|
|
{
|
|
|
|
+ //--------老逻辑
|
|
|
|
+ _buyTimes = ItemDataManager.GetItemExchangeTimes(_itemId);
|
|
|
|
+
|
|
|
|
+ ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum,
|
|
|
|
+ out int buyNum);
|
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(_itemId);
|
|
|
|
+ ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
|
|
|
|
+ _ui.m_txtNeed.text = string.Format("是否花费{0}{1} 购买{2}{3}", coustNum, costCfg.name, buyNum, itemCfg.name);
|
|
|
|
|
|
- base.OnHide();
|
|
|
|
|
|
+ _ui.m_txtNum.text = "";
|
|
|
|
+ _maxTimes = ItemExchangeCfgArray.Instance.GetCfg(_itemId).maxLimit;
|
|
|
|
+ if (_maxTimes != 0)
|
|
|
|
+ {
|
|
|
|
+ _ui.m_txtNum.text = string.Format("今日剩余购买次数{0}/{1}", _maxTimes - _buyTimes, _maxTimes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (_message != "")
|
|
|
|
+ {
|
|
|
|
+ _ui.m_txtNum.text = _message;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //----新加逻辑
|
|
|
|
+ if (_itemId == ConstItemID.POWER)
|
|
|
|
+ {
|
|
|
|
+ //体力礼包--ShopDataManager.Instance.GetGoodsBuyNumById(curPowerGiftBox.id);得次数
|
|
|
|
+ _shopCfgList = ShopCfgArray.Instance
|
|
|
|
+ .GetCfgsBymenu1Andmenu2(ConstStoreTabId.ENDURING_GIFT_BOX, ConstStoreSubId.ENDURING_GIFT_BOX_POWER)
|
|
|
|
+ .OrderBy(a => a.refreshType).ToList();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //金币礼包
|
|
|
|
+ _shopCfgList = ShopCfgArray.Instance
|
|
|
|
+ .GetCfgsBymenu1Andmenu2(ConstStoreTabId.ENDURING_GIFT_BOX, ConstStoreSubId.ENDURING_GIFT_BOX_GOLD)
|
|
|
|
+ .OrderBy(a => a.refreshType).ToList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _ui.m_txtPromptExt.text = string.Format("除了上述购买{0}的途径,我们还提供了更多的优惠礼包选择", itemCfg.name);
|
|
|
|
+ _ui.m_list.itemRenderer = ListItemRender;
|
|
}
|
|
}
|
|
|
|
|
|
- protected override void RemoveEventListener()
|
|
|
|
|
|
+
|
|
|
|
+ private void ListItemRender(int index, GObject obj)
|
|
{
|
|
{
|
|
- base.RemoveEventListener();
|
|
|
|
|
|
+ ShopCfg shopCfg = _shopCfgList[index];
|
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId); //购买的物品-礼包
|
|
|
|
+ UI_ComCurSupplyItem item = UI_ComCurSupplyItem.Proxy(obj);
|
|
|
|
+ item.target.data = shopCfg;
|
|
|
|
+
|
|
|
|
+ //返利包
|
|
|
|
+ item.m_txtTitle.text = itemCfg.name;
|
|
|
|
+ item.m_txtWeekPrompt.visible = false;
|
|
|
|
+ item.m_icoWeekPromptTag.visible = false;
|
|
|
|
+ if (itemCfg.param2Arr[0] != 0)
|
|
|
|
+ {
|
|
|
|
+ item.m_txtWeekPrompt.visible = true;
|
|
|
|
+ item.m_icoWeekPromptTag.visible = true;
|
|
|
|
+ item.m_txtWeekPrompt.text = string.Format("连续{0}天每日获得", itemCfg.param2Arr[0]);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
|
|
|
|
+ item.m_comLeftGiftBox.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
|
+ if (shopCfg.refreshType == RefreshType.DAY) //也可以换成人民币来做条件
|
|
|
|
+ {
|
|
|
|
+ //日刷
|
|
|
|
+ item.m_comLeftGiftBox.m_comDiscount.target.visible = true;
|
|
|
|
+ item.m_comLeftGiftBox.m_comDiscount.m_txtDiscountNum.text = "1.5折"; //之后再计算赋值
|
|
|
|
+ item.m_comLeftGiftBox.m_comGouMaiGetText.target.visible = false;
|
|
|
|
+ item.m_txtUrc.text = string.Format("今日剩余{0}/{1}", remainBuyNum, shopCfg.maxBuyNum);
|
|
|
|
+ item.m_txtLrc.text = string.Format("可获得{0}会员积分", shopCfg.price * 10);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ //周刷
|
|
|
|
+ item.m_comLeftGiftBox.m_comDiscount.target.visible = false;
|
|
|
|
+ item.m_comLeftGiftBox.m_comGouMaiGetText.target.visible = true;
|
|
|
|
+ var itemArr = itemCfg.itemsArr[0];
|
|
|
|
+ ItemCfg getItemCfg = ItemCfgArray.Instance.GetCfg(itemArr[0]); //及时获得的物品,读取第一个显示ICON
|
|
|
|
+ item.m_comLeftGiftBox.m_comGouMaiGetText.m_loaIcon.url = ResPathUtil.GetIconPath(getItemCfg);
|
|
|
|
+ item.m_comLeftGiftBox.m_comGouMaiGetText.m_txtGetGold.text = itemArr[1].ToString();
|
|
|
|
+ item.m_txtUrc.text = string.Format("每周限购{0}/{1}", remainBuyNum, shopCfg.maxBuyNum);
|
|
|
|
+ item.m_txtLrc.text = string.Format("剩余{0}天", "");//剩余天数,应该是存储在数值组件上的,下周一过来再找找 然后赋值吧
|
|
|
|
+ //领取按钮的渲染,后端加个组件来记录着领取状态
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- private void UpdateView()
|
|
|
|
|
|
+ private async void OnClickBtnSure()
|
|
{
|
|
{
|
|
-
|
|
|
|
|
|
+ if (_maxTimes > 0 && (_buyTimes + _count) > _maxTimes)
|
|
|
|
+ {
|
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("购买次数不足");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum,
|
|
|
|
+ out int buyNum);
|
|
|
|
|
|
|
|
+ Debug.Log(costId + "数量:" + ItemDataManager.GetItemNum(costId));
|
|
|
|
+ if (ItemDataManager.GetItemNum(costId) < coustNum)
|
|
|
|
+ {
|
|
|
|
+ ItemCfg costCfg = ItemCfgArray.Instance.GetCfg(costId);
|
|
|
|
+ if (_itemId == ConstItemID.DIAMOND_PURPLE)
|
|
|
|
+ {
|
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt(string.Format("{0}不足,请前往商城选购", costCfg.name));
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ AlertUI.Show(costCfg.name + "不足,是否前往购买?").SetLeftButton(true).SetRightButton(true, "确认",
|
|
|
|
+ (AlertWindow.AlertCallback)((object data) =>
|
|
|
|
+ {
|
|
|
|
+ long costNeedCount = coustNum - ItemDataManager.GetItemNum(costId);
|
|
|
|
+ BuyItemConteoller.Show(costId, costNeedCount, ConstBuyType.TYPE_ITEM, null, true, true,
|
|
|
|
+ GameConst.MAX_COUNT_TO_BUY_DIAMOND_RED);
|
|
|
|
+ }));
|
|
|
|
+ OnClickBtnCancel();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool result = await ItemExchangeSProxy.ItemExchange(_itemId, _count);
|
|
|
|
+
|
|
|
|
+ if (result)
|
|
|
|
+ {
|
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("购买成功", MessageType.SUCCESS);
|
|
|
|
+ if (_onSuccess != null)
|
|
|
|
+ {
|
|
|
|
+ _onSuccess();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.Hide();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OnClickBtnCancel()
|
|
|
|
+ {
|
|
|
|
+ this.Hide();
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|