|
@@ -19,8 +19,7 @@ namespace GFGGame
|
|
|
private int indexItem = 0;
|
|
|
private int muem2;
|
|
|
private List<int> listIndex = new List<int>();
|
|
|
- private List<int> originalIdList = new List<int>() { 50001, 50002, 50003, 50004 };
|
|
|
- private Dictionary<int, int> discountDic = new Dictionary<int, int>();
|
|
|
+ private List<EffectUI> _effectUIs = new List<EffectUI>();
|
|
|
public override void Dispose()
|
|
|
{
|
|
|
if (_valueBarController != null)
|
|
@@ -73,36 +72,21 @@ namespace GFGGame
|
|
|
_valueBarController.OnShown();
|
|
|
muem2 = (int)this.viewData;
|
|
|
AddgiftBagID();
|
|
|
- UpdateDic();
|
|
|
-
|
|
|
+ ReturnDiscountTimeSuitIndex();
|
|
|
UpdateView();
|
|
|
Timers.inst.Add(5, 0, UpdateListSuit);
|
|
|
- Timers.inst.Add(1, 0, UpdateTime);
|
|
|
+ //Timers.inst.Add(1, 0, UpdateTime);
|
|
|
}
|
|
|
protected override void OnHide()
|
|
|
{
|
|
|
Timers.inst.Remove(UpdateListSuit);
|
|
|
- Timers.inst.Remove(UpdateTime);
|
|
|
+ //Timers.inst.Remove(UpdateTime);
|
|
|
giftBagList.Clear();
|
|
|
- discountDic.Clear();
|
|
|
listIndex.Clear();
|
|
|
base.OnHide();
|
|
|
- ShopViewManager.Instance.ClearItemEff();
|
|
|
+ ClearItemEff();
|
|
|
_valueBarController.OnHide();
|
|
|
}
|
|
|
- private async void OnBtnGetClick()
|
|
|
- {
|
|
|
- }
|
|
|
- private void OnClickLeft()
|
|
|
- {
|
|
|
- indexSuit--;
|
|
|
- UpdateView();
|
|
|
- }
|
|
|
- private void OnClickRight()
|
|
|
- {
|
|
|
- indexSuit++;
|
|
|
- UpdateView();
|
|
|
- }
|
|
|
|
|
|
private void OnNumericChange(EventContext context)
|
|
|
{
|
|
@@ -120,21 +104,109 @@ namespace GFGGame
|
|
|
}
|
|
|
private void UpdateView()
|
|
|
{
|
|
|
- ShopViewManager.Instance.ClearItemEff();
|
|
|
+ ClearItemEff();
|
|
|
_shopCfgs = ShopCfgArray.Instance.GetCfgsBymenu1Andmenu2(102, muem2);
|
|
|
_shopCfgs = ShopDataManager.Instance.RemoveNotOpenCfg(_shopCfgs);
|
|
|
+ _shopCfgs = ShopDataManager.Instance.RemoveNotSaleCfg(_shopCfgs);
|
|
|
_shopCfgs = ShopDataManager.Instance.SortShopGoodsCfgs(_shopCfgs);
|
|
|
//UpdateShopCfg();
|
|
|
- _ui.m_listCom.m_list.numItems = _shopCfgs.Count;
|
|
|
_ui.m_suitList.numItems = giftBagList.Count;
|
|
|
+ _ui.m_listCom.m_list.numItems = _shopCfgs.Count;
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ListItemRender(int index, GObject obj)
|
|
|
{
|
|
|
ShopCfg shopCfg = _shopCfgs[index];
|
|
|
- ShopViewManager.Instance.UptadeItem(obj, shopCfg);
|
|
|
+ int isBuy;
|
|
|
+ int currentID;
|
|
|
+ int originalID;
|
|
|
+ currentID = shopCfg.id;
|
|
|
+ originalID = shopCfg.id;
|
|
|
+ bool flog = false;
|
|
|
+ foreach (var Id in listIndex)
|
|
|
+ {
|
|
|
+ if(Id == shopCfg.id)
|
|
|
+ {
|
|
|
+ flog = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!flog)
|
|
|
+ {
|
|
|
+ shopCfg = ShopCfgArray.Instance.GetCfg(_shopCfgs[index].originalId);
|
|
|
+ currentID = shopCfg.id;
|
|
|
+ }
|
|
|
+ UI_ListShopItem item = UI_ListShopItem.Proxy(obj);
|
|
|
+
|
|
|
+ ItemCfg itemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.itemId);
|
|
|
+ item.m_txtName.text = shopCfg.itemName;
|
|
|
+ item.m_icon.url = ResPathUtil.GetIconPath(itemCfg);
|
|
|
+
|
|
|
+ item.m_grpDiscount.visible = shopCfg.Price < shopCfg.originalPrice;
|
|
|
+ if (item.m_grpDiscount.visible)
|
|
|
+ {
|
|
|
+ EffectUI _effectUI = EffectUIPool.CreateEffectUI(item.m_holderfEff, "ui_Small_parts", "store_Value");
|
|
|
+ _effectUIs.Add(_effectUI);
|
|
|
+ item.m_holderfEff.visible = shopCfg.Price < shopCfg.originalPrice;
|
|
|
+ }
|
|
|
+ item.m_txtDesc.text = shopCfg.Price <= 0 ? "" : ShopDataManager.Instance.GetShopGoodsDiscount(shopCfg.id).ToString();
|
|
|
+
|
|
|
+ item.m_txtEndTime.SetVar("value", ShopDataManager.Instance.GetEndTime(shopCfg.id)).FlushVars();
|
|
|
+ item.m_txtEndTime.visible = shopCfg.endTime != "";
|
|
|
+
|
|
|
+ item.m_c2.selectedIndex = ShopDataManager.Instance.GetShopGoodsStateById(shopCfg.id) ? 1 : 0;
|
|
|
+ item.m_txtLock.text = ShopDataManager.Instance.GetShopGoodsStateTips(shopCfg.id);
|
|
|
+
|
|
|
+ int buyNum = ShopDataManager.Instance.GetGoodsBuyNumById(shopCfg.id);
|
|
|
+ item.m_txtLimit.visible = shopCfg.maxBuyNum > 0;
|
|
|
+ item.m_txtLimit.text = string.Format("{0}({1}/{2})", ShopDataManager.Instance.refreshType[shopCfg.refreshType], StringUtil.GetColorText(buyNum.ToString(), "#5A3E16"), shopCfg.maxBuyNum);
|
|
|
+
|
|
|
+ item.m_c1.selectedIndex = shopCfg.maxBuyNum == 0 || buyNum < shopCfg.maxBuyNum ? 0 : 1;
|
|
|
+
|
|
|
+ if (item.m_c1.selectedIndex == 0)//可购买
|
|
|
+ {
|
|
|
+ item.m_btnBuy.m_txtOriginalPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.originalPrice);
|
|
|
+ if (shopCfg.Price > 0 && shopCfg.CostTypeReal != CostType.FREE)//不免费
|
|
|
+ {
|
|
|
+ item.m_btnBuy.m_grpOriginalPrice.visible = shopCfg.originalPrice > 0 && shopCfg.originalPrice != shopCfg.Price;
|
|
|
+ item.m_btnBuy.m_loaIcon.visible = true;
|
|
|
+ item.m_btnBuy.m_txtPrice.text = NumberUtil.ChangeNumberUnit(shopCfg.Price);// cfg.price.ToString();
|
|
|
+
|
|
|
+ if (shopCfg.CostTypeReal == CostType.RMB)//人民币
|
|
|
+ {
|
|
|
+ item.m_btnBuy.m_loaIcon.visible = false;
|
|
|
+ item.m_btnBuy.m_txtIcon.visible = true;
|
|
|
+ item.m_btnBuy.m_txtIcon.text = "¥";
|
|
|
+ }
|
|
|
+ else//道具
|
|
|
+ {
|
|
|
+ ItemCfg costItemCfg = ItemCfgArray.Instance.GetCfg(shopCfg.CostIdReal);
|
|
|
+ item.m_btnBuy.m_loaIcon.url = ResPathUtil.GetIconPath(costItemCfg);
|
|
|
+ item.m_btnBuy.m_loaIcon.visible = true;
|
|
|
+ item.m_btnBuy.m_txtIcon.visible = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.m_btnBuy.m_txtIcon.text = "";
|
|
|
+ item.m_btnBuy.m_loaIcon.visible = false;
|
|
|
+ item.m_btnBuy.m_grpOriginalPrice.visible = false;
|
|
|
+ item.m_btnBuy.m_txtPrice.text = "免费";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (item.target.data == null)
|
|
|
+ {
|
|
|
+ item.target.onClick.Add(OnBtnBugItem);
|
|
|
+ }
|
|
|
+ item.target.data = new List<int> { currentID, originalID };
|
|
|
+ bool isRed = item.m_c1.selectedIndex == 0 && item.m_c2.selectedIndex == 0 && shopCfg.Price == 0;
|
|
|
+
|
|
|
+ RedDotController.Instance.SetComRedDot(item.target, isRed, "", -6, 100);
|
|
|
+ UI_ListShopItem.ProxyEnd();
|
|
|
}
|
|
|
+
|
|
|
private void ListItemSuitRender(int index, GObject obj)
|
|
|
{
|
|
|
UI_StoreZGTHitem item = UI_StoreZGTHitem.Proxy(obj);
|
|
@@ -158,7 +230,16 @@ namespace GFGGame
|
|
|
item.m_discountText.text = string.Format("{0}", discount.ToString());
|
|
|
item.m_DiscountGroud.visible = true;
|
|
|
item.m_timeText.visible = true;
|
|
|
- long endTime = TimeUtil.DateTimeToTimestamp(EverydaySaleCfgArray.Instance.dataArray[index].endTime);
|
|
|
+ long endTime;
|
|
|
+ if (EverydaySaleCfgArray.Instance.dataArray[index].endTime == "" || EverydaySaleCfgArray.Instance.dataArray[index].endTime == null)
|
|
|
+ {
|
|
|
+ var activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfo(EverydaySaleCfgArray.Instance.dataArray[index].activityId);
|
|
|
+ endTime = activityInfo.EndTime;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ endTime = TimeUtil.DateTimeToTimestamp(EverydaySaleCfgArray.Instance.dataArray[index].endTime);
|
|
|
+ }
|
|
|
var leftTime = endTime - TimeHelper.ServerNow();
|
|
|
item.m_timeText.text = TimeUtil.FormattingTimeTo_DDHHmm(leftTime);
|
|
|
}
|
|
@@ -172,6 +253,45 @@ namespace GFGGame
|
|
|
}
|
|
|
UI_StoreZGTHitem.ProxyEnd();
|
|
|
}
|
|
|
+ private void OnBtnBugItem(EventContext context)
|
|
|
+ {
|
|
|
+ //idlist:0:当前显示的id,1:折扣id;
|
|
|
+ List<int> idList = (List<int>) (context.sender as GObject).data;
|
|
|
+ ShopCfg cfg = ShopCfgArray.Instance.GetCfg(idList[0]);
|
|
|
+ ShopCfg cfg1 = ShopCfgArray.Instance.GetCfg(idList[1]);
|
|
|
+ bool isSellOutoriginal = true;
|
|
|
+ if (cfg.originalId == 0)
|
|
|
+ {
|
|
|
+ int maxBuyNum = cfg.maxBuyNum;
|
|
|
+ int countBuyNum = ShopDataManager.Instance.GetGoodsBuyNumById(cfg.id) + ShopDataManager.Instance.GetGoodsBuyNumById(cfg1.originalId);
|
|
|
+ isSellOutoriginal = maxBuyNum > 0 && maxBuyNum - countBuyNum <= 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ShopCfg shopcfg = ShopCfgArray.Instance.GetCfg(idList[0]);
|
|
|
+ isSellOutoriginal = shopcfg.maxBuyNum > 0 && shopcfg.maxBuyNum - ShopDataManager.Instance.GetGoodsBuyNumById(shopcfg.id) <= 0;
|
|
|
+ }
|
|
|
+ if (isSellOutoriginal)
|
|
|
+ {
|
|
|
+ PromptController.Instance.ShowFloatTextPrompt("已售罄");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // if (!ShopDataManager.Instance.GetShopGoodsStateById(cfg.id))
|
|
|
+ // {
|
|
|
+ // PromptController.Instance.ShowFloatTextPrompt(ShopDataManager.Instance.GetShopGoodsStateTips(cfg.id));
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+
|
|
|
+ if (cfg.CostTypeReal == CostType.FREE)
|
|
|
+ {
|
|
|
+ ShopSProxy.ReqShopBuy(cfg.id, 1).Coroutine();
|
|
|
+ LogServerHelper.SendPlayParticipationLog((int)PlayParticipationEnum.SHANG_CHENG, 2);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ViewManager.Show<ItemExchangeView>(cfg.id);
|
|
|
+ }
|
|
|
+ }
|
|
|
private void UpdateListSuit(object param)
|
|
|
{
|
|
|
int itemIndex = _ui.m_suitList.ChildIndexToItemIndex(0) + 1;
|
|
@@ -188,6 +308,10 @@ namespace GFGGame
|
|
|
{
|
|
|
long endTime;
|
|
|
long startTime;
|
|
|
+ if(item.openTime == "" || item.openTime == null)
|
|
|
+ {
|
|
|
+ return ActivityGlobalDataManager.Instance.IsActivityOpen(item.activityId);
|
|
|
+ }
|
|
|
endTime = TimeUtil.DateTimeToTimestamp(item.endTime);
|
|
|
startTime = TimeUtil.DateTimeToTimestamp(item.openTime);
|
|
|
if (startTime <= TimeHelper.ServerNow() && endTime > TimeHelper.ServerNow())
|
|
@@ -196,6 +320,28 @@ namespace GFGGame
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
+ private void ReturnDiscountTimeSuitIndex()
|
|
|
+ {
|
|
|
+ int count = 0;
|
|
|
+ long endTime;
|
|
|
+ long startTime;
|
|
|
+ foreach (var item in EverydaySaleCfgArray.Instance.dataArray)
|
|
|
+ {
|
|
|
+ if(item.openTime == "" || item.openTime == null)
|
|
|
+ {
|
|
|
+ listIndex.Add(giftBagList[count]);
|
|
|
+ count++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ endTime = TimeUtil.DateTimeToTimestamp(item.endTime);
|
|
|
+ startTime = TimeUtil.DateTimeToTimestamp(item.openTime);
|
|
|
+ if (startTime <= TimeHelper.ServerNow() && endTime > TimeHelper.ServerNow())
|
|
|
+ {
|
|
|
+ listIndex.Add(giftBagList[count]);
|
|
|
+ }
|
|
|
+ count++;
|
|
|
+ }
|
|
|
+ }
|
|
|
private void UpdateTime(object param)
|
|
|
{
|
|
|
var activityInfo = EverydaySaleCfgArray.Instance.dataArray[indexItem];
|
|
@@ -219,52 +365,14 @@ namespace GFGGame
|
|
|
}
|
|
|
UI_StoreZGTHitem.ProxyEnd();
|
|
|
}
|
|
|
-
|
|
|
- private void ReturnDiscountTimeSuitIndex()
|
|
|
+ private void ClearItemEff()
|
|
|
{
|
|
|
- int count = 0;
|
|
|
- long endTime;
|
|
|
- long startTime;
|
|
|
- foreach (var item in EverydaySaleCfgArray.Instance.dataArray)
|
|
|
- {
|
|
|
- endTime = TimeUtil.DateTimeToTimestamp(item.endTime);
|
|
|
- startTime = TimeUtil.DateTimeToTimestamp(item.openTime);
|
|
|
- if (startTime <= TimeHelper.ServerNow() && endTime > TimeHelper.ServerNow())
|
|
|
- {
|
|
|
- listIndex.Add(count);
|
|
|
- }
|
|
|
- count++;
|
|
|
- }
|
|
|
- }
|
|
|
- private void UpdateDic()
|
|
|
- {
|
|
|
- for(int i =0;i<giftBagList.Count; i++)
|
|
|
- {
|
|
|
- discountDic.Add(giftBagList[i], originalIdList[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- private void UpdateShopCfg()
|
|
|
- {
|
|
|
- long endTime;
|
|
|
- long startTime;
|
|
|
- for (int i=0;i < EverydaySaleCfgArray.Instance.dataArray.Length;i++)
|
|
|
+ for (int i = 0; i < _effectUIs.Count; i++)
|
|
|
{
|
|
|
- EverydaySaleCfg item = EverydaySaleCfgArray.Instance.dataArray[i];
|
|
|
- endTime = TimeUtil.DateTimeToTimestamp(item.endTime);
|
|
|
- startTime = TimeUtil.DateTimeToTimestamp(item.openTime);
|
|
|
- if (startTime > TimeHelper.ServerNow() || endTime < TimeHelper.ServerNow())
|
|
|
- {
|
|
|
- for(int j =0;j<_shopCfgs.Count;j++)
|
|
|
- {
|
|
|
- if(_shopCfgs[j].id == giftBagList[i])
|
|
|
- {
|
|
|
- int id = _shopCfgs[j].id;
|
|
|
- id = discountDic[id];
|
|
|
- _shopCfgs[j] = ShopCfgArray.Instance.GetCfg(id);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ EffectUIPool.Recycle(_effectUIs[i]);
|
|
|
+ _effectUIs[i] = null;
|
|
|
}
|
|
|
+ _effectUIs.Clear();
|
|
|
}
|
|
|
}
|
|
|
}
|