diff options
10 files changed, 168 insertions, 3 deletions
diff --git a/WorldlineKeepers/Assets/Bundle/metadata/filelist.csv b/WorldlineKeepers/Assets/Bundle/metadata/filelist.csv new file mode 100644 index 0000000..c7acbf6 --- /dev/null +++ b/WorldlineKeepers/Assets/Bundle/metadata/filelist.csv @@ -0,0 +1,6 @@ +key,type,root,path +"#type: 0-csv, 1-json, 2-txt",,, +"#root: 0-bundle, 1-streaming, 2-persistent",,, +default_stats,0,0,metadata/default_stats.csv +default_buffs,0,0,metadata/default_buffs.csv +default_items,0,0,metadata/default_items.csv diff --git a/WorldlineKeepers/Assets/Bundle/metadata/filelist.csv.meta b/WorldlineKeepers/Assets/Bundle/metadata/filelist.csv.meta new file mode 100644 index 0000000..1feafc6 --- /dev/null +++ b/WorldlineKeepers/Assets/Bundle/metadata/filelist.csv.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8d2996979df5c054a85cda1281876d93 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: 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 { + /// <summary> + /// 游戏性相关的常量 + /// </summary> + 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<DataManager> + /// <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<int, MetadataFile> m_Filelist = new Dictionary<int, MetadataFile>(); + 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<DataManager> + { + + /// <summary> + /// 异步加载所有数据 + /// </summary> + /// <returns></returns> + public IEnumerator<float> AsyncLoadAllData() + { + Load_Filelist(); + yield return Timing.WaitForSeconds(StaticDefine.IntervalLoadFile); + } + + private void Load_Filelist() + { + TextAsset text = ResourceManager.Instance.LoadAsset<TextAsset>(StaticDefine.FileList); + string content = text.text; + List<MetadataFile> files = CSVReader.Read<MetadataFile>(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, + } + + /// <summary> + /// 文件列表 + /// </summary> + 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 { + /// <summary> + /// 非游戏性相关的常量(比如文件路径) + /// </summary> 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 |