| | |
| | | //--------------------------------------------------------
|
| | | // [Author]: 第二世界
|
| | | // [ Date ]: Tuesday, February 12, 2019
|
| | | // [Author]: Fish
|
| | | // [ Date ]: Thursday, February 14, 2019
|
| | | //--------------------------------------------------------
|
| | |
|
| | | using UnityEngine;
|
| | | using System.Collections.Generic;
|
| | | using System.IO;
|
| | | using System.Threading;
|
| | | using System;
|
| | | using UnityEngine;
|
| | |
|
| | | namespace TableConfig {
|
| | | [XLua.LuaCallCSharp]
|
| | | public partial class TreasurePrivilegeConfig
|
| | | {
|
| | |
|
| | | |
| | | public partial class TreasurePrivilegeConfig : ConfigBase {
|
| | | public readonly int PrivilegeID;
|
| | | public readonly string Description;
|
| | | public readonly string EffectValue;
|
| | | public readonly int singleValue;
|
| | | public readonly int maxValue;
|
| | | public readonly string attr;
|
| | | public readonly string itemAward;
|
| | | public readonly int[] successList;
|
| | | public readonly int treasureId;
|
| | | public readonly int sort;
|
| | | public readonly string Icon;
|
| | | public readonly string Name;
|
| | | public readonly string targetDescription;
|
| | | public readonly int effectId;
|
| | |
|
| | | public int PrivilegeID;
|
| | | public string Description;
|
| | | public string EffectValue;
|
| | | public int singleValue;
|
| | | public int maxValue;
|
| | | public string attr;
|
| | | public string itemAward;
|
| | | public int[] successList;
|
| | | public int treasureId;
|
| | | public int sort;
|
| | | public string Icon;
|
| | | public string Name;
|
| | | public string targetDescription;
|
| | | public int effectId;
|
| | | public TreasurePrivilegeConfig()
|
| | | {
|
| | | }
|
| | |
|
| | | public override string getKey()
|
| | | public TreasurePrivilegeConfig(string input)
|
| | | {
|
| | | try
|
| | | {
|
| | | return PrivilegeID.ToString();
|
| | | var tables = input.Split('\t');
|
| | |
|
| | | int.TryParse(tables[0],out PrivilegeID); |
| | |
|
| | | Description = tables[1];
|
| | |
|
| | | EffectValue = tables[2];
|
| | |
|
| | | int.TryParse(tables[3],out singleValue); |
| | |
|
| | | int.TryParse(tables[4],out maxValue); |
| | |
|
| | | attr = tables[5];
|
| | |
|
| | | itemAward = tables[6];
|
| | |
|
| | | string[] successListStringArray = tables[7].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); |
| | | successList = new int[successListStringArray.Length]; |
| | | for (int i=0;i<successListStringArray.Length;i++) |
| | | { |
| | | int.TryParse(successListStringArray[i],out successList[i]); |
| | | }
|
| | |
|
| | | int.TryParse(tables[8],out treasureId); |
| | |
|
| | | int.TryParse(tables[9],out sort); |
| | |
|
| | | Icon = tables[10];
|
| | |
|
| | | Name = tables[11];
|
| | |
|
| | | targetDescription = tables[12];
|
| | |
|
| | | int.TryParse(tables[13],out effectId); |
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | DebugEx.Log(ex);
|
| | | }
|
| | | }
|
| | |
|
| | | static Dictionary<string, TreasurePrivilegeConfig> configs = new Dictionary<string, TreasurePrivilegeConfig>();
|
| | | public static TreasurePrivilegeConfig Get(string id)
|
| | | { |
| | | if (!inited)
|
| | | {
|
| | | Debug.Log("TreasurePrivilegeConfig 还未完成初始化。");
|
| | | return null;
|
| | | }
|
| | | |
| | | if (configs.ContainsKey(id))
|
| | | {
|
| | | return configs[id];
|
| | | }
|
| | |
|
| | | public override void Parse(string content) {
|
| | | try
|
| | | {
|
| | | var contents = content.Split('\t');
|
| | | TreasurePrivilegeConfig config = null;
|
| | | if (rawDatas.ContainsKey(id))
|
| | | {
|
| | | config = configs[id] = new TreasurePrivilegeConfig(rawDatas[id]);
|
| | | rawDatas.Remove(id);
|
| | | }
|
| | |
|
| | | int.TryParse(contents[0],out PrivilegeID);
|
| | | |
| | | Description = contents[1];
|
| | | |
| | | EffectValue = contents[2];
|
| | | |
| | | int.TryParse(contents[3],out singleValue);
|
| | | |
| | | int.TryParse(contents[4],out maxValue);
|
| | | |
| | | attr = contents[5];
|
| | | |
| | | itemAward = contents[6];
|
| | | |
| | | var successListStringArray = contents[7].Trim().Split(StringUtility.splitSeparator,StringSplitOptions.RemoveEmptyEntries); |
| | | successList = new int[successListStringArray.Length]; |
| | | for (int i=0;i<successListStringArray.Length;i++) |
| | | { |
| | | int.TryParse(successListStringArray[i],out successList[i]); |
| | | }
|
| | | |
| | | int.TryParse(contents[8],out treasureId);
|
| | | |
| | | int.TryParse(contents[9],out sort);
|
| | | |
| | | Icon = contents[10];
|
| | | |
| | | Name = contents[11];
|
| | | |
| | | targetDescription = contents[12];
|
| | | |
| | | int.TryParse(contents[13],out effectId);
|
| | | }
|
| | | catch (Exception ex)
|
| | | return config;
|
| | | }
|
| | |
|
| | | public static TreasurePrivilegeConfig 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<TreasurePrivilegeConfig> GetValues()
|
| | | {
|
| | | var values = new List<TreasurePrivilegeConfig>();
|
| | | 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(bool sync=false)
|
| | | {
|
| | | inited = false;
|
| | | var path = string.Empty;
|
| | | if (AssetSource.refdataFromEditor)
|
| | | {
|
| | | path = ResourcesPath.CONFIG_FODLER +"/TreasurePrivilege.txt";
|
| | | }
|
| | | else
|
| | | {
|
| | | path = AssetVersionUtility.GetAssetFilePath("config/TreasurePrivilege.txt");
|
| | | }
|
| | |
|
| | | var tempConfig = new TreasurePrivilegeConfig();
|
| | | var preParse = tempConfig is IConfigPostProcess;
|
| | |
|
| | | if (sync)
|
| | | {
|
| | | var lines = File.ReadAllLines(path);
|
| | | if (!preParse)
|
| | | {
|
| | | DebugEx.Log(ex);
|
| | | rawDatas = new Dictionary<string, string>(lines.Length - 3);
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | | for (int i = 3; i < lines.Length; i++)
|
| | | {
|
| | | try |
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | if (index == -1)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var id = line.Substring(0, index);
|
| | |
|
| | | if (preParse)
|
| | | {
|
| | | var config = new TreasurePrivilegeConfig(line);
|
| | | configs[id] = config;
|
| | | (config as IConfigPostProcess).OnConfigParseCompleted();
|
| | | }
|
| | | else
|
| | | {
|
| | | rawDatas[id] = line;
|
| | | }
|
| | | }
|
| | | catch (System.Exception ex)
|
| | | {
|
| | | Debug.LogError(ex);
|
| | | }
|
| | | }
|
| | | inited = true;
|
| | | }
|
| | | else
|
| | | {
|
| | | ThreadPool.QueueUserWorkItem((object _object) =>
|
| | | {
|
| | | var lines = File.ReadAllLines(path);
|
| | | if (!preParse)
|
| | | {
|
| | | rawDatas = new Dictionary<string, string>(lines.Length - 3);
|
| | | }
|
| | | for (int i = 3; i < lines.Length; i++)
|
| | | {
|
| | | try |
| | | {
|
| | | var line = lines[i];
|
| | | var index = line.IndexOf("\t");
|
| | | if (index == -1)
|
| | | {
|
| | | continue;
|
| | | }
|
| | | var id = line.Substring(0, index);
|
| | |
|
| | | if (preParse)
|
| | | {
|
| | | var config = new TreasurePrivilegeConfig(line);
|
| | | configs[id] = config;
|
| | | (config as IConfigPostProcess).OnConfigParseCompleted();
|
| | | }
|
| | | else
|
| | | {
|
| | | rawDatas[id] = line;
|
| | | }
|
| | | }
|
| | | catch (System.Exception ex)
|
| | | {
|
| | | Debug.LogError(ex);
|
| | | }
|
| | | }
|
| | |
|
| | | inited = true;
|
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|