| | |
| | | {
|
| | | public override void Init()
|
| | | {
|
| | | PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
|
| | | ParseConfig();
|
| | | storeModel.RefreshBuyShopLimitEvent += RefreshBuyShopLimitEvent;
|
| | | vipModel.firstChargeRewardEvent += FirstChargeRewardEvent;
|
| | | OpenServerActivityCenter.Instance.Register(6, this);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | | {
|
| | | startSeconds = 0;
|
| | | }
|
| | |
|
| | | public void OnPlayerLoginOk()
|
| | | {
|
| | | activate = CheckActivate();
|
| | | if (onStateUpate != null)
|
| | | {
|
| | | onStateUpate(6);
|
| | |
| | | }
|
| | |
|
| | | public event Action<int> onStateUpate;
|
| | | public event Action timeLimitUpdate;
|
| | | public event Action onSelectUpdate;
|
| | |
|
| | | public bool activate { get; private set; }
|
| | |
|
| | | StoreModel storeModel
|
| | | {
|
| | | get
|
| | | {
|
| | | return ModelCenter.Instance.GetModel<StoreModel>();
|
| | | }
|
| | | }
|
| | |
|
| | | VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
|
| | | StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
| | |
|
| | | public bool IsOpen
|
| | | {
|
| | | get
|
| | | {
|
| | | return CheckActivate();
|
| | | return IsExist();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | get
|
| | | {
|
| | | return OSGiftRedpoint.state == RedPointState.Simple;
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshBuyShopLimitEvent()
|
| | | {
|
| | | bool _activate = CheckActivate();
|
| | | if (activate != _activate)
|
| | | {
|
| | | activate = _activate;
|
| | | if (onStateUpate != null)
|
| | | for (int i = 0; i < redpoints.Count; i++)
|
| | | {
|
| | | onStateUpate(6);
|
| | | if (redpoints[i].state == RedPointState.Simple)
|
| | | {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | UpdateRedpoint();
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | public int timeOverdueGiftId { get; private set; }
|
| | |
|
| | | public bool IsAdvance
|
| | | {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public DateTime overDueTime = DateTime.Now;
|
| | | int m_SelectIndex = 0;
|
| | | public int selectIndex
|
| | | {
|
| | | get { return m_SelectIndex; }
|
| | | set
|
| | | {
|
| | | if (value != m_SelectIndex)
|
| | | {
|
| | | m_SelectIndex = value;
|
| | | if (onSelectUpdate != null)
|
| | | {
|
| | | onSelectUpdate();
|
| | | }
|
| | | }
|
| | | m_SelectIndex = value;
|
| | | }
|
| | | }
|
| | |
|
| | | public int jumpGiftId { get; set; }
|
| | |
|
| | | public List<SuperValueGift> gifts { get; private set; }
|
| | | public List<int> alreadyOpens { get; private set; }
|
| | | void ParseConfig()
|
| | | {
|
| | | gifts = new List<SuperValueGift>();
|
| | | alreadyOpens = new List<int>();
|
| | | var config = Config.Instance.Get<FuncConfigConfig>("SuperGiftTimeList");
|
| | | var array = LitJson.JsonMapper.ToObject<int[][]>(config.Numerical1);
|
| | | for (int i = 0; i < array.Length; i++)
|
| | | {
|
| | | gifts.Add(new SuperValueGift()
|
| | | {
|
| | | giftId = array[i][0],
|
| | | openDays = array[i][1],
|
| | | });
|
| | | }
|
| | |
|
| | | for (int i = 0; i < gifts.Count; i++)
|
| | | {
|
| | | redpoints.Add(new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20906 * 100 + i));
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshBuyShopLimitEvent()
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | public uint startSeconds { get; private set; }
|
| | | public void UpdateTime(HAA16_tagMCSuperGiftInfo package)
|
| | | {
|
| | | timeOverdueGiftId = (int)package.GiftID;
|
| | | overDueTime = ParseOverdueTime(package.EndtDate);
|
| | | bool _activate = CheckActivate();
|
| | | if (activate != _activate)
|
| | | startSeconds = package.StartTime;
|
| | | if (onStateUpate != null)
|
| | | {
|
| | | activate = _activate;
|
| | | if (onStateUpate != null)
|
| | | {
|
| | | onStateUpate(6);
|
| | | }
|
| | | }
|
| | | if (timeLimitUpdate != null)
|
| | | {
|
| | | timeLimitUpdate();
|
| | | onStateUpate(6);
|
| | | }
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | DateTime ParseOverdueTime(string _date)
|
| | | public bool IsExist()
|
| | | {
|
| | | var array = _date.Split('-');
|
| | | var year = int.Parse(array[0]);
|
| | | var month = int.Parse(array[1]);
|
| | | var day = int.Parse(array[2]);
|
| | | var time = new DateTime(year, month, day, 0, 0, 0);
|
| | | return time.AddDays(1);
|
| | | }
|
| | |
|
| | | private void FirstChargeRewardEvent()
|
| | | {
|
| | | bool _activate = CheckActivate();
|
| | | if (activate != _activate)
|
| | | for (int i = 0; i < gifts.Count; i++)
|
| | | {
|
| | | activate = _activate;
|
| | | if (onStateUpate != null)
|
| | | {
|
| | | onStateUpate(6);
|
| | | }
|
| | | }
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
|
| | | public bool CheckActivate()
|
| | | {
|
| | | if (PlayerDatas.Instance.baseData.coinPointTotal == 0
|
| | | || !ModelCenter.Instance.GetModel<VipModel>().firstChargeRewardGet)
|
| | | {
|
| | | return false;
|
| | | }
|
| | | List<StoreConfig> _list = null;
|
| | | StoreConfig.TryGetStoreConfigs((int)StoreFunc.OSGift,out _list);
|
| | | for (int i = 0; i < _list.Count; i++)
|
| | | {
|
| | | if (IsGiftOverdue(_list[i].ID))
|
| | | if (!IsGiftExist(gifts[i].giftId))
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var _limit = storeModel.GetBuyShopLimit((uint)_list[i].ID);
|
| | | if (_limit == null || _limit.BuyCnt < _list[i].PurchaseNumber[0])
|
| | | {
|
| | | return true;
|
| | | }
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public bool IsGiftOverdue(int _id)
|
| | | public bool IsGiftExist(int _id)
|
| | | {
|
| | | if (_id == timeOverdueGiftId)
|
| | | if (startSeconds == 0)
|
| | | {
|
| | | return TimeUtility.ServerNow >= overDueTime;
|
| | | return false;
|
| | | }
|
| | | var gift = gifts.Find((x) =>
|
| | | {
|
| | | return x.giftId == _id;
|
| | | });
|
| | | if (!gift.Equals(default(SuperValueGift)))
|
| | | {
|
| | | var startTime = TimeUtility.GetTime(startSeconds);
|
| | | var endTime = startTime.AddDays(gift.openDays);
|
| | | endTime = new DateTime(endTime.Year, endTime.Month, endTime.Day, 0, 0, 0);
|
| | | return TimeUtility.ServerNow < endTime;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | private void PlayerDataRefreshInfoEvent(PlayerDataRefresh _type)
|
| | | public void SetAreadyOpens()
|
| | | {
|
| | | bool _activate = CheckActivate();
|
| | | if (_type == PlayerDataRefresh.ChangeCoinPointTotal && activate != _activate)
|
| | | alreadyOpens.Clear();
|
| | | for (int i = 0; i < gifts.Count; i++)
|
| | | {
|
| | | activate = _activate;
|
| | | if (onStateUpate != null)
|
| | | if (IsGiftExist(gifts[i].giftId))
|
| | | {
|
| | | onStateUpate(6);
|
| | | alreadyOpens.Add(i);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void OnBeforePlayerDataInitialize()
|
| | | public int GetDefaultSelect()
|
| | | {
|
| | | timeOverdueGiftId = 0;
|
| | | for (int i = 0; i < alreadyOpens.Count; i++)
|
| | | {
|
| | | if (gifts[i].giftId == jumpGiftId)
|
| | | {
|
| | | jumpGiftId = 0;
|
| | | return alreadyOpens[i];
|
| | | }
|
| | | }
|
| | | jumpGiftId = 0;
|
| | | for (int i = 0; i < alreadyOpens.Count; i++)
|
| | | {
|
| | | if (redpoints[alreadyOpens[i]].state == RedPointState.Simple)
|
| | | {
|
| | | return alreadyOpens[i];
|
| | | }
|
| | | }
|
| | | return alreadyOpens[0];
|
| | | }
|
| | |
|
| | | public void SetDayRemind()
|
| | | bool GetDayRemind(int index)
|
| | | {
|
| | | if (OSGiftRedpoint.state == RedPointState.Simple)
|
| | | return LocalSave.GetInt(StringUtility.Contact("OSGift_", index, "_",
|
| | | PlayerDatas.Instance.baseData.PlayerID), 0) == TimeUtility.Day;
|
| | | }
|
| | |
|
| | | public void SetDayRemind(int index)
|
| | | {
|
| | | if (redpoints[index].state == RedPointState.Simple)
|
| | | {
|
| | | DayRemind.Instance.SetDayRemind(DayRemind.OSGIFT_REDPOINT, true);
|
| | | LocalSave.SetInt(StringUtility.Contact("OSGift_", index, "_",
|
| | | PlayerDatas.Instance.baseData.PlayerID), TimeUtility.Day);
|
| | | UpdateRedpoint();
|
| | | }
|
| | | }
|
| | |
|
| | | List<Redpoint> redpoints = new List<Redpoint>();
|
| | |
|
| | | void UpdateRedpoint()
|
| | | {
|
| | | OSGiftRedpoint.state = RedPointState.None;
|
| | | if (CheckActivate() && !DayRemind.Instance.GetDayRemind(DayRemind.OSGIFT_REDPOINT))
|
| | | for (int i = 0; i < redpoints.Count; i++)
|
| | | {
|
| | | OSGiftRedpoint.state = RedPointState.Simple;
|
| | | redpoints[i].state = RedPointState.None;
|
| | | if (IsGiftExist(gifts[i].giftId) && !IsGiftBuy(gifts[i].giftId)
|
| | | && !GetDayRemind(i))
|
| | | {
|
| | | redpoints[i].state = RedPointState.Simple;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public Redpoint OSGiftRedpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20906);
|
| | | public struct SuperValueGift
|
| | | {
|
| | | public int giftId;
|
| | | public int openDays;
|
| | | }
|
| | | }
|
| | | } |
| | | |