|
@@ -1,6 +1,7 @@
|
|
-using FairyGUI;
|
|
|
|
|
|
+using ET;
|
|
|
|
+using FairyGUI;
|
|
using System;
|
|
using System;
|
|
-using System.Collections;
|
|
|
|
|
|
+using System.Collections.Generic;
|
|
using UI.DailyWelfare;
|
|
using UI.DailyWelfare;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
|
@@ -10,9 +11,10 @@ namespace GFGGame
|
|
{
|
|
{
|
|
private UI_LimitedRechargeDBGiftUI _ui;
|
|
private UI_LimitedRechargeDBGiftUI _ui;
|
|
|
|
|
|
- private int _count = 0;
|
|
|
|
private int _minProgressOffset = 6;
|
|
private int _minProgressOffset = 6;
|
|
private int _maxProgressOffset = -8;
|
|
private int _maxProgressOffset = -8;
|
|
|
|
+ private ActivityInfo _activityInfo;
|
|
|
|
+ private ActivityRecharge2Cfg[] _rechargeCfgs;
|
|
|
|
|
|
public override void Dispose()
|
|
public override void Dispose()
|
|
{
|
|
{
|
|
@@ -35,35 +37,44 @@ namespace GFGGame
|
|
viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
|
|
viewAnimationType = EnumViewAnimationType.ZOOM_CENTER;
|
|
|
|
|
|
_ui.m_btnTest.onClick.Add(OnClickBtnTest);
|
|
_ui.m_btnTest.onClick.Add(OnClickBtnTest);
|
|
|
|
+ _rechargeCfgs = ActivityRecharge2CfgArray.Instance.dataArray;
|
|
InitProgressValueList();
|
|
InitProgressValueList();
|
|
|
|
+ InitReward();
|
|
}
|
|
}
|
|
|
|
|
|
protected override void AddEventListener()
|
|
protected override void AddEventListener()
|
|
{
|
|
{
|
|
base.AddEventListener();
|
|
base.AddEventListener();
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.ACTIVITY_REWARD_ADD, UpdateView);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.RED_CHANGE, UpdateView);
|
|
|
|
+ EventAgent.AddEventListener(ConstMessage.ACTIVITY_COUNT_VALUE_CHANGE, UpdateView);
|
|
}
|
|
}
|
|
|
|
|
|
protected override void RemoveEventListener()
|
|
protected override void RemoveEventListener()
|
|
{
|
|
{
|
|
base.RemoveEventListener();
|
|
base.RemoveEventListener();
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.ACTIVITY_REWARD_ADD, UpdateView);
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.RED_CHANGE, UpdateView);
|
|
|
|
+ EventAgent.RemoveEventListener(ConstMessage.ACTIVITY_COUNT_VALUE_CHANGE, UpdateView);
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnShown()
|
|
protected override void OnShown()
|
|
{
|
|
{
|
|
base.OnShown();
|
|
base.OnShown();
|
|
|
|
|
|
- _count = 0;
|
|
|
|
|
|
+ UpdateView();
|
|
UpdateProgress();
|
|
UpdateProgress();
|
|
|
|
+ Timers.inst.Add(1, 0, UpdateTime);
|
|
}
|
|
}
|
|
|
|
|
|
protected override void OnHide()
|
|
protected override void OnHide()
|
|
{
|
|
{
|
|
base.OnHide();
|
|
base.OnHide();
|
|
|
|
+ Timers.inst.Remove(UpdateTime);
|
|
}
|
|
}
|
|
|
|
|
|
private void OnClickBtnTest(EventContext context)
|
|
private void OnClickBtnTest(EventContext context)
|
|
{
|
|
{
|
|
- _count += 10;
|
|
|
|
UpdateProgress();
|
|
UpdateProgress();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -74,6 +85,7 @@ namespace GFGGame
|
|
private void InitProgressValueList()
|
|
private void InitProgressValueList()
|
|
{
|
|
{
|
|
_progressValuePart = new int[_partNum];
|
|
_progressValuePart = new int[_partNum];
|
|
|
|
+ _ui.m_progress.target.max = _rechargeCfgs[_rechargeCfgs.Length - 1].value;
|
|
int max = (int)_ui.m_progress.target.max;
|
|
int max = (int)_ui.m_progress.target.max;
|
|
int average = (int)Mathf.Ceil((float)(_ui.m_progress.target.max / (_partNum - 1)));
|
|
int average = (int)Mathf.Ceil((float)(_ui.m_progress.target.max / (_partNum - 1)));
|
|
|
|
|
|
@@ -85,21 +97,33 @@ namespace GFGGame
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 初始化奖励的UI
|
|
|
|
+ /// </summary>
|
|
|
|
+ private void InitReward()
|
|
|
|
+ {
|
|
|
|
+ // 包子图
|
|
|
|
+
|
|
|
|
+ // 大奖icon
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
private void UpdateProgress()
|
|
private void UpdateProgress()
|
|
{
|
|
{
|
|
int max = (int)_ui.m_progress.target.max;
|
|
int max = (int)_ui.m_progress.target.max;
|
|
|
|
+ long count = _activityInfo.CountValue;
|
|
|
|
|
|
// 确定count的区间
|
|
// 确定count的区间
|
|
- if (_count == 0 || _count == max)
|
|
|
|
|
|
+ if (count == 0 || count == max)
|
|
{
|
|
{
|
|
- _ui.m_progress.target.value = _count;
|
|
|
|
|
|
+ _ui.m_progress.target.value = count;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
int index = 1;
|
|
int index = 1;
|
|
for (; index < _progressValuePart.Length; index++)
|
|
for (; index < _progressValuePart.Length; index++)
|
|
{
|
|
{
|
|
- if (_count < _progressValuePart[index])
|
|
|
|
|
|
+ if (count < _progressValuePart[index])
|
|
{
|
|
{
|
|
--index;
|
|
--index;
|
|
break;
|
|
break;
|
|
@@ -110,15 +134,93 @@ namespace GFGGame
|
|
int minProgressValue = _progressValuePart[index] + _minProgressOffset;
|
|
int minProgressValue = _progressValuePart[index] + _minProgressOffset;
|
|
int maxProgressValue = _progressValuePart[index + 1] + _maxProgressOffset;
|
|
int maxProgressValue = _progressValuePart[index + 1] + _maxProgressOffset;
|
|
|
|
|
|
- if(_count == _progressValuePart[index] || _count == _progressValuePart[index + 1])
|
|
|
|
|
|
+ if (count == _progressValuePart[index] || count == _progressValuePart[index + 1])
|
|
{
|
|
{
|
|
- _ui.m_progress.target.value = _count;
|
|
|
|
|
|
+ _ui.m_progress.target.value = count;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- _ui.m_progress.target.value = Mathf.Clamp(_count, minProgressValue, maxProgressValue);
|
|
|
|
|
|
+ _ui.m_progress.target.value = Mathf.Clamp(count, minProgressValue, maxProgressValue);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 检测玩家是否领取奖励
|
|
|
|
+ UpdateRewardState(index);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void UpdateTime(object param)
|
|
|
|
+ {
|
|
|
|
+ long curTime = TimeHelper.ServerNow();
|
|
|
|
+ long endTime = _activityInfo.EndTime;
|
|
|
|
+ _ui.m_txtTime.text = TimeUtil.FormattingTimeTo_DDHHmm(endTime - curTime);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void UpdateView()
|
|
|
|
+ {
|
|
|
|
+ _activityInfo = ActivityGlobalDataManager.Instance.GetActivityInfoOneByType(ActivityType.DBGift);
|
|
|
|
+ UpdateProgress();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private struct GetState
|
|
|
|
+ {
|
|
|
|
+ public int index;
|
|
|
|
+ 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));
|
|
|
|
+ bonus.target.data = new GetState
|
|
|
|
+ {
|
|
|
|
+ index = i,
|
|
|
|
+ canGet = arrive
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ // 玩家已经达到的奖励
|
|
|
|
+ if (arrive)
|
|
|
|
+ {
|
|
|
|
+ // 已领
|
|
|
|
+ if (_activityInfo.GetRewards.IndexOf(_rechargeCfgs[i].id) > 0)
|
|
|
|
+ {
|
|
|
|
+ bonus.m_imgGot.visible = true;
|
|
|
|
+ bonus.target.touchable = false;
|
|
|
|
+ // 隐藏红点
|
|
|
|
+ RedDotController.Instance.SetComRedDot(bonus.target, false);
|
|
|
|
+ }
|
|
|
|
+ // 未领
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ bonus.m_imgGot.visible = false;
|
|
|
|
+ // 显示红点
|
|
|
|
+ RedDotController.Instance.SetComRedDot(bonus.target, true);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- Debug.LogError("count:" + _count + "," + "progress:" + _ui.m_progress.target.value);
|
|
|
|
|
|
+ bonus.target.onClick.Set(OnClickGift);
|
|
|
|
+ UI_ComProBonus2.ProxyEnd();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void OnClickGift(EventContext eventContext)
|
|
|
|
+ {
|
|
|
|
+ GObject gObject = (GObject)eventContext.data;
|
|
|
|
+ GetState getState = (GetState)gObject.data;
|
|
|
|
+
|
|
|
|
+ if (getState.canGet)
|
|
|
|
+ {
|
|
|
|
+ ActivityGlobalSProxy.ReqGetActivityBonus(_activityInfo.ActivityId, _rechargeCfgs[getState.index].id).Coroutine();
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // 显示奖励详细列表
|
|
|
|
+ //ViewManager.Show<UI_GiftDetailUI>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|