|
@@ -1,6 +1,7 @@
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using ET;
|
|
|
using FairyGUI;
|
|
|
using UI.EnduringGiftBox;
|
|
|
using UnityEngine;
|
|
@@ -19,30 +20,89 @@ namespace GFGGame
|
|
|
private int _maxTimes = 0;
|
|
|
private string _message = "";
|
|
|
private List<ShopCfg> _shopCfgList = new List<ShopCfg>();
|
|
|
+ private GameObject _gameObject1;
|
|
|
+ private GameObject _gameObject2;
|
|
|
+ private GameObject _gameObject3;
|
|
|
+ private GameObject _gameObject4;
|
|
|
+
|
|
|
+ private GoWrapper _wrapper1;
|
|
|
+ private GoWrapper _wrapper2;
|
|
|
+ private GoWrapper _wrapper3;
|
|
|
+ private GoWrapper _wrapper4;
|
|
|
+
|
|
|
+ protected override void OnInit()
|
|
|
+ {
|
|
|
+ base.OnInit();
|
|
|
+ packageName = UI_EnduringGiftBoxUI.PACKAGE_NAME;
|
|
|
+ _ui = UI_EnduringGiftBoxUI.Create();
|
|
|
+ this.viewCom = _ui.target;
|
|
|
+ this.viewCom.Center();
|
|
|
+ this.modal = true;
|
|
|
+ viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; //先这样写,后面再改
|
|
|
+
|
|
|
+ //测试数据
|
|
|
+ EnduringGiftBoxDataManager.GiftBoxStateDic[110001] = 1;
|
|
|
+ EnduringGiftBoxDataManager.GiftBoxStateDic[110002] = 1;
|
|
|
+ EnduringGiftBoxDataManager.GiftBoxStateDic[110003] = 1;
|
|
|
+ EnduringGiftBoxDataManager.GiftBoxStateDic[110004] = 1;
|
|
|
+
|
|
|
+ _ui.m_btnSure.onClick.Add(OnClickBtnSure);
|
|
|
+ _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
|
|
|
+ }
|
|
|
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
+ SceneController.DestroyObjectFromView(_gameObject1, _wrapper1);
|
|
|
+ SceneController.DestroyObjectFromView(_gameObject2, _wrapper2);
|
|
|
+ SceneController.DestroyObjectFromView(_gameObject3, _wrapper3);
|
|
|
+ SceneController.DestroyObjectFromView(_gameObject4, _wrapper4);
|
|
|
if (_ui != null)
|
|
|
{
|
|
|
_ui.Dispose();
|
|
|
_ui = null;
|
|
|
}
|
|
|
|
|
|
- BuyConfirmController.Dispose();
|
|
|
+ EnduringGiftBoxController.Dispose();
|
|
|
base.Dispose();
|
|
|
}
|
|
|
|
|
|
- protected override void OnInit()
|
|
|
+ protected override void OnShown()
|
|
|
{
|
|
|
- base.OnInit();
|
|
|
- _ui = UI_EnduringGiftBoxUI.Create();
|
|
|
- this.viewCom = _ui.target;
|
|
|
- this.viewCom.Center();
|
|
|
- this.modal = true;
|
|
|
- //viewAnimationType = EnumViewAnimationType.ZOOM_CENTER; //先这样写,后面再改
|
|
|
+ base.OnShown();
|
|
|
+ AddEffect();
|
|
|
+ UpdateView();
|
|
|
+ }
|
|
|
|
|
|
- _ui.m_btnSure.onClick.Add(OnClickBtnSure);
|
|
|
- _ui.m_btnCancel.onClick.Add(OnClickBtnCancel);
|
|
|
+ private void AddEffect()
|
|
|
+ {
|
|
|
+ string resPath3;
|
|
|
+ if (_itemId == ConstItemID.POWER)
|
|
|
+ {
|
|
|
+ resPath3 = ResPathUtil.GetViewEffectPath("ui_Activity", "Activity_people02");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ resPath3 = ResPathUtil.GetViewEffectPath("ui_Activity", "Activity_people01");
|
|
|
+ }
|
|
|
+
|
|
|
+ //小人
|
|
|
+ SceneController.AddObjectToView(null, null, _ui.m_holderBaby, resPath3,
|
|
|
+ out _gameObject3, out _wrapper3);
|
|
|
+
|
|
|
+ //爆发,大泡泡
|
|
|
+ string resPath1 = ResPathUtil.GetViewEffectPath("ui_Activity", "Activity_baofa");
|
|
|
+ SceneController.AddObjectToView(null, null, _ui.m_holderPaoMax, resPath1,
|
|
|
+ out _gameObject1, out _wrapper1);
|
|
|
+
|
|
|
+ //持续的小泡泡
|
|
|
+ string resPath2 = ResPathUtil.GetViewEffectPath("ui_Activity", "Activity_chixu");
|
|
|
+ SceneController.AddObjectToView(null, null, _ui.m_holderPaoMin, resPath2,
|
|
|
+ out _gameObject2, out _wrapper2);
|
|
|
+
|
|
|
+ //爆发时候的发光
|
|
|
+ string resPath4 = ResPathUtil.GetViewEffectPath("ui_Activity", "Activity_glow");
|
|
|
+ SceneController.AddObjectToView(null, null, _ui.m_holderFg, resPath4,
|
|
|
+ out _gameObject4, out _wrapper4);
|
|
|
}
|
|
|
|
|
|
public void SetParams(int itemId, int count, Action onSuccess, string message = "")
|
|
@@ -54,15 +114,8 @@ namespace GFGGame
|
|
|
_message = message;
|
|
|
}
|
|
|
|
|
|
- protected override void OnShown()
|
|
|
- {
|
|
|
- base.OnShown();
|
|
|
- UpdateView();
|
|
|
- }
|
|
|
-
|
|
|
private void UpdateView()
|
|
|
{
|
|
|
- //--------老逻辑
|
|
|
_buyTimes = ItemDataManager.GetItemExchangeTimes(_itemId);
|
|
|
|
|
|
ItemExchangeCfgArray.Instance.GetMoneyIdAndNum(_itemId, _buyTimes, _count, out int costId, out int coustNum,
|
|
@@ -83,10 +136,11 @@ namespace GFGGame
|
|
|
_ui.m_txtNum.text = _message;
|
|
|
}
|
|
|
|
|
|
- //----新加逻辑
|
|
|
+ _shopCfgList.Clear();
|
|
|
+ //常驻礼包
|
|
|
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();
|
|
@@ -101,9 +155,10 @@ namespace GFGGame
|
|
|
|
|
|
_ui.m_txtPromptExt.text = string.Format("除了上述购买{0}的途径,我们还提供了更多的优惠礼包选择", itemCfg.name);
|
|
|
_ui.m_list.itemRenderer = ListItemRender;
|
|
|
+ _ui.m_list.numItems = _shopCfgList.Count;
|
|
|
+ _ui.m_list.visible = true;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
private void ListItemRender(int index, GObject obj)
|
|
|
{
|
|
|
ShopCfg shopCfg = _shopCfgList[index];
|
|
@@ -115,15 +170,20 @@ namespace GFGGame
|
|
|
item.m_txtTitle.text = itemCfg.name;
|
|
|
item.m_txtWeekPrompt.visible = false;
|
|
|
item.m_icoWeekPromptTag.visible = false;
|
|
|
- if (itemCfg.param2Arr[0] != 0)
|
|
|
+ if (itemCfg.param2Arr.Length != 0)
|
|
|
{
|
|
|
item.m_txtWeekPrompt.visible = true;
|
|
|
item.m_icoWeekPromptTag.visible = true;
|
|
|
item.m_txtWeekPrompt.text = string.Format("连续{0}天每日获得", itemCfg.param2Arr[0]);
|
|
|
}
|
|
|
|
|
|
+ int numItems;
|
|
|
+ var childItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
|
|
|
var remainBuyNum = shopCfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
|
|
|
item.m_comLeftGiftBox.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+ item.m_btnBuy.m_txtOldPrice.text = $"{shopCfg.originalPrice}";
|
|
|
+ item.m_btnBuy.m_txtNewPrice.text = $"{shopCfg.price}元";
|
|
|
+
|
|
|
if (shopCfg.refreshType == RefreshType.DAY) //也可以换成人民币来做条件
|
|
|
{
|
|
|
//日刷
|
|
@@ -132,10 +192,31 @@ namespace GFGGame
|
|
|
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);
|
|
|
+ item.m_txtWeekPrompt.visible = false;
|
|
|
+ item.m_icoWeekPromptTag.visible = false;
|
|
|
+ numItems = childItemCfg.itemsArr.Length;
|
|
|
+
|
|
|
+ if (remainBuyNum == 0)
|
|
|
+ {
|
|
|
+ //已售完
|
|
|
+ item.m_btnBuy.target.visible = true;
|
|
|
+ item.m_btnCurReceive.target.visible = false;
|
|
|
+ item.m_btnBuy.m_bagYellow.visible = false;
|
|
|
+ item.m_btnBuy.m_bagGrey.visible = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //未售完
|
|
|
+ item.m_btnBuy.target.visible = true;
|
|
|
+ item.m_btnCurReceive.target.visible = false;
|
|
|
+ item.m_btnBuy.m_bagYellow.visible = true;
|
|
|
+ item.m_btnBuy.m_bagGrey.visible = false;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//周刷
|
|
|
+ var weekGiftBoxState = EnduringGiftBoxDataManager.GiftBoxStateDic[shopCfg.id];
|
|
|
item.m_comLeftGiftBox.m_comDiscount.target.visible = false;
|
|
|
item.m_comLeftGiftBox.m_comGouMaiGetText.target.visible = true;
|
|
|
var itemArr = itemCfg.itemsArr[0];
|
|
@@ -143,9 +224,138 @@ namespace GFGGame
|
|
|
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}天", "");//剩余天数,应该是存储在数值组件上的,下周一过来再找找 然后赋值吧
|
|
|
- //领取按钮的渲染,后端加个组件来记录着领取状态
|
|
|
+ item.m_txtLrc.text = string.Format("剩余{0}天", "");
|
|
|
+ item.m_txtWeekPrompt.visible = true;
|
|
|
+ item.m_txtWeekPrompt.text =
|
|
|
+ string.Format("连续{0}天每日获得", NumberUtil.GetChiniseNumberText(itemCfg.param2Arr[0]));
|
|
|
+ item.m_icoWeekPromptTag.visible = true;
|
|
|
+
|
|
|
+ numItems = childItemCfg.param1Arr.Length;
|
|
|
+
|
|
|
+ //是否需要领取
|
|
|
+ if (weekGiftBoxState == EnduringGiftBoxBuyStatus.NoGet)
|
|
|
+ {
|
|
|
+ item.m_btnBuy.target.visible = false;
|
|
|
+ item.m_btnCurReceive.target.visible = true;
|
|
|
+ item.m_btnCurReceive.m_receive.visible = true;
|
|
|
+ item.m_btnCurReceive.m_received.visible = false;
|
|
|
+ item.m_btnCurReceive.m_txtRec.text = "领取";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //是否能购买
|
|
|
+ if (remainBuyNum == 0)
|
|
|
+ {
|
|
|
+ //已售完
|
|
|
+ item.m_btnBuy.target.visible = false;
|
|
|
+ item.m_btnCurReceive.target.visible = true;
|
|
|
+ item.m_btnCurReceive.m_receive.visible = false;
|
|
|
+ item.m_btnCurReceive.m_received.visible = true;
|
|
|
+ item.m_btnCurReceive.m_txtRec.text = "已领取";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //未售完
|
|
|
+ item.m_btnBuy.target.visible = true;
|
|
|
+ item.m_btnCurReceive.target.visible = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //领取按钮点击事件
|
|
|
+ //购买按钮点击事件
|
|
|
+ item.m_btnBuy.target.onClick.Add(OnBtnBuyClick);
|
|
|
+
|
|
|
+ item.m_list.data = shopCfg;
|
|
|
+ item.m_list.itemRenderer = ChildListItemRender;
|
|
|
+ item.m_list.numItems = numItems;
|
|
|
+ }
|
|
|
+
|
|
|
+ //领取按钮点击事件
|
|
|
+
|
|
|
+ //购买按钮点击事件
|
|
|
+ private void OnBtnBuyClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject sender = context.sender as GObject;
|
|
|
+ GObject obj = sender.parent;
|
|
|
+ ShopCfg cfg = obj.data as ShopCfg;
|
|
|
+ bool isSellOut = cfg.maxBuyNum > 0 &&
|
|
|
+ cfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(cfg.id) <= 0;
|
|
|
+
|
|
|
+ if (isSellOut)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("已售罄");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!ShopDataManager.Instance.GetShopGoodsStateById(cfg.id))
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt(ShopDataManager.Instance.GetShopGoodsStateTips(cfg.id));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (cfg.costType == CostType.FREE)
|
|
|
+ {
|
|
|
+ ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();
|
|
|
+ LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ViewManager.Show<ItemExchangeView>(cfg.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ChildListItemRender(int index, GObject obj)
|
|
|
+ {
|
|
|
+ UI_ComRewardIconItem uiItemChild = UI_ComRewardIconItem.Proxy(obj);
|
|
|
+ var shopCfg = uiItemChild.target.parent.data as ShopCfg;
|
|
|
+ var itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
|
|
|
+ // uiItemChild.m_showRreceives.visible = false;
|
|
|
+
|
|
|
+ var curGiftBoxState = EnduringGiftBoxDataManager.GiftBoxStateDic[shopCfg.id];
|
|
|
+ int[][] result;
|
|
|
+ if (shopCfg.refreshType == RefreshType.DAY)
|
|
|
+ {
|
|
|
+ result = itemCfg.itemsArr;
|
|
|
+ uiItemChild.m_bagYellow.visible = false;
|
|
|
+ uiItemChild.m_bagBlue.visible = true;
|
|
|
+ uiItemChild.m_bagYellowEx.visible = false;
|
|
|
+ uiItemChild.m_bagBlueEx.visible = true;
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //周刷
|
|
|
+ result = itemCfg.param1Arr;
|
|
|
+ uiItemChild.m_bagYellow.visible = true;
|
|
|
+ uiItemChild.m_bagBlue.visible = false;
|
|
|
+ uiItemChild.m_bagYellowEx.visible = true;
|
|
|
+ uiItemChild.m_bagBlueEx.visible = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // if (curGiftBoxState == EnduringGiftBoxBuyStatus.YesGet)
|
|
|
+ // {
|
|
|
+ // uiItemChild.m_showRreceives.visible = true;
|
|
|
+ // }
|
|
|
+ // else if (curGiftBoxState == EnduringGiftBoxBuyStatus.NoGet)
|
|
|
+ // {
|
|
|
+ // uiItemChild.m_showRreceives.visible = false;
|
|
|
+ // }
|
|
|
+
|
|
|
+ var itemArr = result[index];
|
|
|
+ var itemCfgChild = ItemCfgArray.Instance.GetCfg(itemArr[0]);
|
|
|
+ uiItemChild.m_loaIcon.onClick.Add(OnListSelectorItemClick);
|
|
|
+ uiItemChild.m_loaIcon.url = ResPathUtil.GetIconPath(itemCfgChild);
|
|
|
+ uiItemChild.m_num.text = itemArr[1].ToString();
|
|
|
+ uiItemChild.target.data = itemCfgChild;
|
|
|
+ UI_ComRewardIconItem.ProxyEnd();
|
|
|
+ }
|
|
|
+
|
|
|
+ //弹出物品详细描述框
|
|
|
+ private void OnListSelectorItemClick(EventContext context)
|
|
|
+ {
|
|
|
+ GObject sender = context.sender as GObject;
|
|
|
+ GObject obj = sender.parent;
|
|
|
+ ItemCfg itemCfg = obj.data as ItemCfg;
|
|
|
+ GoodsItemTipsController.ShowItemTips(itemCfg.id);
|
|
|
}
|
|
|
|
|
|
private async void OnClickBtnSure()
|