少年修仙传客户端代码仓库
client_Wu Xijin
2018-08-23 e925aced4b439a2583a86d2924d070373b4a89d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
using System;
using System.Collections;
using System.Collections.Generic;
using TableConfig;
using UnityEngine;
namespace Snxxz.UI
{
    public class OSGiftModel : Model, IPlayerLoginOk, IBeforePlayerDataInitialize, IOpenServerActivity
    {
        public override void Init()
        {
            PlayerDatas.Instance.PlayerDataRefreshInfoEvent += PlayerDataRefreshInfoEvent;
            storeModel.RefreshBuyShopLimitEvent += RefreshBuyShopLimitEvent;
            vipModel.firstChargeRewardEvent += FirstChargeRewardEvent;
            OpenServerActivityCenter.Instance.Register(6, this);
        }
 
        public override void UnInit()
        {
 
        }
 
        public void OnPlayerLoginOk()
        {
            activate = CheckActivate();
            if (onStateUpate != null)
            {
                onStateUpate(6);
            }
        }
 
        public event Action<int> onStateUpate;
 
        public bool activate { get; private set; }
 
        private bool m_GiftGetNotify = false;
        public bool giftGetNotify
        {
            get { return m_GiftGetNotify; }
            set
            {
                m_GiftGetNotify = value;
                OSGiftRedpoint.state = value ? RedPointState.Simple : RedPointState.None;
            }
        }
 
        StoreModel storeModel
        {
            get
            {
                return ModelCenter.Instance.GetModel<StoreModel>();
            }
        }
 
        VipModel vipModel { get { return ModelCenter.Instance.GetModel<VipModel>(); } }
 
        public bool IsOpen
        {
            get
            {
                return CheckActivate();
            }
        }
 
        public bool priorityOpen
        {
            get
            {
                return OSGiftRedpoint.state == RedPointState.Simple;
            }
        }
 
        private void RefreshBuyShopLimitEvent()
        {
            bool _activate = CheckActivate();
            if (activate != _activate)
            {
                activate = _activate;
                if (onStateUpate != null)
                {
                    onStateUpate(6);
                }
            }
        }
 
        private void FirstChargeRewardEvent()
        {
            bool _activate = CheckActivate();
            if (activate != _activate)
            {
                activate = _activate;
                if (onStateUpate != null)
                {
                    onStateUpate(6);
                }
            }
        }
 
        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++)
            {
                var _limit = storeModel.GetBuyShopLimit((uint)_list[i].ID);
                if (_limit == null || _limit.BuyCnt < _list[i].PurchaseNumber[0])
                {
                    return true;
                }
            }
            return false;
        }
 
        private void PlayerDataRefreshInfoEvent(PlayerDataRefresh _type)
        {
            bool _activate = CheckActivate();
            if (_type == PlayerDataRefresh.ChangeCoinPointTotal && activate != _activate)
            {
                activate = _activate;
                if (onStateUpate != null)
                {
                    onStateUpate(6);
                }
            }
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            giftGetNotify = false;
        }
 
        public Redpoint OSGiftRedpoint = new Redpoint(MainRedDot.REDPOINT_OPENSERVER, 20906);
    }
}