少年修仙传客户端代码仓库
client_Wu Xijin
2019-06-13 033958214c0b16d7e7b93cc821b018c295251867
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
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
 
using UnityEngine;
namespace Snxxz.UI
{
    [XLua.LuaCallCSharp]
    public class TrialDungeonModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        Dictionary<int, Dictionary<int, Item[]>> trialRewardDict = new Dictionary<int, Dictionary<int, Item[]>>();
        Dictionary<int, int> trialDungeonPetHorseLevels = null;
        PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
        DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
        DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
        PetModel petModel { get { return ModelCenter.Instance.GetModel<PetModel>(); } }
        MountModel horseModel { get { return ModelCenter.Instance.GetModel<MountModel>(); } }
 
        bool serverInited = false;
 
        public const int TRIALEXCHANGE_GUIDE = 91;
        public const int TRIALDUNGOEN_MAPID = 60010;
 
        public int trialSweepGradeLimit { get; private set; }
 
        public override void Init()
        {
            ParseConfig();
        }
 
        public void OnBeforePlayerDataInitialize()
        {
            serverInited = false;
        }
 
        public void OnPlayerLoginOk()
        {
            serverInited = true;
        }
 
        void ParseConfig()
        {
            var trialRewards = TrialRewardsConfig.GetValues();
            for (int i = 0; i < trialRewards.Count; i++)
            {
                Dictionary<int, Item[]> dict = null;
                if (!trialRewardDict.TryGetValue(trialRewards[i].lineId, out dict))
                {
                    dict = new Dictionary<int, Item[]>();
                    trialRewardDict.Add(trialRewards[i].lineId, dict);
                }
                var itemsArray = LitJson.JsonMapper.ToObject<int[][]>(trialRewards[i].rewards);
                if (itemsArray != null && itemsArray.Length > 0)
                {
                    Item[] items = new Item[itemsArray.Length];
                    for (int k = 0; k < itemsArray.Length; k++)
                    {
                        items[k] = new Item()
                        {
                            id = itemsArray[k][0],
                            count = itemsArray[k][1],
                        };
                    }
                    dict.Add(trialRewards[i].grade, items);
                }
            }
 
            var funcConfig = FuncConfigConfig.Get("TrialSweepGradeLimit");
            if (funcConfig != null)
            {
                trialSweepGradeLimit = int.Parse(funcConfig.Numerical1);
            }
 
            funcConfig = FuncConfigConfig.Get("MunekadoLockLimit");
            trialDungeonPetHorseLevels = ConfigParse.GetDic<int, int>(funcConfig.Numerical2);
        }
 
        public override void UnInit()
        {
        }
 
        public bool TryGetTrialRewards(int lineId, int grade, out Item[] rewards)
        {
            rewards = null;
            if (trialRewardDict.ContainsKey(lineId))
            {
                if (trialRewardDict[lineId].ContainsKey(grade))
                {
                    rewards = trialRewardDict[lineId][grade];
                    return rewards != null && rewards.Length > 0;
                }
            }
            return false;
        }
 
        public void ProcessTrialError(int error)
        {
            switch (error)
            {
                case 1:
                    SysNotifyMgr.Instance.ShowTip("TrialTokenCountError");
                    break;
                case 2:
                    FuncOpen.Instance.ProcessorFuncErrorTip(88);
                    break;
            }
        }
 
        public bool CompleteTrialFloor(int _lineId)
        {
            DungeonRecord dungeonRecord;
            if (dungeonModel.TryGetRecord(60010, out dungeonRecord))
            {
                if (dungeonRecord.lineGrades != null
                    && dungeonRecord.lineGrades.ContainsKey(_lineId))
                {
                    return dungeonRecord.lineGrades[_lineId] > 0;
                }
            }
            return false;
        }
 
        public int GetDungeonRequirePetHorseLevel(int lineId)
        {
            if (trialDungeonPetHorseLevels.ContainsKey(lineId))
            {
                return trialDungeonPetHorseLevels[lineId];
            }
            return 0;
        }
 
        public int GetPetHorseLevel()
        {
            var level = 0;
            if (petModel._DicPetBack != null)
            {
                foreach (var item in petModel._DicPetBack.Values)
                {
                    level += item.PetClass;
                }
            }
            if (horseModel._DicHorse != null)
            {
                foreach (var item in horseModel._DicHorse.Values)
                {
                    level += item.Lv;
                }
            }
            return level;
        }
    }
}