From dbf4ea119100f571b3710568dfdc2e09dcec2a61 Mon Sep 17 00:00:00 2001
From: chai <215380520@qq.com>
Date: Wed, 31 May 2023 09:21:51 +0800
Subject: *misc
---
WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs | 137 ---------------------
.../Assets/Scripts/Data/CSVReader.cs.meta | 11 --
.../Assets/Scripts/Data/DataManager.cs | 99 +++++++--------
.../Assets/Scripts/Data/DataManager_Data.cs | 24 ++++
.../Assets/Scripts/Data/DataManager_Data.cs.meta | 11 ++
.../Assets/Scripts/Data/DataManager_Load.cs | 4 +-
WorldlineKeepers/Assets/Scripts/Data/FileKey.cs | 22 ----
.../Assets/Scripts/Data/FileKey.cs.meta | 11 --
WorldlineKeepers/Assets/Scripts/Data/Filelist.cs | 34 -----
.../Assets/Scripts/Data/Filelist.cs.meta | 11 --
WorldlineKeepers/Assets/Scripts/Data/Metadata.meta | 8 ++
.../Assets/Scripts/Data/Metadata/FileKey.cs | 22 ++++
.../Assets/Scripts/Data/Metadata/FileKey.cs.meta | 11 ++
.../Assets/Scripts/Data/Metadata/Filelist.cs | 39 ++++++
.../Assets/Scripts/Data/Metadata/Filelist.cs.meta | 11 ++
.../Assets/Scripts/Data/Metadata/StageMetadata.cs | 17 +++
.../Scripts/Data/Metadata/StageMetadata.cs.meta | 11 ++
17 files changed, 201 insertions(+), 282 deletions(-)
delete mode 100644 WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs
delete mode 100644 WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs.meta
delete mode 100644 WorldlineKeepers/Assets/Scripts/Data/FileKey.cs
delete mode 100644 WorldlineKeepers/Assets/Scripts/Data/FileKey.cs.meta
delete mode 100644 WorldlineKeepers/Assets/Scripts/Data/Filelist.cs
delete mode 100644 WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Metadata.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs.meta
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs
create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs.meta
(limited to 'WorldlineKeepers/Assets/Scripts/Data')
diff --git a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs b/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs
deleted file mode 100644
index 207656b..0000000
--- a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-using JetBrains.Annotations;
-using LitJson;
-using Newtonsoft.Json.Serialization;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Net.Mime;
-using System.Reflection;
-using UnityEngine;
-using yutokun;
-using static UnityEngine.Rendering.DebugUI;
-
-namespace WK.Data
-{
-
- public class CSVReader
- {
- private static Dictionary m_KeyMapping = new Dictionary();
- private static List> m_Rows = new List>();
-
- ///
- /// 解析csv表格,并返回列表
- ///
- ///
- ///
- ///
- public static List Read(string content) where T : new()
- {
- List result = new List();
- Read(result, content);
- return result;
- }
-
- ///
- /// 解析csv表格,并返回数量
- ///
- ///
- ///
- ///
- public static int Read(List target, string content) where T : new()
- {
- m_KeyMapping.Clear();
- m_Rows.Clear();
-
- m_Rows = CSVParser.LoadFromString(content);
- // 第一行是key
- List keys = m_Rows[0];
- for (int i = 0; i < keys.Count; ++i)
- {
- m_KeyMapping.Add(keys[i], i);
- }
- int count = 0;
- Type type = typeof(T);
- for (int i = 1; i < m_Rows.Count; ++i)
- {
- if (m_Rows[i][0][0] == '#') // 注释
- continue;
- List row = m_Rows[i];
- T obj = new T();
- foreach (var key in m_KeyMapping)
- {
- int index = key.Value;
- var fieldInfo = type.GetField(key.Key);
- if (fieldInfo != null)
- {
- Type fieldType = fieldInfo.FieldType;
- if (fieldType.IsEnum) // 如果是枚举,先转成int
- {
- int value = int.Parse(row[index]);
- fieldInfo.SetValue(obj, value);
- }
- else
- {
- fieldInfo.SetValue(obj, Convert.ChangeType(row[index], fieldInfo.FieldType));
- }
- }
- }
- target.Add(obj);
- count++;
- }
- return count;
- }
-
- ///
- /// 解析csv表格,并按key存储到字典里,返回数量
- ///
- ///
- ///
- ///
- ///
- ///
- ///
- public static int ReadDictionary(Dictionary target, string content, string keyName) where TValue : new()
- {
- List data = CSVReader.Read(content);
- if (data == null || data.Count == 0)
- return 0;
- Type type_key = typeof(TKey);
- Type type_value = typeof(TValue);
- FieldInfo field = type_value.GetField(keyName);
- Type type_field = field.FieldType;
- int count = 0;
- for (int i = 0; i < data.Count; ++i)
- {
- TValue d = data[i];
-
- TKey key = default(TKey);
- if (type_key.IsEnum)
- {
- if(type_field == typeof(string))
- {
- key = (TKey)Enum.Parse(type_key, field.GetValue(d).ToString());
- }
- else if(type_field == typeof(int))
- {
- key = (TKey)field.GetValue(d);
- }
- }
- else
- {
- key = (TKey)field.GetValue(d);
- }
- if (key == null)
- {
- LogHelper.LogError("CSVReader.ReadDictionary(): key is null");
- continue;
- }
-
- target.Add(key, d);
- count++;
- }
- return count;
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta
deleted file mode 100644
index 52670ce..0000000
--- a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: f6b35022c04390a46beb2b27711a7950
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs
index 2667736..9ec2734 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs
+++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs
@@ -7,63 +7,54 @@ using UnityEngine;
namespace WK.Data
{
- ///
- /// 所有配置数据
- ///
public partial class DataManager : Singleton
{
- private Dictionary m_CharacterStatsMetadata = new Dictionary();
- private Dictionary m_BuffMetadata = new Dictionary();
- private Dictionary m_CharacterMetadata = new Dictionary();
-
- private Dictionary m_Filelist = new Dictionary();
-
- public CharacterStatsMetadata GetCharacterStats(string uid)
- {
- CharacterStatsMetadata metadata;
- if(m_CharacterStatsMetadata.TryGetValue(uid, out metadata))
- {
- return metadata;
- }
- return null;
- }
-
- public BuffMetadata GetBuffMetadata(string uid)
- {
- BuffMetadata metadata;
- if(m_BuffMetadata.TryGetValue(uid, out metadata))
- {
- return metadata;
- }
- return null;
- }
-
- public void Load()
- {
- LoadDefaultStats();
- LoadDefaultCharacters();
- }
-
- private void LoadDefaultStats()
- {
- TextAsset text = ResourceManager.Instance.LoadAsset(StaticDefine.StatsFilePath);
- List stats = CSVReader.Read(text.text);
- for(int i = 0; i < stats.Count; ++i)
- {
- m_CharacterStatsMetadata.Add(stats[i].uid, stats[i]);
- }
- }
-
- private void LoadDefaultCharacters()
- {
- TextAsset text = ResourceManager.Instance.LoadAsset(StaticDefine.RoninPath);
- CharacterMetadata metadata = JsonMapper.ToObject(text.text);
- if(metadata != null)
- {
- m_CharacterMetadata.Add(metadata.uid, metadata);
- }
- }
+ //public CharacterStatsMetadata GetCharacterStats(string uid)
+ //{
+ // CharacterStatsMetadata metadata;
+ // if(m_CharacterStatsMetadata.TryGetValue(uid, out metadata))
+ // {
+ // return metadata;
+ // }
+ // return null;
+ //}
+
+ //public BuffMetadata GetBuffMetadata(string uid)
+ //{
+ // BuffMetadata metadata;
+ // if(m_BuffMetadata.TryGetValue(uid, out metadata))
+ // {
+ // return metadata;
+ // }
+ // return null;
+ //}
+
+ //public void Load()
+ //{
+ // LoadDefaultStats();
+ // LoadDefaultCharacters();
+ //}
+
+ //private void LoadDefaultStats()
+ //{
+ // TextAsset text = ResourceManager.Instance.LoadAsset(StaticDefine.StatsFilePath);
+ // List stats = CSVReader.Read(text.text);
+ // for(int i = 0; i < stats.Count; ++i)
+ // {
+ // m_CharacterStatsMetadata.Add(stats[i].uid, stats[i]);
+ // }
+ //}
+
+ //private void LoadDefaultCharacters()
+ //{
+ // TextAsset text = ResourceManager.Instance.LoadAsset(StaticDefine.RoninPath);
+ // CharacterMetadata metadata = JsonMapper.ToObject(text.text);
+ // if(metadata != null)
+ // {
+ // m_CharacterMetadata.Add(metadata.uid, metadata);
+ // }
+ //}
}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs
new file mode 100644
index 0000000..d16c785
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs
@@ -0,0 +1,24 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Data
+{
+
+ ///
+ /// 所有配置数据
+ ///
+ public partial class DataManager : Singleton
+ {
+ // 文件列表
+ private Dictionary m_Filelist = new Dictionary();
+
+ private Dictionary m_CharacterStatsMetadata = new Dictionary();
+ private Dictionary m_BuffMetadata = new Dictionary();
+ private Dictionary m_CharacterMetadata = new Dictionary();
+
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs.meta
new file mode 100644
index 0000000..cea1f4f
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 707bcf2d592188048b205923766b94a5
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs
index 811f5b4..aab90a9 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs
+++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs
@@ -33,8 +33,8 @@ namespace WK.Data
{
TextAsset text = ResourceManager.Instance.LoadAsset(StaticDefine.FileList);
string content = text.text;
- List files = CSVReader.Read(content);
- CSVReader.ReadDictionary(m_Filelist, content, "key");
+ List files = CSVReader.Read(content);
+ CSVReader.ReadDictionary(m_Filelist, content, "key");
Debug.Log(m_Filelist.Count);
}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs b/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs
deleted file mode 100644
index 1ab15b2..0000000
--- a/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace WK.Data
-{
-
- ///
- /// 文件enum
- ///
- public enum EFileKey
- {
- none = 0,
-
- default_stats,
- default_buffs,
- default_items,
-
- all
- }
-
-}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs.meta
deleted file mode 100644
index 1564c3d..0000000
--- a/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 024b24790fd0abd4181e4b690d9fb4ee
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs b/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs
deleted file mode 100644
index dc96df9..0000000
--- a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
-
-namespace WK.Data
-{
-
- public enum FileType
- {
- CSV = 0,
- Json = 1,
- Txt = 2,
- }
-
- public enum FileRoot
- {
- Bundle = 0,
- Streaming = 1,
- Persistent = 2,
- }
-
- ///
- /// 文件列表
- ///
- public class MetadataFile
- {
-
- public string key;
- public FileType type;
- public FileRoot root;
- public string path;
- }
-
-}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta
deleted file mode 100644
index 9bb6057..0000000
--- a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: f427347e73ff3e94d8d6f091ddcd4179
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata.meta b/WorldlineKeepers/Assets/Scripts/Data/Metadata.meta
new file mode 100644
index 0000000..adfaa0d
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c9192579c4677b3438c941d65a0a1a61
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs
new file mode 100644
index 0000000..621203e
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs
@@ -0,0 +1,22 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Data
+{
+
+ ///
+ /// 默认文件enum,编号无所谓,名字不可更改。方便找文件
+ ///
+ public enum EFileKey
+ {
+ none = 0,
+
+ default_stats,
+ default_buffs,
+ default_items,
+
+ all
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs.meta
new file mode 100644
index 0000000..1564c3d
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 024b24790fd0abd4181e4b690d9fb4ee
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs
new file mode 100644
index 0000000..b91619b
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs
@@ -0,0 +1,39 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Data
+{
+
+ ///
+ /// 文件类型
+ ///
+ public enum FileType
+ {
+ CSV = 0,
+ Json = 1,
+ Txt = 2,
+ }
+
+ ///
+ /// 文件路径
+ ///
+ public enum FileRoot
+ {
+ Bundle = 0,
+ Streaming = 1,
+ Persistent = 2,
+ }
+
+ ///
+ /// 元文件描述符
+ ///
+ public class MetadataFileDescriptor
+ {
+ public string key;
+ public FileType type;
+ public FileRoot root;
+ public string path;
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs.meta
new file mode 100644
index 0000000..9bb6057
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: f427347e73ff3e94d8d6f091ddcd4179
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs
new file mode 100644
index 0000000..ed7b1cb
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs
@@ -0,0 +1,17 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK.Data
+{
+ ///
+ /// 关卡元数据
+ ///
+ public class StageMetadata
+ {
+
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs.meta
new file mode 100644
index 0000000..7ff42d8
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7e2e7c43d0f01fe4799d8284e9982627
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
--
cgit v1.1-26-g67d0