| | |
| | | using UnityEngine;
|
| | | using System.Threading;
|
| | |
|
| | | public class ConfigManager : Singleton<ConfigManager>
|
| | | public class Config : Singleton<Config>
|
| | | {
|
| | | public static string CustomIV = "4vHKRj3yfzU=";
|
| | | public static string CustomKey = "xhVs6DRXLfUGxw+AhtfQdpQGoa+8SA9d";
|
| | |
|
| | | protected string[] lineStep = new string[] { "\r\n" }; //行间隔体
|
| | | protected string[] rowStep = new string[] { "\t" }; //段间隔体
|
| | |
|
| | | bool isPlaying = true;
|
| | |
|
| | | bool m_Inited = false;
|
| | | public bool inited {
|
| | | public bool inited
|
| | | {
|
| | | get { return m_Inited; }
|
| | | private set { m_Inited = value; }
|
| | | }
|
| | |
| | | AddAsyncTask<IconConfig>();
|
| | | AddAsyncTask<ItemConfig>();
|
| | | AddAsyncTask<SkillConfig>();
|
| | | AddAsyncTask<DirtyNameConfig>();
|
| | | AddAsyncTask<TASKINFOConfig>();
|
| | | AddAsyncTask<mapnpcConfig>();
|
| | | AddAsyncTask<LoginSeverListConfig>();
|
| | | AddAsyncTask<DienstgradConfig>();
|
| | |
| | | AddAsyncTask<ItemPlusConfig>();
|
| | | AddAsyncTask<ItemPlusMaxConfig>();
|
| | | AddAsyncTask<PyTaskConfig>();
|
| | | AddAsyncTask<TASKINFOConfig>();
|
| | | AddAsyncTask<MailConfig>();
|
| | | AddAsyncTask<RuneTowerConfig>();
|
| | | AddAsyncTask<EquipWashConfig>();
|
| | |
| | | AddAsyncTask<AllPeoplePartyAwardConfig>();
|
| | | AddAsyncTask<OrderInfoConfig>();
|
| | | AddAsyncTask<TrialExchangeConfig>();
|
| | | AddAsyncTask<DogzDungeonConfig>();
|
| | | AddAsyncTask<TrialRewardsConfig>();
|
| | | AddAsyncTask<DogzEquipPlusConfig>();
|
| | | AddAsyncTask<FairyGrabBossConfig>();
|
| | | AddAsyncTask<DungeonSpecialStateTimeConfig>();
|
| | | AddAsyncTask<DailyQuestSpecialOpenTimeConfig>();
|
| | |
|
| | | while (!AllCompleted())
|
| | | {
|
| | |
| | | StartSyncTask<IconConfig>(AssetPath.ResourceOut);
|
| | | StartSyncTask<SysInfoConfig>(AssetPath.ResourceOut);
|
| | | StartSyncTask<LanguageConfig>(AssetPath.ResourceOut);
|
| | | StartSyncTask<RealmConfig>(AssetPath.ResourceOut);
|
| | | }
|
| | |
|
| | | public bool AllCompleted()
|
| | |
| | | switch (Application.platform)
|
| | | {
|
| | | case RuntimePlatform.Android:
|
| | | if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 3.5f * 1024)
|
| | | if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 3.2f * 1024)
|
| | | {
|
| | | return 4;
|
| | | }
|
| | |
| | | switch (Application.platform)
|
| | | {
|
| | | case RuntimePlatform.Android:
|
| | | if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 3.5f * 1024)
|
| | | if (DeviceUtility.cpu >= 4 && DeviceUtility.memory > 3.2f * 1024)
|
| | | {
|
| | | return 20;
|
| | | }
|
| | |
| | | }
|
| | | else
|
| | | {
|
| | | path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, "config/", fileName, ".bytes");
|
| | | path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, "config/", fileName, ".txt");
|
| | | }
|
| | |
|
| | | var task = new ConfigTask(typeof(T), AssetSource.refdataFromEditor ? AssetPath.ResourceOut : AssetPath.External, path);
|
| | |
| | | (object _obj) =>
|
| | | {
|
| | | string[] lines = null;
|
| | | StreamReader sr = null;
|
| | |
|
| | | try
|
| | | {
|
| | | if (_task.assetPath == AssetPath.ResourceOut)
|
| | | {
|
| | | var fileInfo = new FileInfo(_task.filePath);
|
| | | var fs = fileInfo.OpenRead();
|
| | | sr = new StreamReader(fs, Encoding.UTF8);
|
| | | var content = sr.ReadToEnd();
|
| | | lines = content.Split(lineStep, StringSplitOptions.None);
|
| | | }
|
| | | else if (_task.assetPath == AssetPath.External)
|
| | | {
|
| | | var tripleDESCryptoServiceProvider = new TripleDESCryptoServiceProvider();
|
| | | tripleDESCryptoServiceProvider.Key = Convert.FromBase64String(CustomKey);
|
| | | tripleDESCryptoServiceProvider.IV = Convert.FromBase64String(CustomIV);
|
| | | tripleDESCryptoServiceProvider.Mode = CipherMode.CBC;
|
| | | tripleDESCryptoServiceProvider.Padding = PaddingMode.PKCS7;
|
| | | var decryptor = tripleDESCryptoServiceProvider.CreateDecryptor();
|
| | |
|
| | | var expectedSteam = new FileStream(_task.filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
| | | var bytes = new byte[expectedSteam.Length];
|
| | | expectedSteam.Read(bytes, 0, bytes.Length);
|
| | | var tableMs = new MemoryStream(bytes);
|
| | |
|
| | | var crypS = new CryptoStream(tableMs, decryptor, CryptoStreamMode.Read);
|
| | | sr = new StreamReader(crypS, Encoding.UTF8);
|
| | | var content = sr.ReadToEnd();
|
| | | lines = content.Split(lineStep, StringSplitOptions.None);
|
| | | }
|
| | |
|
| | | lines = File.ReadAllLines(_task.filePath, Encoding.UTF8);
|
| | | _task.state = TaskState.ReadFileSuccess;
|
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | _task.state = TaskState.ReadFileFailure;
|
| | | DesignDebug.Log(ex);
|
| | | DebugEx.Log(ex);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | var container = _task.container as Dictionary<string, ConfigBase>;
|
| | | for (int i = 3; i < _task.contentLines.Length; i++)
|
| | | {
|
| | | var contents = _task.contentLines[i].Split(rowStep, StringSplitOptions.None);
|
| | | var contents = _task.contentLines[i].Split(new string[] { "\t" }, StringSplitOptions.None);
|
| | | if (contents.Length <= 1)
|
| | | {
|
| | | continue;
|
| | |
| | | catch (Exception ex)
|
| | | {
|
| | | _task.state = TaskState.ParseFailure;
|
| | | DesignDebug.Log(ex);
|
| | | DebugEx.Log(ex);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | | {
|
| | | if (isPlaying && _task.state == TaskState.ReadFileFailure)
|
| | | {
|
| | | Thread.Sleep(30);
|
| | | ReadFile(_task, OnEndReadFile<T>);
|
| | | }
|
| | | else
|
| | |
| | | if (isPlaying && _task.state == TaskState.ParseFailure)
|
| | | {
|
| | | Debug.LogFormat("配置表解析失败:{0}", _task.taskName);
|
| | | Thread.Sleep(30);
|
| | | ReadFile(_task, OnEndReadFile<T>);
|
| | | }
|
| | | }
|
| | |
| | | case AssetPath.Resource:
|
| | | path = StringUtility.Contact("Config/", fileName);
|
| | | var textAsset = Resources.Load<TextAsset>(path);
|
| | | lines = textAsset.text.Split(lineStep, StringSplitOptions.None);
|
| | | lines = textAsset.text.Split(new string[] { "\r\n" }, StringSplitOptions.None);
|
| | | break;
|
| | | case AssetPath.ResourceOut:
|
| | | path = StringUtility.Contact(ResourcesPath.CONFIG_FODLER, "/", fileName, ".txt");
|
| | | lines = File.ReadAllLines(path, Encoding.UTF8);
|
| | | break;
|
| | | case AssetPath.External:
|
| | | var assetVersion = AssetVersionUtility.GetAssetVersion(StringUtility.Contact("config/", fileName, ".bytes"));
|
| | | var assetVersion = AssetVersionUtility.GetAssetVersion(StringUtility.Contact("config/", fileName, ".txt"));
|
| | | path = StringUtility.Contact(ResourcesPath.Instance.ExternalStorePath, assetVersion.relativePath);
|
| | |
|
| | | var provider = new TripleDESCryptoServiceProvider();
|
| | | provider.Key = Convert.FromBase64String(CustomKey);
|
| | | provider.IV = Convert.FromBase64String(CustomIV);
|
| | | provider.Mode = CipherMode.CBC;
|
| | | provider.Padding = PaddingMode.PKCS7;
|
| | | var decryptor = provider.CreateDecryptor();
|
| | |
|
| | | var fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
| | | var bytes = new byte[fs.Length];
|
| | | fs.Read(bytes, 0, bytes.Length);
|
| | | var ms = new MemoryStream(bytes);
|
| | |
|
| | | var crypS = new CryptoStream(ms, decryptor, CryptoStreamMode.Read);
|
| | | var sr = new StreamReader(crypS, Encoding.UTF8);
|
| | | var content = sr.ReadToEnd();
|
| | | lines = content.Split(lineStep, StringSplitOptions.None);
|
| | |
|
| | | lines = File.ReadAllLines(path, Encoding.UTF8);
|
| | | break;
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | for (int i = 3; i < _task.contentLines.Length; i++)
|
| | | {
|
| | | var contents = _task.contentLines[i].Split(rowStep, StringSplitOptions.None);
|
| | | var contents = _task.contentLines[i].Split(new string[] { "\t" }, StringSplitOptions.None);
|
| | | if (contents.Length <= 1)
|
| | | {
|
| | | continue;
|
| | |
| | | }
|
| | | catch (Exception ex)
|
| | | {
|
| | | DesignDebug.Log(ex);
|
| | | DebugEx.Log(ex);
|
| | | }
|
| | | finally
|
| | | {
|
| | |
| | |
|
| | | }
|
| | |
|
| | | public T GetTemplate<T>(string _dwTemplateID) where T : ConfigBase, new()
|
| | | public T Get<T>(string _dwTemplateID) where T : ConfigBase, new()
|
| | | {
|
| | | if (string.IsNullOrEmpty(_dwTemplateID))
|
| | | {
|
| | |
| | | var token = typeof(T).MetadataToken;
|
| | | if (configDictionary.ContainsKey(token) == false)
|
| | | {
|
| | | DesignDebug.LogErrorFormat("not find the config:{0}", token);
|
| | | DebugEx.LogErrorFormat("not find the config:{0}", token);
|
| | | return null;
|
| | | }
|
| | |
|
| | |
| | | var dic = configDictionary[token];
|
| | | if (!dic.ContainsKey(_dwTemplateID))
|
| | | {
|
| | | DesignDebug.LogFormat("not find the config:{0},<color=#ff0000ff>ID:{1}</color>", typeof(T).Name, _dwTemplateID);
|
| | | DebugEx.LogFormat("not find the config:{0},<color=#ff0000ff>ID:{1}</color>", typeof(T).Name, _dwTemplateID);
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | return config as T;
|
| | | }
|
| | |
|
| | | public T GetTemplate<T>(int _dwTemplateID) where T : ConfigBase, new()
|
| | | public T Get<T>(int _dwTemplateID) where T : ConfigBase, new()
|
| | | {
|
| | | return GetTemplate<T>(_dwTemplateID.ToString());
|
| | | return Get<T>(_dwTemplateID.ToString());
|
| | | }
|
| | |
|
| | | public bool ContainKey<T>(int _id)
|
| | |
| | | var token = typeof(T).MetadataToken;
|
| | | if (!configDictionary.ContainsKey(token))
|
| | | {
|
| | | DesignDebug.LogErrorFormat("not find the dic of config: {0}", typeof(T).Name);
|
| | | DebugEx.LogErrorFormat("not find the dic of config: {0}", typeof(T).Name);
|
| | | return null;
|
| | | }
|
| | |
|
| | |
| | | var token = typeof(T).MetadataToken;
|
| | | if (!configDictionary.ContainsKey(token))
|
| | | {
|
| | | DesignDebug.LogErrorFormat("not find the dic of config: {0}", typeof(T).Name);
|
| | | DebugEx.LogErrorFormat("not find the dic of config: {0}", typeof(T).Name);
|
| | | return null;
|
| | | }
|
| | |
|