少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LitJson;
 
namespace vnxbqy.UI
{
    
    public class HeavenBattleInfo : Singleton<HeavenBattleInfo>
 
    {
        public HeavenBattleInfo()
        {
            ResetModel();
        }
 
        public void ResetModel()
        {
            Score1 = 0;
            Score2 = 0;
            TopScore = 0;
            TopName = "";
            battleResultDict.Clear();
            Faction = 0;
            PlayerScore = 0;
            WinCnt = 0;
            getAwardDict.Clear();
            bettingRecordDict.Clear();
        }
 
        #region 仙魔之争的信息
        public int Score1 { get; private set; }   // 仙界阵营积分
 
        public int Score2 { get; private set; }    // 魔界阵营积分
 
        public int TopScore { get; private set; }   // 积分第1名积分
 
        public string TopName { get; private set; }    // 积分第1名名字
 
        private Dictionary<int, int> battleResultDict = new Dictionary<int, int>();// 阶段胜负记录{"0":1,"1":2,"2":3,"3":1}
        public event Action bettingResultAct;
        public void SetHeavenBattleInfo(HAC02_tagGCXMZZInfo info)
        {
            battleResultDict.Clear();
            this.Score1 = (int)info.Score1;
            this.Score2 = (int)info.Score2;
            this.TopScore = (int)info.TopScore;
            this.TopName = info.TopName;
 
            JsonData jsonData = JsonMapper.ToObject(info.StageRecord);
            foreach (var key in jsonData.Keys)
            {
                int index = int.Parse(key);
                int result = int.Parse(jsonData[key].ToString());
                if (!battleResultDict.ContainsKey(index))
                {
                    battleResultDict.Add(index, result);
                }
                else
                {
                    battleResultDict[index] = result;
                }
 
                DebugEx.Log("阶段胜利:" + index + "结果:" + result);
            }
 
            if (bettingResultAct != null)
            {
                bettingResultAct();
            }
        }
 
        public int GetBattleResultByIndex(int index)
        {
            int result = 0;
            battleResultDict.TryGetValue(index, out result);
            return result;
        }
 
        #endregion
 
        #region 仙魔之争玩家信息
        public int Faction { get; private set; }    // 所属阵营
        public int PlayerScore { get; private set; }    // 积分
        public int WinCnt { get; private set; }    // 胜场数
        private Dictionary<int, bool> getAwardDict = new Dictionary<int, bool>();  // 胜场奖励领取记录
        private Dictionary<int, List<int>> bettingRecordDict = new Dictionary<int, List<int>>();  // 押注记录 1 阵营1 2 阵营2
        public event Action bettingRecordAct;
        public void SetHeavenBattlePlayerInfo(HAC03_tagGCXMZZSelfInfo info)
        {
            bettingRecordDict.Clear();
            getAwardDict.Clear();
 
            this.Faction = (int)info.Faction;
            this.PlayerScore = (int)info.Score;
            this.WinCnt = (int)info.WinCnt;
            string awardRecord = info.WinCntAwardRecord.ToString();
            int sumIndex = ModelCenter.Instance.GetModel<HeavenBattleModel>().heavenAwardDict.Count;
            for (int i = 0; i < sumIndex; i++)
            {
                bool isRecord = MathUtility.GetBitValue(info.WinCntAwardRecord, (ushort)i);
                if (isRecord)
                {
                    getAwardDict.Add(i, true);
                }
                else
                {
                    getAwardDict.Add(i, false);
                }
            }
 
            JsonData jsonData = JsonMapper.ToObject(info.BetRecord);
            foreach (var key in jsonData.Keys)
            {
                int index = int.Parse(key);
                if (jsonData[key].IsArray)
                {
                    int betRecord = int.Parse(jsonData[key][0].ToString());
                    int betMoney = int.Parse(jsonData[key][1].ToString());
                    if (!bettingRecordDict.ContainsKey(index))
                    {
                        List<int> betlist = new List<int>();
                        betlist.Add(betRecord);
                        betlist.Add(betMoney);
                        bettingRecordDict.Add(index, betlist);
                    }
                    else
                    {
                        bettingRecordDict[index][0] = betRecord;
                        bettingRecordDict[index][1] = betMoney;
                    }
                }
 
 
            }
 
            if (bettingRecordAct != null)
            {
                bettingRecordAct();
            }
        }
 
        public bool IsGetAwardByIndex(int index)
        {
            bool isGet = false;
            getAwardDict.TryGetValue(index, out isGet);
            return isGet;
        }
 
        public int GetBetRecordByIndex(int index)
        {
            int record = 0;
            List<int> betlist = null;
            bettingRecordDict.TryGetValue(index, out betlist);
            if (betlist != null)
            {
                record = betlist[0];
            }
            return record;
        }
 
        public int GetBetMoneyByIndex(int index)
        {
            int betMoney = 0;
            List<int> betlist = null;
            bettingRecordDict.TryGetValue(index, out betlist);
            if (betlist != null)
            {
                betMoney = betlist[1];
            }
            return betMoney;
        }
        #endregion
 
    }
}