| | |
| | | [XLua.LuaCallCSharp]
|
| | | public class OSGiftModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize, IOpenServerActivity
|
| | | {
|
| | | VipModel vipModel
|
| | | {
|
| | | get { return ModelCenter.Instance.GetModel<VipModel>(); }
|
| | | }
|
| | |
|
| | | public override void Init()
|
| | | {
|
| | | ParseConfig();
|
| | | storeModel.RefreshBuyShopLimitEvent += RefreshBuyShopLimitEvent;
|
| | | vipModel.rechargeCountEvent += RechargeCountEvent;
|
| | | OpenServerActivityCenter.Instance.Register(6, this);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | public event Action<int> onStateUpate;
|
| | | public event Action onSelectUpdate;
|
| | |
|
| | | StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
|
| | |
|
| | | public bool IsOpen
|
| | | {
|
| | |
| | | {
|
| | | gifts.Add(new SuperValueGift()
|
| | | {
|
| | | giftId = array[i][0],
|
| | | payType = array[i][0],
|
| | | openDays = array[i][1],
|
| | | });
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshBuyShopLimitEvent()
|
| | | private void RechargeCountEvent(int id)
|
| | | {
|
| | | UpdateRedpoint();
|
| | | }
|
| | |
| | | {
|
| | | for (int i = 0; i < gifts.Count; i++)
|
| | | {
|
| | | if (!IsGiftExist(gifts[i].giftId))
|
| | | if (!IsGiftExist(gifts[i].payType))
|
| | | {
|
| | | continue;
|
| | | }
|
| | |
| | | return false;
|
| | | }
|
| | |
|
| | | public bool IsGiftExist(int _id)
|
| | | public bool IsGiftExist(int payType)
|
| | | {
|
| | | if (startSeconds == 0)
|
| | | {
|
| | |
| | | }
|
| | | var gift = gifts.Find((x) =>
|
| | | {
|
| | | return x.giftId == _id;
|
| | | return x.payType == payType;
|
| | | });
|
| | | if (!gift.Equals(default(SuperValueGift)))
|
| | | {
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | public bool IsGiftBuy(int _id)
|
| | | public bool IsGiftBuy(int payType)
|
| | | {
|
| | | var _limit = storeModel.GetBuyShopLimit((uint)_id);
|
| | | var config = Config.Instance.Get<StoreConfig>(_id);
|
| | | if (_limit != null && config != null
|
| | | && _limit.BuyCnt >= config.PurchaseNumber[0])
|
| | | var rechargeId = GetRechargeId(payType);
|
| | | if (rechargeId != 0)
|
| | | {
|
| | | return true;
|
| | | VipModel.RechargeCount rechargeCount;
|
| | | if (vipModel.TryGetRechargeCount(rechargeId, out rechargeCount))
|
| | | {
|
| | | return rechargeCount.todayCount >= 1;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | public int GetRechargeId(int payType)
|
| | | {
|
| | | var list = vipModel.GetCTGConfigs(VersionConfig.Get().appId);
|
| | | if (list != null)
|
| | | {
|
| | | for (int i = 0; i < list.Count; i++)
|
| | | {
|
| | | var config = Config.Instance.Get<CTGConfig>(list[i]);
|
| | | if (config != null && config.PayType == payType)
|
| | | {
|
| | | return config.RecordID;
|
| | | }
|
| | | }
|
| | | }
|
| | | return 0;
|
| | | }
|
| | |
|
| | | public void SetAreadyOpens()
|
| | |
| | | alreadyOpens.Clear();
|
| | | for (int i = 0; i < gifts.Count; i++)
|
| | | {
|
| | | if (IsGiftExist(gifts[i].giftId))
|
| | | if (IsGiftExist(gifts[i].payType))
|
| | | {
|
| | | alreadyOpens.Add(i);
|
| | | }
|
| | |
| | | {
|
| | | for (int i = 0; i < alreadyOpens.Count; i++)
|
| | | {
|
| | | if (gifts[i].giftId == jumpGiftId)
|
| | | if (gifts[i].payType == jumpGiftId)
|
| | | {
|
| | | jumpGiftId = 0;
|
| | | return alreadyOpens[i];
|
| | |
| | | for (int i = 0; i < redpoints.Count; i++)
|
| | | {
|
| | | redpoints[i].state = RedPointState.None;
|
| | | if (IsGiftExist(gifts[i].giftId) && !IsGiftBuy(gifts[i].giftId)
|
| | | if (IsGiftExist(gifts[i].payType) && !IsGiftBuy(gifts[i].payType)
|
| | | && !GetDayRemind(i))
|
| | | {
|
| | | redpoints[i].state = RedPointState.Simple;
|
| | |
| | |
|
| | | public struct SuperValueGift
|
| | | {
|
| | | public int giftId;
|
| | | public int payType;
|
| | | public int openDays;
|
| | | }
|
| | | }
|