三国卡牌客户端基础资源仓库
yyl
1 天以前 cec146fc3fe287928e075c79ece20a20a9b16b20
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
//--------------------------------------------------------
//    [Author]:           Fish
//    [  Date ]:           Friday, October 23, 2020
//--------------------------------------------------------
 
using System.Collections.Generic;
using System.IO;
using System;
using UnityEngine;
 
namespace LaunchCommon
{
 
    public class InitialFunctionConfig
    {
 
        public readonly string KEY;
        public readonly string Numerical1;
        public readonly string Numerical2;
        public readonly string Numerical3;
        public readonly string Numerical4;
        public readonly string Numerical5;
 
        public InitialFunctionConfig()
        {
        }
 
        public InitialFunctionConfig(string input)
        {
            try
            {
                var tables = input.Split('\t');
 
                KEY = tables[0];
 
                Numerical1 = tables[1];
 
                Numerical2 = tables[2];
 
                Numerical3 = tables[3];
 
                Numerical4 = tables[4];
 
                Numerical5 = tables[5];
            }
            catch (Exception ex)
            {
                Debug.Log(ex);
            }
        }
 
        static Dictionary<string, InitialFunctionConfig> configs = new Dictionary<string, InitialFunctionConfig>();
        public static InitialFunctionConfig Get(string id)
        {
            if (!inited)
            {
                Debug.LogError("InitialFunctionConfig 还未完成初始化。");
                return null;
            }
 
            if (configs.ContainsKey(id))
            {
                return configs[id];
            }
 
            InitialFunctionConfig config = null;
            if (rawDatas.ContainsKey(id))
            {
                config = configs[id] = new InitialFunctionConfig(rawDatas[id]);
                rawDatas.Remove(id);
            }
 
            return config;
        }
 
        public static InitialFunctionConfig Get(int id)
        {
            return Get(id.ToString());
        }
 
        public static List<string> GetKeys()
        {
            var keys = new List<string>();
            keys.AddRange(configs.Keys);
            keys.AddRange(rawDatas.Keys);
            return keys;
        }
 
        public static List<InitialFunctionConfig> GetValues()
        {
            var values = new List<InitialFunctionConfig>();
            values.AddRange(configs.Values);
 
            var keys = new List<string>(rawDatas.Keys);
            foreach (var key in keys)
            {
                values.Add(Get(key));
            }
 
            return values;
        }
 
        public static bool Has(string id)
        {
            return configs.ContainsKey(id) || rawDatas.ContainsKey(id);
        }
 
        public static bool Has(int id)
        {
            return Has(id.ToString());
        }
 
        public static bool inited { get; private set; }
        protected static Dictionary<string, string> rawDatas = new Dictionary<string, string>();
        public static void Init(string content)
        {
            inited = false;
            configs.Clear();
            using (StringReader reader = new StringReader(content))
            {
                string line;
                int lineIndex = 0;
                while ((line = reader.ReadLine()) != null)
                {
                    lineIndex++;
                    if (lineIndex <= 3)
                    {
                        continue;
                    }
                    try
                    {
                        var index = line.IndexOf("\t");
                        if (index == -1)
                        {
                            continue;
                        }
                        var id = line.Substring(0, index);
 
                        rawDatas[id] = line;
                    }
                    catch (System.Exception ex)
                    {
                        Debug.LogError(ex);
                    }
                }
            }
            inited = true;
            Debug.Log("InitialFunctionConfig Init Finished line = " + rawDatas.Count);
        }
 
    }
}