summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-05-31 09:21:51 +0800
committerchai <215380520@qq.com>2023-05-31 09:21:51 +0800
commitdbf4ea119100f571b3710568dfdc2e09dcec2a61 (patch)
tree50d3721718aeff5944b5baa8d392a1d8cfa1bad1
parent2fcb4625389b1594bbefdbaf2e038b2cfffa8ead (diff)
*misc
-rw-r--r--WorldlineKeepers/Assets/Editor.meta8
-rw-r--r--WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs16
-rw-r--r--WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs15
-rw-r--r--WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Common/Common.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Common/CommonParse.cs2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs137
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/DataManager.cs99
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs24
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/DataManager_Data.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs4
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/Metadata.meta8
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs (renamed from WorldlineKeepers/Assets/Scripts/Data/FileKey.cs)2
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs.meta (renamed from WorldlineKeepers/Assets/Scripts/Data/FileKey.cs.meta)0
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs (renamed from WorldlineKeepers/Assets/Scripts/Data/Filelist.cs)11
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs.meta (renamed from WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta)0
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs17
-rw-r--r--WorldlineKeepers/Assets/Scripts/Data/Metadata/StageMetadata.cs.meta11
-rw-r--r--WorldlineKeepers/Assets/Scripts/StaticDefine.cs3
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools/CSVReader.cs133
-rw-r--r--WorldlineKeepers/Assets/Scripts/Tools/CSVReader.cs.meta (renamed from WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta)0
-rw-r--r--WorldlineKeepers/Assets/ThirdParty/LitJson/JsonMapper.cs36
-rw-r--r--WorldlineKeepers/Assets/ThirdParty/LitJson/JsonWriter.cs6
-rw-r--r--WorldlineKeepers/Assets/Tools.meta8
-rw-r--r--WorldlineKeepers/Assets/Tools/LevelEditor.meta8
27 files changed, 363 insertions, 222 deletions
diff --git a/WorldlineKeepers/Assets/Editor.meta b/WorldlineKeepers/Assets/Editor.meta
new file mode 100644
index 0000000..ae1b3ae
--- /dev/null
+++ b/WorldlineKeepers/Assets/Editor.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: c133e97861bffb94588d6cb22894b5f8
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs
new file mode 100644
index 0000000..68b81b4
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs
@@ -0,0 +1,16 @@
+using System.Collections;
+using System.Collections.Generic;
+using Unity.VisualScripting;
+using UnityEngine;
+
+namespace WK
+{
+
+ public class BattleBehaviour
+ {
+
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs.meta
new file mode 100644
index 0000000..a0c3a26
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Battle/BattleBehaviour.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 6c8b27831b1022e4881217680c643f15
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs
new file mode 100644
index 0000000..6cffe4d
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs
@@ -0,0 +1,15 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+namespace WK
+{
+
+ public class StageBehaviour
+ {
+
+
+
+ }
+
+}
diff --git a/WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs.meta
new file mode 100644
index 0000000..bb28c07
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Battle/StageBehaviour.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 47c0fe08c8f25a04dac706a9aefdd444
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs b/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs
index fd82064..b468807 100644
--- a/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs
+++ b/WorldlineKeepers/Assets/Scripts/Buffs/BuffMetadata.cs
@@ -4,7 +4,7 @@ using UnityEngine;
namespace WK.Data
{
-
+
public class BuffMetadata
{
diff --git a/WorldlineKeepers/Assets/Scripts/Common/Common.cs b/WorldlineKeepers/Assets/Scripts/Common/Common.cs
index 13a9f58..6fd2315 100644
--- a/WorldlineKeepers/Assets/Scripts/Common/Common.cs
+++ b/WorldlineKeepers/Assets/Scripts/Common/Common.cs
@@ -13,7 +13,7 @@
using UnityEngine;
using System.Collections;
-namespace DNA
+namespace WK
{
[System.Serializable]
public struct IntVector2
diff --git a/WorldlineKeepers/Assets/Scripts/Common/CommonParse.cs b/WorldlineKeepers/Assets/Scripts/Common/CommonParse.cs
index 6d06eff..f2d7640 100644
--- a/WorldlineKeepers/Assets/Scripts/Common/CommonParse.cs
+++ b/WorldlineKeepers/Assets/Scripts/Common/CommonParse.cs
@@ -15,7 +15,7 @@ using System.Collections;
using System;
using LitJson;
-namespace DNA
+namespace WK
{
public class CommonParse
{
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<string/*key*/, int/*index*/> m_KeyMapping = new Dictionary<string, int>();
- private static List<List<string>> m_Rows = new List<List<string>>();
-
- /// <summary>
- /// 解析csv表格,并返回列表
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="content"></param>
- /// <returns></returns>
- public static List<T> Read<T>(string content) where T : new()
- {
- List<T> result = new List<T>();
- Read<T>(result, content);
- return result;
- }
-
- /// <summary>
- /// 解析csv表格,并返回数量
- /// </summary>
- /// <typeparam name="T"></typeparam>
- /// <param name="content"></param>
- /// <returns></returns>
- public static int Read<T>(List<T> target, string content) where T : new()
- {
- m_KeyMapping.Clear();
- m_Rows.Clear();
-
- m_Rows = CSVParser.LoadFromString(content);
- // 第一行是key
- List<string> 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<string> 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;
- }
-
- /// <summary>
- /// 解析csv表格,并按key存储到字典里,返回数量
- /// </summary>
- /// <typeparam name="TKey"></typeparam>
- /// <typeparam name="TValue"></typeparam>
- /// <param name="target"></param>
- /// <param name="content"></param>
- /// <param name="keyName"></param>
- /// <returns></returns>
- public static int ReadDictionary<TKey, TValue>(Dictionary<TKey, TValue> target, string content, string keyName) where TValue : new()
- {
- List<TValue> data = CSVReader.Read<TValue>(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/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
{
- /// <summary>
- /// 所有配置数据
- /// </summary>
public partial class DataManager : Singleton<DataManager>
{
- private Dictionary<string/*uid*/, CharacterStatsMetadata> m_CharacterStatsMetadata = new Dictionary<string, CharacterStatsMetadata>();
- private Dictionary<string/*uid*/, BuffMetadata> m_BuffMetadata = new Dictionary<string, BuffMetadata>();
- private Dictionary<string/*uid*/, CharacterMetadata> m_CharacterMetadata = new Dictionary<string, CharacterMetadata>();
-
- private Dictionary<EFileKey, MetadataFile> m_Filelist = new Dictionary<EFileKey, MetadataFile>();
-
- 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<TextAsset>(StaticDefine.StatsFilePath);
- List<CharacterStatsMetadata> stats = CSVReader.Read<CharacterStatsMetadata>(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<TextAsset>(StaticDefine.RoninPath);
- CharacterMetadata metadata = JsonMapper.ToObject<CharacterMetadata>(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<TextAsset>(StaticDefine.StatsFilePath);
+ // List<CharacterStatsMetadata> stats = CSVReader.Read<CharacterStatsMetadata>(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<TextAsset>(StaticDefine.RoninPath);
+ // CharacterMetadata metadata = JsonMapper.ToObject<CharacterMetadata>(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
+{
+
+ /// <summary>
+ /// 所有配置数据
+ /// </summary>
+ public partial class DataManager : Singleton<DataManager>
+ {
+ // 文件列表
+ private Dictionary<string/*EFileKey*/, MetadataFileDescriptor> m_Filelist = new Dictionary<string, MetadataFileDescriptor>();
+
+ private Dictionary<string/*uid*/, CharacterStatsMetadata> m_CharacterStatsMetadata = new Dictionary<string, CharacterStatsMetadata>();
+ private Dictionary<string/*uid*/, BuffMetadata> m_BuffMetadata = new Dictionary<string, BuffMetadata>();
+ private Dictionary<string/*uid*/, CharacterMetadata> m_CharacterMetadata = new Dictionary<string, CharacterMetadata>();
+
+
+
+ }
+
+}
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<TextAsset>(StaticDefine.FileList);
string content = text.text;
- List<MetadataFile> files = CSVReader.Read<MetadataFile>(content);
- CSVReader.ReadDictionary<EFileKey, MetadataFile>(m_Filelist, content, "key");
+ List<MetadataFileDescriptor> files = CSVReader.Read<MetadataFileDescriptor>(content);
+ CSVReader.ReadDictionary<string, MetadataFileDescriptor>(m_Filelist, content, "key");
Debug.Log(m_Filelist.Count);
}
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/FileKey.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs
index 1ab15b2..621203e 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs
@@ -6,7 +6,7 @@ namespace WK.Data
{
/// <summary>
- /// 文件enum
+ /// 默认文件enum,编号无所谓,名字不可更改。方便找文件
/// </summary>
public enum EFileKey
{
diff --git a/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs.meta
index 1564c3d..1564c3d 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/FileKey.cs.meta
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs.meta
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs
index dc96df9..b91619b 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs
@@ -5,6 +5,9 @@ using UnityEngine;
namespace WK.Data
{
+ /// <summary>
+ /// 文件类型
+ /// </summary>
public enum FileType
{
CSV = 0,
@@ -12,6 +15,9 @@ namespace WK.Data
Txt = 2,
}
+ /// <summary>
+ /// 文件路径
+ /// </summary>
public enum FileRoot
{
Bundle = 0,
@@ -20,11 +26,10 @@ namespace WK.Data
}
/// <summary>
- /// 文件列表
+ /// 元文件描述符
/// </summary>
- public class MetadataFile
+ public class MetadataFileDescriptor
{
-
public string key;
public FileType type;
public FileRoot root;
diff --git a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs.meta
index 9bb6057..9bb6057 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta
+++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/Filelist.cs.meta
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
+{
+ /// <summary>
+ /// 关卡元数据
+ /// </summary>
+ 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:
diff --git a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs
index 947882e..b772d86 100644
--- a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs
+++ b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs
@@ -17,10 +17,11 @@ namespace WK
public static string RoninPath = "characters/ronin/ronin.json";
- // 场景
+ // 场景名
public static string Scene_Dojo = "Scenes/3_Dojo";
public static string Scene_Stage = "Scenes/4_Stage";
+ // 文件列表
public static string FileList = "metadata/filelist.csv";
}
diff --git a/WorldlineKeepers/Assets/Scripts/Tools/CSVReader.cs b/WorldlineKeepers/Assets/Scripts/Tools/CSVReader.cs
new file mode 100644
index 0000000..0ce796e
--- /dev/null
+++ b/WorldlineKeepers/Assets/Scripts/Tools/CSVReader.cs
@@ -0,0 +1,133 @@
+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;
+
+public class CSVReader
+{
+ private static Dictionary<string/*key*/, int/*index*/> m_KeyMapping = new Dictionary<string, int>();
+ private static List<List<string>> m_Rows = new List<List<string>>();
+
+ /// <summary>
+ /// 解析csv表格,并返回列表
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="content"></param>
+ /// <returns></returns>
+ public static List<T> Read<T>(string content) where T : new()
+ {
+ List<T> result = new List<T>();
+ Read<T>(result, content);
+ return result;
+ }
+
+ /// <summary>
+ /// 解析csv表格,并返回数量
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="content"></param>
+ /// <returns></returns>
+ public static int Read<T>(List<T> target, string content) where T : new()
+ {
+ m_KeyMapping.Clear();
+ m_Rows.Clear();
+
+ m_Rows = CSVParser.LoadFromString(content);
+ // 第一行是key
+ List<string> 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<string> 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;
+ }
+
+ /// <summary>
+ /// 解析csv表格,并按key存储到字典里,返回数量
+ /// </summary>
+ /// <typeparam name="TKey"></typeparam>
+ /// <typeparam name="TValue"></typeparam>
+ /// <param name="target"></param>
+ /// <param name="content"></param>
+ /// <param name="keyName"></param>
+ /// <returns></returns>
+ public static int ReadDictionary<TKey, TValue>(Dictionary<TKey, TValue> target, string content, string keyName) where TValue : new()
+ {
+ List<TValue> data = CSVReader.Read<TValue>(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;
+ }
+
+}
+
diff --git a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta b/WorldlineKeepers/Assets/Scripts/Tools/CSVReader.cs.meta
index 52670ce..52670ce 100644
--- a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta
+++ b/WorldlineKeepers/Assets/Scripts/Tools/CSVReader.cs.meta
diff --git a/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonMapper.cs b/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonMapper.cs
index 3a09a87..6f79c65 100644
--- a/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonMapper.cs
+++ b/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonMapper.cs
@@ -414,35 +414,35 @@ namespace LitJson
}
if (inst_type == typeof(UnityEngine.Vector4))
{
- return DNA.CommonParse.ParseVector4(reader.Value.ToString());
+ return WK.CommonParse.ParseVector4(reader.Value.ToString());
}
if (inst_type == typeof(UnityEngine.Vector3))
{
- return DNA.CommonParse.ParseVector3(reader.Value.ToString());
+ return WK.CommonParse.ParseVector3(reader.Value.ToString());
}
if (inst_type == typeof(UnityEngine.Vector2))
{
- return DNA.CommonParse.ParseVector2(reader.Value.ToString());
+ return WK.CommonParse.ParseVector2(reader.Value.ToString());
}
- if (inst_type == typeof(DNA.IntVector4))
+ if (inst_type == typeof(WK.IntVector4))
{
- return DNA.CommonParse.ParseIntVector4(reader.Value.ToString());
+ return WK.CommonParse.ParseIntVector4(reader.Value.ToString());
}
- if (inst_type == typeof(DNA.IntVector3))
+ if (inst_type == typeof(WK.IntVector3))
{
- return DNA.CommonParse.ParseIntVector3(reader.Value.ToString());
+ return WK.CommonParse.ParseIntVector3(reader.Value.ToString());
}
- if (inst_type == typeof(DNA.IntVector2))
+ if (inst_type == typeof(WK.IntVector2))
{
- return DNA.CommonParse.ParseIntVector2(reader.Value.ToString());
+ return WK.CommonParse.ParseIntVector2(reader.Value.ToString());
}
if (inst_type == typeof(UnityEngine.Color))
{
- return DNA.CommonParse.ParseColor(reader.Value.ToString());
+ return WK.CommonParse.ParseColor(reader.Value.ToString());
}
if (inst_type == typeof(UnityEngine.Color32))
{
- return DNA.CommonParse.ParseColor32(reader.Value.ToString());
+ return WK.CommonParse.ParseColor32(reader.Value.ToString());
}
//==========================================
@@ -560,7 +560,7 @@ namespace LitJson
object keyObj = property;
if (t_data.GenericKeyType == typeof(int))
{
- keyObj = DNA.CommonParse.ParseInt(property);
+ keyObj = WK.CommonParse.ParseInt(property);
}
((IDictionary) instance).Add (
@@ -827,21 +827,21 @@ namespace LitJson
writer.Write((UnityEngine.Vector2)obj);
return;
}
- if (obj is DNA.IntVector4)
+ if (obj is WK.IntVector4)
{
- writer.Write((DNA.IntVector4)obj);
+ writer.Write((WK.IntVector4)obj);
return;
}
- if (obj is DNA.IntVector3)
+ if (obj is WK.IntVector3)
{
- writer.Write((DNA.IntVector3)obj);
+ writer.Write((WK.IntVector3)obj);
return;
}
- if (obj is DNA.IntVector2)
+ if (obj is WK.IntVector2)
{
- writer.Write((DNA.IntVector2)obj);
+ writer.Write((WK.IntVector2)obj);
return;
}
diff --git a/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonWriter.cs b/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonWriter.cs
index 40324e9..887adad 100644
--- a/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonWriter.cs
+++ b/WorldlineKeepers/Assets/ThirdParty/LitJson/JsonWriter.cs
@@ -340,7 +340,7 @@ namespace LitJson
context.ExpectingValue = false;
}
- //public void Write(DNA.IntVector4 v4)
+ //public void Write(WK.IntVector4 v4)
//{
// DoValidation(Condition.Value);
// PutNewline();
@@ -353,7 +353,7 @@ namespace LitJson
// context.ExpectingValue = false;
//}
- //public void Write(DNA.IntVector3 v3)
+ //public void Write(WK.IntVector3 v3)
//{
// DoValidation(Condition.Value);
// PutNewline();
@@ -366,7 +366,7 @@ namespace LitJson
// context.ExpectingValue = false;
//}
- //public void Write(DNA.IntVector2 v2)
+ //public void Write(WK.IntVector2 v2)
//{
// DoValidation(Condition.Value);
// PutNewline();
diff --git a/WorldlineKeepers/Assets/Tools.meta b/WorldlineKeepers/Assets/Tools.meta
new file mode 100644
index 0000000..8ce3fe9
--- /dev/null
+++ b/WorldlineKeepers/Assets/Tools.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 137d3d7aebb9acd4aa3798ec18198450
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/WorldlineKeepers/Assets/Tools/LevelEditor.meta b/WorldlineKeepers/Assets/Tools/LevelEditor.meta
new file mode 100644
index 0000000..d70b307
--- /dev/null
+++ b/WorldlineKeepers/Assets/Tools/LevelEditor.meta
@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: cf820871525e2d64eb429efd80875983
+folderAsset: yes
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant: