From 8af5d3d900b11288f98696be9a97d726cbe86006 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期三, 13 二月 2019 19:07:54 +0800
Subject: [PATCH] 3335 配置表读取重构。
---
Core/GameEngine/Model/Config/CrossServerArenaConfig.cs | 221 +++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 182 insertions(+), 39 deletions(-)
diff --git a/Core/GameEngine/Model/Config/CrossServerArenaConfig.cs b/Core/GameEngine/Model/Config/CrossServerArenaConfig.cs
index 96ee5c6..1a63324 100644
--- a/Core/GameEngine/Model/Config/CrossServerArenaConfig.cs
+++ b/Core/GameEngine/Model/Config/CrossServerArenaConfig.cs
@@ -1,47 +1,190 @@
-锘�//--------------------------------------------------------
-// [Author]: 绗簩涓栫晫
-// [ Date ]: Wednesday, February 13, 2019
-//--------------------------------------------------------
-
-using UnityEngine;
-using System;
-using System.Collections.Generic;
-
-
- public partial class CrossServerArenaConfig {
-
- public int DanLV { get ; private set ; }
- public string Name { get ; private set; }
- public int DanType { get ; private set ; }
- public string IconKey { get ; private set; }
- public int LVUpScore { get ; private set ; }
- public string DanLVAwardList { get ; private set; }
- public string SeasonAwardList { get ; private set; }
+锘�//--------------------------------------------------------
+// [Author]: Fish
+// [ Date ]: Wednesday, February 13, 2019
+//--------------------------------------------------------
- public static bool inited;
-
- public static void Init()
+using System.Collections.Generic;
+using System.IO;
+using System.Threading;
+using System;
+using UnityEngine;
+
+public partial class CrossServerArenaConfig
+{
+
+ public readonly int DanLV;
+ public readonly string Name;
+ public readonly int DanType;
+ public readonly string IconKey;
+ public readonly int LVUpScore;
+ public readonly string DanLVAwardList;
+ public readonly string SeasonAwardList;
+
+ public CrossServerArenaConfig()
{
+ }
- }
-
+ public CrossServerArenaConfig(string input)
+ {
+ try
+ {
+ var tables = input.Split('\t');
+
+ int.TryParse(tables[0],out DanLV);
+
+ Name = tables[1];
+
+ int.TryParse(tables[2],out DanType);
+
+ IconKey = tables[3];
+
+ int.TryParse(tables[4],out LVUpScore);
+
+ DanLVAwardList = tables[5];
+
+ SeasonAwardList = tables[6];
+ }
+ catch (Exception ex)
+ {
+ DebugEx.Log(ex);
+ }
+ }
+
+ static Dictionary<string, CrossServerArenaConfig> configs = new Dictionary<string, CrossServerArenaConfig>();
public static CrossServerArenaConfig Get(string id)
+ {
+ if (!inited)
+ {
+ Debug.Log("CrossServerArenaConfig 杩樻湭瀹屾垚鍒濆鍖栥��");
+ return null;
+ }
+
+ if (configs.ContainsKey(id))
+ {
+ return configs[id];
+ }
+
+ CrossServerArenaConfig config = null;
+ if (rawDatas.ContainsKey(id))
+ {
+ config = configs[id] = new CrossServerArenaConfig(rawDatas[id]);
+ rawDatas.Remove(id);
+ }
+
+ return config;
+ }
+
+ public static CrossServerArenaConfig Get(int id)
{
- return null;
- }
-
- public static CrossServerArenaConfig Get(int id)
+ return Get(id.ToString());
+ }
+
+ public static List<string> GetKeys()
{
- return null;
- }
-
+ var keys = new List<string>();
+ keys.AddRange(configs.Keys);
+ keys.AddRange(rawDatas.Keys);
+ return keys;
+ }
+
public static List<CrossServerArenaConfig> GetValues()
{
- return null;
- }
-
-}
-
-
-
-
+ var values = new List<CrossServerArenaConfig>();
+ 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 +"/CrossServerArena.txt";
+ }
+ else
+ {
+ path = AssetVersionUtility.GetAssetFilePath("config/CrossServerArena.txt");
+ }
+
+ var tempConfig = new CrossServerArenaConfig();
+ var preParse = tempConfig is IConfigPostProcess;
+
+ if (sync)
+ {
+ var lines = File.ReadAllLines(path);
+ if (!preParse)
+ {
+ rawDatas = new Dictionary<string, string>(lines.Length - 3);
+ }
+ for (int i = 3; i < lines.Length; i++)
+ {
+ var line = lines[i];
+ var index = line.IndexOf("\t");
+ var id = line.Substring(0, index);
+
+ if (preParse)
+ {
+ configs[id] = new CrossServerArenaConfig(line);
+ }
+ else
+ {
+ rawDatas[id] = line;
+ }
+ }
+ 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++)
+ {
+ var line = lines[i];
+ var index = line.IndexOf("\t");
+ var id = line.Substring(0, index);
+
+ if (preParse)
+ {
+ configs[id] = new CrossServerArenaConfig(line);
+ }
+ else
+ {
+ rawDatas[id] = line;
+ }
+ }
+
+ inited = true;
+ });
+ }
+ }
+
+}
+
+
+
+
--
Gitblit v1.8.0