少年修仙传客户端代码仓库
Client_PangDeRong
2018-11-22 cb0ee4d845b5452beeb2a19dceb4de9ecf191c54
System/OpenServerActivity/OSGiftModel.cs
@@ -8,10 +8,15 @@
    [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);
        }
@@ -36,8 +41,6 @@
        public event Action<int> onStateUpate;
        public event Action onSelectUpdate;
        StoreModel storeModel { get { return ModelCenter.Instance.GetModel<StoreModel>(); } }
        public bool IsOpen
        {
@@ -102,7 +105,7 @@
            {
                gifts.Add(new SuperValueGift()
                {
                    giftId = array[i][0],
                    payType = array[i][0],
                    openDays = array[i][1],
                });
            }
@@ -113,7 +116,7 @@
            }
        }
        private void RefreshBuyShopLimitEvent()
        private void RechargeCountEvent(int id)
        {
            UpdateRedpoint();
        }
@@ -133,7 +136,7 @@
        {
            for (int i = 0; i < gifts.Count; i++)
            {
                if (!IsGiftExist(gifts[i].giftId))
                if (!IsGiftExist(gifts[i].payType))
                {
                    continue;
                }
@@ -142,7 +145,7 @@
            return false;
        }
        public bool IsGiftExist(int _id)
        public bool IsGiftExist(int payType)
        {
            if (startSeconds == 0)
            {
@@ -150,7 +153,7 @@
            }
            var gift = gifts.Find((x) =>
            {
                return x.giftId == _id;
                return x.payType == payType;
            });
            if (!gift.Equals(default(SuperValueGift)))
            {
@@ -162,16 +165,35 @@
            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()
@@ -179,7 +201,7 @@
            alreadyOpens.Clear();
            for (int i = 0; i < gifts.Count; i++)
            {
                if (IsGiftExist(gifts[i].giftId))
                if (IsGiftExist(gifts[i].payType))
                {
                    alreadyOpens.Add(i);
                }
@@ -190,7 +212,7 @@
        {
            for (int i = 0; i < alreadyOpens.Count; i++)
            {
                if (gifts[i].giftId == jumpGiftId)
                if (gifts[i].payType == jumpGiftId)
                {
                    jumpGiftId = 0;
                    return alreadyOpens[i];
@@ -230,7 +252,7 @@
            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;
@@ -240,7 +262,7 @@
        public struct SuperValueGift
        {
            public int giftId;
            public int payType;
            public int openDays;
        }
    }