From c66fe8c43a368eb4b23aa1e3104019aabf9e2274 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 18 May 2023 11:00:32 +0800 Subject: *misc --- WorldlineKeepers/Assets/Scripts/ConstDefine.cs | 12 +++++-- .../Assets/Scripts/Data/DataManager.cs | 7 +++- .../Assets/Scripts/Data/DataManager_Load.cs | 38 ++++++++++++++++++++ .../Assets/Scripts/Data/DataManager_Load.cs.meta | 11 ++++++ WorldlineKeepers/Assets/Scripts/Data/Filelist.cs | 41 ++++++++++++++++++++++ .../Assets/Scripts/Data/Filelist.cs.meta | 11 ++++++ .../Assets/Scripts/Stages/GameStageManager.cs | 31 ++++++++++++++++ WorldlineKeepers/Assets/Scripts/StaticDefine.cs | 7 ++++ 8 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs create mode 100644 WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs.meta create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Filelist.cs create mode 100644 WorldlineKeepers/Assets/Scripts/Data/Filelist.cs.meta (limited to 'WorldlineKeepers/Assets/Scripts') diff --git a/WorldlineKeepers/Assets/Scripts/ConstDefine.cs b/WorldlineKeepers/Assets/Scripts/ConstDefine.cs index 6cbe017..f99f0b2 100644 --- a/WorldlineKeepers/Assets/Scripts/ConstDefine.cs +++ b/WorldlineKeepers/Assets/Scripts/ConstDefine.cs @@ -2,9 +2,17 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; -public class ConstDefine +namespace WK { + /// + /// 游戏性相关的常量 + /// + public class ConstDefine + { -} + + } + +} \ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs index 3bb9ef2..1c148ee 100644 --- a/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager.cs @@ -7,13 +7,18 @@ using UnityEngine; namespace WK.Data { - public class DataManager : Singleton + /// + /// 所有配置数据 + /// + 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; diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs new file mode 100644 index 0000000..886446a --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs @@ -0,0 +1,38 @@ +using LitJson; +using System; +using System.Collections; +using System.Collections.Generic; +using Unity.VisualScripting; +using UnityEngine; +using MovementEffects; + +namespace WK.Data +{ + public partial class DataManager : Singleton + { + + /// + /// 异步加载所有数据 + /// + /// + public IEnumerator AsyncLoadAllData() + { + Load_Filelist(); + yield return Timing.WaitForSeconds(StaticDefine.IntervalLoadFile); + } + + private void Load_Filelist() + { + TextAsset text = ResourceManager.Instance.LoadAsset(StaticDefine.FileList); + string content = text.text; + List files = CSVReader.Read(content); + for (int i = 0; i < files.Count; ++i) + { + MetadataFile file = files[i]; + int key = (int)Enum.Parse(typeof(EFileKey), file.key); + m_Filelist.Add(key, file); + } + } + + } +} \ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs.meta b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs.meta new file mode 100644 index 0000000..1b51533 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f346cc2edf9eab84f92fd6fb0a8969b3 +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 new file mode 100644 index 0000000..094c1ea --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/Filelist.cs @@ -0,0 +1,41 @@ +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 enum EFileKey + { + default_stats = 1, + default_buffs = 2, + default_items = 3, + } + + /// + /// 文件列表 + /// + 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 new file mode 100644 index 0000000..9bb6057 --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Data/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/Stages/GameStageManager.cs b/WorldlineKeepers/Assets/Scripts/Stages/GameStageManager.cs index d5caf15..8c746a5 100644 --- a/WorldlineKeepers/Assets/Scripts/Stages/GameStageManager.cs +++ b/WorldlineKeepers/Assets/Scripts/Stages/GameStageManager.cs @@ -1,6 +1,7 @@ using System.Collections; using System.Collections.Generic; using Unity.VisualScripting; +using UnityEditorInternal; using UnityEngine; using WK.Tools; @@ -59,6 +60,36 @@ namespace WK { } + public void AsyncLoadStage(int stage, bool forceLoad = false, AsyncStatemachine.LoadStateComplete loadStateComplete = null) + { + int curRunStage = m_Statemachine.GetCurStateID(); + if (!forceLoad && curRunStage == stages[stage]) + { + if (null != loadStateComplete) + { + loadStateComplete(); + } + return; + } + + //LogHelper.LogEditorError("==> StageChange:" + curStage + " --> " + (EGameStage)stage); + + prevStage = curStage; + curStage = (EGameStage)stage; + m_Statemachine.GotoState(stages[(int)stage], false, forceLoad, loadStateComplete); + } + + + public EGameStage GetCurStage() + { + return curStage; + } + + public EGameStage GetPrevStage() + { + return prevStage; + } + } } diff --git a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs index adf8f3e..05755ec 100644 --- a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs +++ b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs @@ -5,8 +5,13 @@ using UnityEngine; namespace WK { + /// + /// 非游戏性相关的常量(比如文件路径) + /// public class StaticDefine { + public const float IntervalLoadFile = 0.1f; + public static string StatsFilePath = "metadata/default_stats.csv"; public static string BuffFilePath = "metadata/default_buffs.csv"; @@ -15,6 +20,8 @@ namespace WK public static string Scene_Dojo = "Scenes/3_Dojo"; public static string Scene_Stage = "Scenes/4_Stage"; + public static string FileList = "metadata/filelist.csv"; + } } \ No newline at end of file -- cgit v1.1-26-g67d0