diff options
author | chai <215380520@qq.com> | 2023-05-12 19:00:29 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-05-12 19:00:29 +0800 |
commit | 6c91f1ed6810a57da08a24dd1359f288c443dd75 (patch) | |
tree | 485096584922b7300e987af1fe9c21f262898a5f /WorldlineKeepers/Assets/Scripts | |
parent | 266370578135dca270729e8a70252e776ed22898 (diff) |
*misc
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts')
25 files changed, 433 insertions, 41 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs b/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs new file mode 100644 index 0000000..312eba8 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs @@ -0,0 +1,55 @@ +using JetBrains.Annotations; +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>>(); + + public static List<T> Read<T>(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); + } + List<T> result = new List<T>(); + 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) + { + fieldInfo.SetValue(obj, Convert.ChangeType(row[index], fieldInfo.FieldType)); + } + } + result.Add(obj); + } + return result; + } + + } + +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta new file mode 100644 index 0000000..52670ce --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/CSVReader.cs.meta @@ -0,0 +1,11 @@ +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 e56c80b..a3d1257 100644 --- a/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs @@ -9,8 +9,8 @@ namespace WK.Data public class DataManager : Singleton<DataManager> { - private Dictionary<string/*uid*/, CharacterStatsMetadata> m_CharacterStatsMetadata; - private Dictionary<string/*uid*/, BuffMetadata> m_BuffMetadata; + private Dictionary<string/*uid*/, CharacterStatsMetadata> m_CharacterStatsMetadata = new Dictionary<string, CharacterStatsMetadata>(); + private Dictionary<string/*uid*/, BuffMetadata> m_BuffMetadata = new Dictionary<string, BuffMetadata>(); public CharacterStatsMetadata GetCharacterStats(string uid) { @@ -32,6 +32,21 @@ namespace WK.Data return null; } + public void Load() + { + LoadDefaultStats(); + } + + 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]); + } + } + } }
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Managers/Main.cs b/WorldlineKeepers/Assets/Scripts/Managers/Main.cs new file mode 100644 index 0000000..976779d --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Managers/Main.cs @@ -0,0 +1,36 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WK.Data; + +namespace WK +{ + + public class Main : SingletonMB<Main> + { + protected override void Awake() + { + base.Awake(); + DontDestroyOnLoad(this.gameObject); + } + + private void Start() + { + DataManager.Instance.Load(); + + Debug.Log(DataManager.Instance.GetCharacterStats("health")); + } + + private void Update() + { + + } + + private void FixedUpdate() + { + + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Managers/Main.cs.meta b/WorldlineKeepers/Assets/Scripts/Managers/Main.cs.meta new file mode 100644 index 0000000..f8cfcd8 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Managers/Main.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e1448edde341f4f44b6959c045b6600b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Particles.meta b/WorldlineKeepers/Assets/Scripts/Particles.meta new file mode 100644 index 0000000..8cc2ebb --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Particles.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: af5fa8c4dfb03144b82e12b7640aac6b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Particles/ParticleEffect.cs b/WorldlineKeepers/Assets/Scripts/Particles/ParticleEffect.cs new file mode 100644 index 0000000..514c0b0 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Particles/ParticleEffect.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + public class Particle + { + + } + + public class ParticleEffect + { + + } + +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Particles/ParticleEffect.cs.meta b/WorldlineKeepers/Assets/Scripts/Particles/ParticleEffect.cs.meta new file mode 100644 index 0000000..6f48db8 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Particles/ParticleEffect.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c224205c69a732e4d86047718d17b716 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Rendering.meta b/WorldlineKeepers/Assets/Scripts/Rendering.meta new file mode 100644 index 0000000..311f706 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Rendering.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 71e7fb8d495c42741af95417c97c5477 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs new file mode 100644 index 0000000..f2b7e98 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK.Rendering +{ + + public class SpriteAnimation + { + public List<Sprite> sprites; + + public float duration; + } + +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs.meta b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs.meta new file mode 100644 index 0000000..6350064 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e85d2c6a8c8a6f41aad37c9bf63851a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs new file mode 100644 index 0000000..315cf91 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs @@ -0,0 +1,34 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK.Rendering +{ + + public class SpriteAnimationController : MonoBehaviour + { + #region åºåˆ—化 + [SerializeField] private SpriteAnimation m_SpriteAnimation; + [SerializeField] private bool m_AutoPlay; + #endregion + + #region 公共嗿®µ + + #endregion + + #region ç§æœ‰å—段 + + #endregion + + private void Awake() + { + // ç§æœ‰å—段赋值 + + // 公共嗿®µèµ‹å€¼ + + // åˆå§‹åŒ– + } + + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs.meta b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs.meta new file mode 100644 index 0000000..910958f --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Rendering/SpriteAnimationController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 167a1a5c7e017484d92699dc23a2b5c0 +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 new file mode 100644 index 0000000..53219b5 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + public class StaticDefine + { + public static string StatsFilePath = "metadata/default_stats.csv"; + public static string BuffFilePath = "metadata/default_buffs.csv"; + + } + +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs.meta b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs.meta new file mode 100644 index 0000000..c7693e2 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5cbd85a50d3874748ae49b6aa5ed74e6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs index 3b0b13b..c240ca1 100644 --- a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs +++ b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsMetadata.cs @@ -14,7 +14,7 @@ namespace WK.Data public string name_key; - public int type; + public string type; // ÔÝÁôÊý¾Ý public string extra_data; diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestCSV.cs b/WorldlineKeepers/Assets/Scripts/Tests/TestCSV.cs index 068d235..b24a8c7 100644 --- a/WorldlineKeepers/Assets/Scripts/Tests/TestCSV.cs +++ b/WorldlineKeepers/Assets/Scripts/Tests/TestCSV.cs @@ -4,54 +4,64 @@ using System.Collections.Generic; using System.Resources; using System.Text; using UnityEngine; +using WK.Data; +using WK; using yutokun; -public class TestCSV : MonoBehaviour +namespace WK { - #region åºåˆ—化 - - #endregion - - #region 公共嗿®µ - - #endregion - - #region ç§æœ‰å—段 - - #endregion - - private void OnEnable() - { - // ç§æœ‰å—段赋值 - - // 公共嗿®µèµ‹å€¼ - - // åˆå§‹åŒ– - - TextAsset text = WK.ResourceManager.Instance.LoadAsset<TextAsset>("metadata/default_stats.csv"); - - var sheet = CSVParser.LoadFromString(text.text); - - var styled = new StringBuilder(); - foreach (var row in sheet) + + public class TestCSV : MonoBehaviour + { + #region åºåˆ—化 + + #endregion + + #region 公共嗿®µ + + #endregion + + #region ç§æœ‰å—段 + + #endregion + + private void OnEnable() { - styled.Append("| "); + // ç§æœ‰å—段赋值 + + // 公共嗿®µèµ‹å€¼ - if (row[0][0] == '#') - continue; + // åˆå§‹åŒ– - foreach (var cell in row) + TextAsset text = ResourceManager.Instance.LoadAsset<TextAsset>("metadata/default_stats.csv"); + + var sheet = CSVParser.LoadFromString(text.text); + + var styled = new StringBuilder(); + foreach (var row in sheet) { - styled.Append(cell); - styled.Append(" | "); + styled.Append("| "); + + if (row[0][0] == '#') + continue; + + foreach (var cell in row) + { + styled.Append(cell); + styled.Append(" | "); + } + + styled.AppendLine(); } - styled.AppendLine(); - } + Debug.Log(styled.ToString()); // Unity + Console.WriteLine(styled.ToString()); // C# - Debug.Log(styled.ToString()); // Unity - Console.WriteLine(styled.ToString()); // C# + List<CharacterStatsMetadata> stats = CSVReader.Read<CharacterStatsMetadata>(text.text); + Debug.Log(stats.Count); + + } } -} +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs b/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs index 89d6219..dbfa8dc 100644 --- a/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs +++ b/WorldlineKeepers/Assets/Scripts/Tests/TestJson.cs @@ -62,6 +62,7 @@ public class TestJson : MonoBehaviour SaveDatas sd = JsonMapper.ToObject<SaveDatas>(Datas); Debug.Log(Datas); + } private void Reset() diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs new file mode 100644 index 0000000..7674523 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + /// <summary> + /// ½ÇÉ«µÄÍæ·¨¡¢ÐÐΪ£¬ÊǽÇÉ«µÄÍæ·¨ºËÐÄ¡£ÐèÒª¼Ì³ÐʵÏÖÕâ¸öÀà + /// </summary> + public abstract class CharacterBehaviour + { + private PlayerController m_Controller; + public PlayerController controller { get { return m_Controller; } } + + public CharacterInfo info { get { return m_Controller.info; } } + + public virtual void OnCreate() + { + } + + public virtual void OnGlobalUpdate() + { + } + + public virtual void OnStageUpdate() + { + } + + } + +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs.meta new file mode 100644 index 0000000..330a2d3 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/CharacterController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 65afd074deb4dbc468bd8d8940712002 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs new file mode 100644 index 0000000..66bf6df --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs @@ -0,0 +1,18 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace WK +{ + + public class PlayerController + { + private CharacterInfo m_CharacterInfo; + public CharacterInfo info { get { return m_CharacterInfo; } } + + private CharacterBehaviour m_CharacterBehaviour; + public CharacterBehaviour behaviour { get { return m_CharacterBehaviour; } } + + } + +}
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs.meta new file mode 100644 index 0000000..6d0088e --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/PlayerController.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 66c187a180d1c0848aa1a1743aec6cdc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin.meta new file mode 100644 index 0000000..05dfd58 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1dc22d7994acb134f9036b17b2831130 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs new file mode 100644 index 0000000..4a348eb --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs @@ -0,0 +1,20 @@ +using Mono.Cecil.Cil; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WK; + +public class RoninBehaviour : CharacterBehaviour +{ + + public override void OnCreate() + { + base.OnCreate(); + + if (info.stats["max_health"] != null) + { + int health = info.stats["max_health"].value.i; + } + } + +} diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs.meta b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs.meta new file mode 100644 index 0000000..8edce5b --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7064bd9c8014c684db967665061cb779 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: |