|
@@ -36,7 +36,7 @@ namespace GFGGame
|
|
|
this.modal = true;
|
|
|
viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
|
|
|
|
|
|
- _ui.m_btnTest.onClick.Add(OnClickBtnTest);
|
|
|
+ _ui.m_btnTest.onClick.Add(OnBtnTestClick);
|
|
|
_rechargeCfgs = ActivityRecharge2CfgArray.Instance.dataArray;
|
|
|
InitProgressValueList();
|
|
|
InitReward();
|
|
@@ -46,7 +46,6 @@ namespace GFGGame
|
|
|
{
|
|
|
base.AddEventListener();
|
|
|
EventAgent.AddEventListener(ConstMessage.ACTIVITY_REWARD_ADD, UpdateView);
|
|
|
- EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateView);
|
|
|
EventAgent.AddEventListener(ConstMessage.ACTIVITY_COUNT_VALUE_CHANGE, UpdateView);
|
|
|
}
|
|
|
|
|
@@ -54,7 +53,6 @@ namespace GFGGame
|
|
|
{
|
|
|
base.RemoveEventListener();
|
|
|
EventAgent.RemoveEventListener(ConstMessage.ACTIVITY_REWARD_ADD, UpdateView);
|
|
|
- EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateView);
|
|
|
EventAgent.RemoveEventListener(ConstMessage.ACTIVITY_COUNT_VALUE_CHANGE, UpdateView);
|
|
|
}
|
|
|
|
|
@@ -63,7 +61,7 @@ namespace GFGGame
|
|
|
base.OnShown();
|
|
|
|
|
|
UpdateView();
|
|
|
- UpdateProgress();
|
|
|
+ UpdateTime(null);
|
|
|
Timers.inst.Add(1, 0, UpdateTime);
|
|
|
}
|
|
|
|
|
@@ -73,7 +71,7 @@ namespace GFGGame
|
|
|
Timers.inst.Remove(UpdateTime);
|
|
|
}
|
|
|
|
|
|
- private void OnClickBtnTest(EventContext context)
|
|
|
+ private void OnBtnTestClick(EventContext context)
|
|
|
{
|
|
|
UpdateProgress();
|
|
|
}
|
|
@@ -82,6 +80,9 @@ namespace GFGGame
|
|
|
private int[] _progressValuePart;
|
|
|
private int _partNum = 4;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 计算奖励的分段列表
|
|
|
+ /// </summary>
|
|
|
private void InitProgressValueList()
|
|
|
{
|
|
|
_progressValuePart = new int[_partNum];
|
|
@@ -102,25 +103,40 @@ namespace GFGGame
|
|
|
/// </summary>
|
|
|
private void InitReward()
|
|
|
{
|
|
|
- // 包子图
|
|
|
-
|
|
|
- // 大奖icon
|
|
|
+ for (int i = 0; i < _partNum; i++)
|
|
|
+ {
|
|
|
+ GObject gift = _ui.target.GetChild("DBGiftItem" + (i + 1));
|
|
|
+ UI_DBGiftItem item = UI_DBGiftItem.Proxy(gift);
|
|
|
+ // 大奖icon
|
|
|
+ item.m_loaIcon.url = ResPathUtil.GetIconPath(ItemCfgArray.Instance.GetCfg(_rechargeCfgs[i].bonusArr[0][0]));
|
|
|
+ // 包子图
|
|
|
+ item.m_DBB.url = "ui://DailyWelfare/DBB_" + (i + 1);
|
|
|
+ gift.data = _rechargeCfgs[i].bonusArr[0][0];
|
|
|
+ gift.onClick.Add(OnRewardIconClick);
|
|
|
+ UI_DBGiftItem.ProxyEnd();
|
|
|
|
|
|
+ // 进度条分段值Text
|
|
|
+ GObject progressItem = _ui.m_progress.target.GetChild("comProBonus" + i);
|
|
|
+ UI_ComProBonus2 bonus = UI_ComProBonus2.Proxy(progressItem);
|
|
|
+ bonus.m_count.text = _rechargeCfgs[i].value.ToString();
|
|
|
+ UI_ComProBonus2.ProxyEnd();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void UpdateProgress()
|
|
|
{
|
|
|
int max = (int)_ui.m_progress.target.max;
|
|
|
long count = _activityInfo.CountValue;
|
|
|
+ int index = 1;
|
|
|
|
|
|
// 确定count的区间
|
|
|
- if (count == 0 || count == max)
|
|
|
+ if (count == 0 || count >= max)
|
|
|
{
|
|
|
- _ui.m_progress.target.value = count;
|
|
|
+ _ui.m_progress.target.value = Mathf.Min(count, max);
|
|
|
+ index = (count == 0 ? 0 : _partNum - 1);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- int index = 1;
|
|
|
for (; index < _progressValuePart.Length; index++)
|
|
|
{
|
|
|
if (count < _progressValuePart[index])
|
|
@@ -142,10 +158,9 @@ namespace GFGGame
|
|
|
{
|
|
|
_ui.m_progress.target.value = Mathf.Clamp(count, minProgressValue, maxProgressValue);
|
|
|
}
|
|
|
-
|
|
|
- // 检测玩家是否领取奖励
|
|
|
- UpdateRewardState(index);
|
|
|
}
|
|
|
+ // 检测玩家是否领取奖励
|
|
|
+ UpdateRewardState(index);
|
|
|
}
|
|
|
|
|
|
private void UpdateTime(object param)
|
|
@@ -163,24 +178,24 @@ namespace GFGGame
|
|
|
|
|
|
private struct GetState
|
|
|
{
|
|
|
- public int index;
|
|
|
+ public int rewardID;
|
|
|
public bool canGet;
|
|
|
}
|
|
|
+
|
|
|
/// <summary>
|
|
|
- ///
|
|
|
+ /// 更新奖励状态
|
|
|
/// </summary>
|
|
|
/// <param name="index">玩家可领取的最大奖励index</param>
|
|
|
private void UpdateRewardState(int index)
|
|
|
{
|
|
|
- GComponent comProBonusGroup = _ui.m_progress.m_comProBonusGroup.asCom;
|
|
|
-
|
|
|
for(int i = 0; i < _partNum; i++)
|
|
|
{
|
|
|
bool arrive = (i <= index);
|
|
|
- UI_ComProBonus2 bonus = UI_ComProBonus2.Proxy(comProBonusGroup.GetChildAt(i));
|
|
|
+ GObject progressItem = _ui.m_progress.target.GetChild("comProBonus" + i);
|
|
|
+ UI_ComProBonus2 bonus = UI_ComProBonus2.Proxy(progressItem);
|
|
|
bonus.target.data = new GetState
|
|
|
{
|
|
|
- index = i,
|
|
|
+ rewardID = _rechargeCfgs[i].id,
|
|
|
canGet = arrive
|
|
|
};
|
|
|
|
|
@@ -188,7 +203,7 @@ namespace GFGGame
|
|
|
if (arrive)
|
|
|
{
|
|
|
// 已领
|
|
|
- if (_activityInfo.GetRewards.IndexOf(_rechargeCfgs[i].id) > 0)
|
|
|
+ if (_activityInfo.GetRewards.IndexOf(_rechargeCfgs[i].id) >= 0)
|
|
|
{
|
|
|
bonus.m_imgGot.visible = true;
|
|
|
bonus.target.touchable = false;
|
|
@@ -203,26 +218,48 @@ namespace GFGGame
|
|
|
RedDotController.Instance.SetComRedDot(bonus.target, true);
|
|
|
}
|
|
|
}
|
|
|
- bonus.target.onClick.Set(OnClickGift);
|
|
|
+ progressItem.onClick.Set(OnGiftClick);
|
|
|
UI_ComProBonus2.ProxyEnd();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void OnClickGift(EventContext eventContext)
|
|
|
+ /// <summary>
|
|
|
+ /// 点击最下方的礼物icon
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="eventContext"></param>
|
|
|
+ private void OnGiftClick(EventContext eventContext)
|
|
|
{
|
|
|
- GObject gObject = (GObject)eventContext.data;
|
|
|
- GetState getState = (GetState)gObject.data;
|
|
|
+ GObject gObject = eventContext.sender as GObject;
|
|
|
+ GetState getState = (GetState)(gObject.data);
|
|
|
|
|
|
if (getState.canGet)
|
|
|
{
|
|
|
- ActivityGlobalSProxy.ReqGetActivityBonus(_activityInfo.ActivityId, _rechargeCfgs[getState.index].id).Coroutine();
|
|
|
+ ActivityGlobalSProxy.ReqGetActivityBonus(_activityInfo.ActivityId, getState.rewardID).Coroutine();
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
// 显示奖励详细列表
|
|
|
- //ViewManager.Show<UI_GiftDetailUI>
|
|
|
+ ViewManager.Show<GiftDetailView>(getState.rewardID, ViewManager.GetGoBackDatas(typeof(LimitedRechargeDBGiftView).FullName));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 点击上方的奖励icon,显示单个奖励介绍(奖励配置中的第一个奖励)
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="eventContext"></param>
|
|
|
+ private void OnRewardIconClick(EventContext eventContext)
|
|
|
+ {
|
|
|
+ GObject gObject = eventContext.sender as GObject;
|
|
|
+ int id = (int)(gObject.data);
|
|
|
+ GoodsItemTipsController.ShowItemTips(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ public bool CheckOpen()
|
|
|
+ {
|
|
|
+ var activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(ActivityType.DBGift);
|
|
|
+ return activityInfo != null && activityInfo.StartTime <= TimeHelper.ServerNow() &&
|
|
|
+ activityInfo.EndTime > TimeHelper.ServerNow();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|