少年修仙传客户端代码仓库
hch
4 天以前 600733c8f592cb9e65f2b7a3e110ac1d686e6bfe
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
 
 
using LitJson;
using vnxbqy.UI;
using System;
using System.Collections.Generic;
using UnityEngine;
 
class HeroControler : ILModel<HeroControler>
{
    RoleModel roleModel { get { return ModelCenter.Instance.GetModelEx<RoleModel>(); } }
    VipModel vipModel { get { return ModelCenter.Instance.GetModelEx<VipModel>(); } }
 
    Dictionary<int, List<string>> popWinDict = new Dictionary<int, List<string>>();
 
    float popWinLastTime = 0;   //充值界面推送,不做堆栈推送,如有同时多个只推送一个,推送间隔2秒
    protected override void Init()
    {
        GameEvent.playerLoginOkEvent += OnPlayerLoginOk;
        FuncOpen.Instance.OnFuncStateChangeEvent += OnFunctionStateChange;
        MailAllModel.Instance.funcType = MailFuncType.Mail;//邮件不是继承模块导致未初始化问题,在这里初始化
        PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
        ParseConfig();
    }
 
    protected override void UnInit()
    {
        FuncOpen.Instance.OnFuncStateChangeEvent -= OnFunctionStateChange;
        GameEvent.playerLoginOkEvent -= OnPlayerLoginOk;
    }
 
    void ParseConfig()
    {
        var popStr = FuncConfigConfig.Get("RechargePop").Numerical1;
        var dict = JsonMapper.ToObject<Dictionary<string, List<string>>>(popStr);
 
        foreach (var key in dict.Keys)
        {
            popWinDict[int.Parse(key)] = dict[key];
        }
    }
 
 
    public ulong GetMoneyCntIL(int moneyType)
    {
        return UIHelper.GetMoneyCnt(moneyType);
    }
 
    //货币类型对应的0418类型
    public PlayerDataType GetMoneyPlayerDataType(int moneyType)
    {
        switch (moneyType)
        {
 
            case 1:
                {
                    return PlayerDataType.Gold;
                }
            case 2:
                {
                    return PlayerDataType.GoldPaper;
                }
            case 3:
                {
                    return PlayerDataType.Silver;
                }
            case 32:
                {
                    //环保值
                    return PlayerDataType.default4;
                }
        }
        return 0;
    }
 
 
    private void OnFunctionStateChange(int id)
    {
        FuncPush(id);
    }
 
    //参考 RoleModel . OnFuncStateChangeEvent  0 未推送 1已推送
    //功能:是否提醒过  1豪华首充 2无限货币 3 在线特惠 4 1元30倍 5 玩法前瞻 6 战场召集 7跨服64排位 8 跨服天梯
    public void FuncPush(int id)
    {
        if (id == 203)
        {
            //var result = FuncAwardModel.Instance.TryGetAwardState(48);
            //roleModel.funcInfo[5] = result == -1 ? 1 : result;
        }
        else if (id == 208)
        {
            if (ILCrossServerModel.Instance.IsOpen())
            {
                roleModel.funcInfo[6] = ILCrossServerModel.Instance.newCallMark == Int2.zero ? 1 : 0;
            }
        }
        else if (id == 210)
        {
            if (FuncOpen.Instance.IsFuncOpen(210) && CrossServerQualifyingModel.Instance.nowGroupMark != 0)
            {
                roleModel.funcInfo[7] = 0;
            }
        }
        else if (id == 157)
        {
            if (CrossServerOneVsOnePKSeason.Instance.isSatisfyMatch && 
                CrossServerOneVsOnePlayerInfo.Instance.GetDayRemainNum() > 0)
            {
                roleModel.funcInfo[8] = 0;
            }
        }
    }
 
    List<int> funcPushIDS = new List<int>() { 157, 208, 210 };
 
    void OnPlayerLoginOk()
    {
        popWinLastTime = 0;
        for (int i = 0; i < funcPushIDS.Count; i++)
        {
            FuncPush(funcPushIDS[i]);
        }
    }
 
    public void FuncPushGoto(int id)
    {
        if (id == 6)
        {
            if (ILCrossServerModel.Instance.newCallMark == Int2.zero)
            {
                WindowCenter.Instance.OpenEx<CrossServerWin>(false, 3);
                return;
            }
            var callMark = new Int3(ILCrossServerModel.Instance.newCallMark.x, ILCrossServerModel.Instance.newCallMark.y, 1);
            ILCrossServerModel.Instance.selectJumpIndex = ILCrossServerModel.Instance.crossBattleFieldOpenTimes.IndexOf(callMark) + 1;
            WindowCenter.Instance.OpenEx<CrossServerWin>(false, 3);
        }
        else if (id == 7)
        {
            WindowCenter.Instance.OpenIL<CrossServerQualifyingWin>();
        }
        else if (id == 8)
        {
            WindowCenter.Instance.Open<CrossServerWin>(false, 0);
        }
    }
 
    public void FuncPushClose(int id)
    {
 
    }
 
    //性别 0男1女
    public int GetGender(int job)
    {
        if (job == 2)
            return 1;
 
        return 0;
    }
 
    
    private void PlayerDataRefreshEvent(PlayerDataType dataType)
    {
        if (dataType == PlayerDataType.LV)
        {
 
            if (popWinDict.ContainsKey(PlayerDatas.Instance.baseData.LV))
            {
                VipModel.RechargeCount rechargeCount;
                vipModel.TryGetRechargeCount(int.Parse(popWinDict[PlayerDatas.Instance.baseData.LV][0]), out rechargeCount);
                if (rechargeCount.totalCount > 0) return;
 
                if (Time.time - popWinLastTime < 2)
                    return;
 
                //WindowCenter.Instance.Open(popWinDict[PlayerDatas.Instance.baseData.LV][1], false, int.Parse(popWinDict[PlayerDatas.Instance.baseData.LV][2]));
 
                PopupWindowsProcessor.Instance.Add(popWinDict[PlayerDatas.Instance.baseData.LV][1], int.Parse(popWinDict[PlayerDatas.Instance.baseData.LV][2]));
                popWinLastTime = Time.time;
            }
        }
    }
 
 
    //客户端坐标和服务端坐标 需要通过计算获得
    //获取客户端坐标
    public Vector2 GetClientPos(int posX, int posY)
    {
        return new Vector2((posX - GA_Hero.MapOffset.x) * .5f, (posY - GA_Hero.MapOffset.y) * .5f);
    }
}