少年修仙传客户端代码仓库
client_linchunjie
2019-04-17 f1f2599ba0e6b64358ffef7ae5c9f9af3ed8b8b4
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
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Snxxz.UI
{
    [XLua.LuaCallCSharp]
    [XLua.Hotfix]
    public class RuneResolveModel : Model, IBeforePlayerDataInitialize, IPlayerLoginOk
    {
        Dictionary<int, float> m_RuneBaseResolveSplinters;
 
        public List<ushort> resolveItems = new List<ushort>();
        public List<Transform> resolveObjs = new List<Transform>();
        public List<int> itemIndexs = new List<int>();
        public Dictionary<int, bool> resolveSigns = new Dictionary<int, bool>();
 
        bool specialItemColorSign = false;
 
        public readonly Redpoint redpoint = new Redpoint(108, 10802);
 
        public event Action<int> onResolveSelect;
 
        RuneModel runeModel { get { return ModelCenter.Instance.GetModel<RuneModel>(); } }
        VirtualPackModel virtualPackModel { get { return ModelCenter.Instance.GetModel<VirtualPackModel>(); } }
 
        public override void Init()
        {
            ParseConfig();
            StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
            virtualPackModel.virtualPackRefresh += VirtualPackRefresh;
            FuncOpen.Instance.OnFuncStateChangeEvent += OnFuncStateChangeEvent;
        }
 
        public void OnBeforePlayerDataInitialize()
        {
        }
 
        public void OnPlayerLoginOk()
        {
        }
 
        public override void UnInit()
        {
            StageLoad.Instance.onStageLoadFinish -= OnStageLoadFinish;
            virtualPackModel.virtualPackRefresh -= VirtualPackRefresh;
            FuncOpen.Instance.OnFuncStateChangeEvent -= OnFuncStateChangeEvent;
        }
 
        private void OnFuncStateChangeEvent(int id)
        {
            if (id == (int)FuncOpenEnum.Rune)
            {
                RefreshRedpoint();
            }
        }
 
        private void OnStageLoadFinish()
        {
            if (!(StageLoad.Instance.currentStage is DungeonStage))
            {
                specialItemColorSign = false;
            }
        }
 
        void ParseConfig()
        {
            var config = FuncConfigConfig.Get("RuneExp");
            m_RuneBaseResolveSplinters = ConfigParse.GetDic<int, float>(config.Numerical4);
        }
 
        public bool IsQualitySign(int itemColor)
        {
            if (itemColor == 4)
            {
                return specialItemColorSign;
            }
            var playerId = PlayerDatas.Instance.baseData.PlayerID;
            return LocalSave.GetBool(StringUtility.Contact("RuneBreakSelect_", playerId, "_", itemColor), itemColor == 1);
        }
 
        public bool IsComposeSource(int sourceType)
        {
            if (sourceType == 0 || sourceType == 2)
            {
                return true;
            }
            return false;
        }
 
        public float GetRuneResolveGetSplinters(int id, int level, bool fromCompose = false)
        {
            var result = 0f;
            var config = ItemConfig.Get(id);
            if (config.Type == RuneModel.RUNE_CREAMTYPE)
            {
                return config.EffectValueA1 + config.EffectValueA1;
            }
            for (int i = 1; i <= level; i++)
            {
                if (i == 1 && !fromCompose)
                {
                    result += m_RuneBaseResolveSplinters[config.ItemColor] +
                        m_RuneBaseResolveSplinters[config.ItemColor];
                }
                else
                {
                    result += runeModel.GetLevelUpRequireRuneEssence(id, i - 1);
                }
            }
            return result;
        }
 
        public float GetRuneResolveGetSouls(int id)
        {
            ItemConfig config = ItemConfig.Get(id);
            if (config.Type == RuneModel.RUNE_CREAMTYPE)
            {
                return config.EffectValueA1;
            }
            else
            {
                return m_RuneBaseResolveSplinters[config.ItemColor];
            }
        }
 
        public void SetQualityMark(int itemColor, bool mark)
        {
            if (itemColor == 4)
            {
                specialItemColorSign = mark;
                return;
            }
            var playerId = PlayerDatas.Instance.baseData.PlayerID;
            LocalSave.SetBool(StringUtility.Contact("RuneBreakSelect_", playerId, "_", itemColor), mark);
        }
 
        public void RefreshResolveSelect(int line)
        {
            if (onResolveSelect != null)
            {
                onResolveSelect(line);
            }
        }
 
        private void VirtualPackRefresh(PackType packType)
        {
            if (packType == PackType.RunePack)
            {
                RefreshRedpoint();
            }
        }
 
        void RefreshRedpoint()
        {
            var satisfyResolve = false;
            if (FuncOpen.Instance.IsFuncOpen((int)FuncOpenEnum.Rune))
            {
                if (virtualPackModel.GetPackRemainCount(PackType.RunePack) == 0)
                {
                    satisfyResolve = true;
                }
            }
            redpoint.state = satisfyResolve ? RedPointState.Simple : RedPointState.None;
        }
    }
}