|
@@ -47,6 +47,11 @@ namespace GFGGame
|
|
|
_ui.m_list.itemRenderer = ListItemRender;
|
|
|
|
|
|
}
|
|
|
+ protected override void AddEventListener()
|
|
|
+ {
|
|
|
+ base.AddEventListener();
|
|
|
+ EventAgent.AddEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
|
|
|
+ }
|
|
|
|
|
|
protected override void OnShown()
|
|
|
{
|
|
@@ -57,7 +62,7 @@ namespace GFGGame
|
|
|
_month = DateTime.Now.Month;
|
|
|
_day = DateTime.Now.Day;
|
|
|
// _ui.m_list.ScrollToView(0);
|
|
|
- UpdateSgignView();
|
|
|
+ UpdateView();
|
|
|
}
|
|
|
|
|
|
protected override void OnHide()
|
|
@@ -65,10 +70,21 @@ namespace GFGGame
|
|
|
_valueBarController.OnHide();
|
|
|
base.OnHide();
|
|
|
}
|
|
|
+ protected override void RemoveEventListener()
|
|
|
+ {
|
|
|
+ base.RemoveEventListener();
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.NUMERIC_CHANGE, UpdateView);
|
|
|
+ }
|
|
|
+
|
|
|
private void OnBtnBackClick()
|
|
|
{
|
|
|
ViewManager.GoBackFrom(typeof(DailyWelfareView).FullName);
|
|
|
}
|
|
|
+ private void UpdateView()
|
|
|
+ {
|
|
|
+ UpdateSgignView();
|
|
|
+ UpdateSupplyView();
|
|
|
+ }
|
|
|
private void UpdateSgignView()
|
|
|
{
|
|
|
_signCount = MathHelper.CountOnes(GameGlobal.myNumericComponent.GetAsInt(NumericType.SignDay));
|
|
@@ -94,14 +110,27 @@ namespace GFGGame
|
|
|
}
|
|
|
_ui.m_list.numItems = signBonusCfgs.Count;
|
|
|
}
|
|
|
- private void OnBtnGetProBonus(EventContext context)
|
|
|
+ private async void OnBtnGetProBonus(EventContext context)
|
|
|
{
|
|
|
GObject obj = context.sender as GObject;
|
|
|
DailySignCfg signCfg = obj.data as DailySignCfg;
|
|
|
+ if (_signCount < signCfg.day || MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.SignReward), signCfg.day))
|
|
|
+ {
|
|
|
+ GoodsItemTipsController.ShowItemTips(signCfg.bonusArr[0][1]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ bool result = await DailyWelfareSProxy.ReqGetSignReward(signCfg.day);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ UpdateSgignView();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
private void UpdateSupplyView()
|
|
|
{
|
|
|
-
|
|
|
+ UpdateReward(_ui.m_comSupply0.target, DailySupplyCfgArray.Instance.dataArray[0].id);
|
|
|
+ UpdateReward(_ui.m_comSupply1.target, DailySupplyCfgArray.Instance.dataArray[1].id);
|
|
|
}
|
|
|
|
|
|
private void ListItemRender(int index, GObject obj)
|
|
@@ -148,7 +177,7 @@ namespace GFGGame
|
|
|
}
|
|
|
if (result)
|
|
|
{
|
|
|
- _ui.m_list.numItems = DailySignCfgArray.Instance.GetCfgsBymonth(_month).Count;
|
|
|
+ _ui.m_list.numItems = DailySignBonusCfgArray.Instance.GetCfgsBymonth(_month).Count;
|
|
|
}
|
|
|
}
|
|
|
private void UpdateReward(GObject obj, int id)
|
|
@@ -157,12 +186,61 @@ namespace GFGGame
|
|
|
|
|
|
UI_ComSupply item = UI_ComSupply.Proxy(obj);
|
|
|
|
|
|
+ long openTime = TimeUtil.GetCurDayTime(TimeUtil.GetDateTime(supplyCfg.openTime).ToString("HH:mm:ss"));
|
|
|
+ long endTime = TimeUtil.GetCurDayTime(TimeUtil.GetDateTime(supplyCfg.endTime).ToString("HH:mm:ss"));
|
|
|
+ item.m_txtTime.text = TimeUtil.FormattingTime6(openTime) + "-" + TimeUtil.FormattingTime6(endTime);
|
|
|
+ if (item.m_comItem.data == null)
|
|
|
+ {
|
|
|
+ item.m_comItem.data = new ItemView(item.m_comItem);
|
|
|
+ }
|
|
|
+ ItemData itemData = ItemUtil.createItemData(supplyCfg.bonusArr[0]);
|
|
|
+ (item.m_comItem.data as ItemView).SetData(itemData);
|
|
|
+ (item.m_comItem.data as ItemView).ShowTips = false;
|
|
|
+ ItemUtil.UpdateItemNeedNum(item.m_comCost, GlobalCfgArray.globalCfg.dailySupplyConsumeArr[0]);
|
|
|
+ item.m_comCost.visible = false;
|
|
|
+
|
|
|
+ if (MathHelper.isBitSet(GameGlobal.myNumericComponent.GetAsInt(NumericType.DailySupplyReward), supplyCfg.id))
|
|
|
+ {
|
|
|
+ item.m_btnGet.title = "已领取";
|
|
|
+ item.m_btnGet.enabled = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ long curTime = TimeHelper.ServerNow();
|
|
|
+ if (curTime < openTime)
|
|
|
+ {
|
|
|
+ item.m_btnGet.title = "领取";
|
|
|
+ item.m_btnGet.enabled = false;
|
|
|
+ }
|
|
|
+ else if (curTime > openTime && curTime < endTime)
|
|
|
+ {
|
|
|
+ item.m_btnGet.title = "领取";
|
|
|
+ item.m_btnGet.enabled = true;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ item.m_comCost.visible = true;
|
|
|
+ item.m_btnGet.title = "补领";
|
|
|
+ item.m_btnGet.enabled = true;
|
|
|
+ }
|
|
|
+ if (item.m_btnGet.data == null)
|
|
|
+ {
|
|
|
+ item.m_btnGet.onClick.Add(OnBtnGetSupplyClick);
|
|
|
+ }
|
|
|
+ item.m_btnGet.data = supplyCfg;
|
|
|
UI_ComSupply.ProxyEnd();
|
|
|
}
|
|
|
- private void ListBonusItemRender(int index, GObject obj)
|
|
|
+ private async void OnBtnGetSupplyClick(EventContext context)
|
|
|
{
|
|
|
-
|
|
|
+ GObject obj = context.sender as GObject;
|
|
|
+ DailySupplyCfg supplyCfg = obj.data as DailySupplyCfg;
|
|
|
+ long openTime = TimeUtil.GetCurDayTime(TimeUtil.GetDateTime(supplyCfg.openTime).ToString("HH:mm:ss"));
|
|
|
+ long endTime = TimeUtil.GetCurDayTime(TimeUtil.GetDateTime(supplyCfg.endTime).ToString("HH:mm:ss"));
|
|
|
+ bool result = await DailyWelfareSProxy.ReqGetSupplyReward(supplyCfg.id);
|
|
|
+ if (result)
|
|
|
+ {
|
|
|
+ UpdateSupplyView();
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|