diff options
Diffstat (limited to 'WorldlineKeepers/Assets/Scripts')
10 files changed, 79 insertions, 10 deletions
diff --git a/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs index 3ce2663..ae5a132 100644 --- a/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs +++ b/WorldlineKeepers/Assets/Scripts/Common/CommonFunction.cs @@ -13,6 +13,12 @@ public static class CommonFunction File.Delete(file); } + string dir = Path.GetDirectoryName(file); + if(!Directory.Exists(dir)) + { + Directory.CreateDirectory(dir); + } + File.WriteAllText(file, content); } diff --git a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs index e5b78b4..bca064a 100644 --- a/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs +++ b/WorldlineKeepers/Assets/Scripts/Data/DataManager_Load.cs @@ -10,6 +10,10 @@ namespace WK.Data { public partial class DataManager : Singleton<DataManager> { + private bool m_IsLoaded = false; + public bool isLoaded => m_IsLoaded; + + private bool m_IsLoading = false; /// <summary> /// 异步加载数据 @@ -22,13 +26,24 @@ namespace WK.Data private IEnumerator<float> CoLoadAllData() { + PreLoad(); Load_Filelist(); + Load_DefaultStats(); yield return Timing.WaitForSeconds(StaticDefine.IntervalLoadFile); + PostLoad(); + } + + private void PreLoad() + { + m_IsLoading = true; + } + + private void PostLoad() + { + m_IsLoading = false; + m_IsLoaded = true; } - /// <summary> - /// fielist - /// </summary> private void Load_Filelist() { TextAsset text = ResourceManager.Instance.LoadAsset<TextAsset>(StaticDefine.FileList); @@ -36,6 +51,12 @@ namespace WK.Data CSVReader.ReadDictionary<string, FileDescriptor>(m_Filelist, content, "key"); } + private void Load_DefaultStats() + { + TextAsset text = ResourceManager.Instance.LoadAsset<TextAsset>(StaticDefine.StatsFilePath); + string content = text.text; + CSVReader.ReadDictionary<string, CharacterStatsMetadata>(m_CharacterStatsMetadata, content, "uid"); + } } }
\ No newline at end of file diff --git a/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs index 51d4d20..dff712e 100644 --- a/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs +++ b/WorldlineKeepers/Assets/Scripts/Data/Metadata/FileKey.cs @@ -9,6 +9,7 @@ namespace WK.Data default_buffs, default_items, spr_milk_bg, + spr_library_bg, all } diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Prefab.cs b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Prefab.cs new file mode 100644 index 0000000..1a8004b --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Prefab.cs @@ -0,0 +1,28 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using WK; +using WK.Data; + +public class StageEntity_Prefab : StageEntityBase +{ + public string fileKey; + + public override void OnDeserialize(StageEntityMetadata metadata) + { + StageEntityMetadata_Prefab meta = metadata as StageEntityMetadata_Prefab; + fileKey = meta.fileKey; + GameObject prefab = ResourceManager.Instance.LoadFile<GameObject>(fileKey); + if(prefab != null) + { + GameObject go = GameObject.Instantiate(prefab); + } + } + + public override StageEntityMetadata OnSerialize() + { + StageEntityMetadata_Prefab meta = new StageEntityMetadata_Prefab(); + meta.fileKey = fileKey; + return meta; + } +} diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Prefab.cs.meta b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Prefab.cs.meta new file mode 100644 index 0000000..0c658df --- /dev/null +++ b/WorldlineKeepers/Assets/Scripts/Stage/Entites/StageEntity_Prefab.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 66ec53ebfef24ed4592ca31e75708ca8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/WorldlineKeepers/Assets/Scripts/Stage/Metadata/StageMetadata.cs b/WorldlineKeepers/Assets/Scripts/Stage/Metadata/StageMetadata.cs index fd5e7d0..25e3e1a 100644 --- a/WorldlineKeepers/Assets/Scripts/Stage/Metadata/StageMetadata.cs +++ b/WorldlineKeepers/Assets/Scripts/Stage/Metadata/StageMetadata.cs @@ -48,6 +48,11 @@ namespace WK.Data { } + public sealed class StageEntityMetadata_Prefab : StageEntityMetadata + { + public string fileKey; + } + /// <summary> /// 关卡元数据 /// </summary> diff --git a/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs b/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs index 7b68181..e557518 100644 --- a/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs +++ b/WorldlineKeepers/Assets/Scripts/Stage/StageBuilder.cs @@ -39,8 +39,11 @@ public class StageBuilder : Singleton<StageBuilder> private IEnumerator<float> CoBuildStage(StageMetadata metadata, Transform root = null) { Build<StageEntity_Background, StageEntityMetadata_Background>(metadata.backgrounds, root); + yield return Timing.WaitForSeconds(StaticDefine.IntervalBuildStage); Build<StageEntity_Collider, StageEntityMetadata_Collider>(metadata.colliders, root); yield return Timing.WaitForSeconds(StaticDefine.IntervalBuildStage); + Build<StageEntity_Trigger, StageEntityMetadata_Trigger>(metadata.triggers, root); + yield return Timing.WaitForSeconds(StaticDefine.IntervalBuildStage); } } diff --git a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs index f2a9156..8bb1ff6 100644 --- a/WorldlineKeepers/Assets/Scripts/StaticDefine.cs +++ b/WorldlineKeepers/Assets/Scripts/StaticDefine.cs @@ -13,6 +13,7 @@ namespace WK public const float IntervalLoadFile = 0.1f; public const float IntervalBuildStage = 0.1f; + // 文件 public static string StatsFilePath = "metadata/default_stats.csv"; public static string BuffFilePath = "metadata/default_buffs.csv"; diff --git a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs index 49c6933..b03effa 100644 --- a/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs +++ b/WorldlineKeepers/Assets/Scripts/Stats/CharacterStatsBase.cs @@ -28,7 +28,6 @@ namespace WK public Color color; } - /// <summary> /// 运行时角色基础属性 /// </summary> @@ -61,11 +60,6 @@ namespace WK } } - //public T Access<T>() - //{ - // return null; - //} - } } diff --git a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs index 1964323..04b7e9f 100644 --- a/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs +++ b/WorldlineKeepers/Assets/Scripts/Unit/Characters/Ronin/RoninBehaviour.cs @@ -14,7 +14,6 @@ public class RoninBehaviour : CharacterBehaviour if (info.stats["max_health"] != null) { int health = info.stats["max_health"].intValue; - } } |