diff --git a/Assets/Convention-Unity.meta b/Assets/Convention.meta similarity index 77% rename from Assets/Convention-Unity.meta rename to Assets/Convention.meta index c52cba9..a10e9d3 100644 --- a/Assets/Convention-Unity.meta +++ b/Assets/Convention.meta @@ -1,5 +1,5 @@ fileFormatVersion: 2 -guid: 0667b42895d3e8d49899aabe3006d732 +guid: 2b3ed32090a476b46b21bd207b4d2d34 folderAsset: yes DefaultImporter: externalObjects: {} diff --git a/Assets/Scripts/Framework/DDT.cs b/Assets/Scripts/Framework/DDT.cs index 3284a1a..bfdbda4 100644 --- a/Assets/Scripts/Framework/DDT.cs +++ b/Assets/Scripts/Framework/DDT.cs @@ -16,30 +16,34 @@ namespace Demo.Game public List Datas = new(); [ScriptableCall(@" -添加float数据, 随后可以用对象路径+索引获取变量值, +添加float数据(允许使用除本以外的表达式), 随后可以用对象路径+索引获取变量值, e.g: CameraObject/DDT[3], 获取CameraObject/DDT对象路径下DDT数据中的第四个值 ")] public void Add(string value) { - Datas.Add(float.Parse(value)); + Datas.Add(Parse(value)); } /// - /// 从特定的json中读取数据 + /// 从特定的json中读取数据, 并调用 /// - [ScriptableCall(@"从特定的json中读取数据")] + [ScriptableCall(@"从特定的json中读取数据, 并调用Add函数")] public void Load() { var file = new ToolFile(BindingDataJson); if (file.Exists() == false) { file.MustExistsPath() - .SaveAsJson>(new()); + .SaveAsJson>(new()); Datas.Clear(); } else { - Datas = file.LoadAsJson>(); + Datas.Clear(); + foreach (var item in file.LoadAsJson>()) + { + Add(item); + } } } } diff --git a/Assets/Scripts/Framework/GameContent/GameController.cs b/Assets/Scripts/Framework/GameContent/GameController.cs index 41a722f..a3a9fdd 100644 --- a/Assets/Scripts/Framework/GameContent/GameController.cs +++ b/Assets/Scripts/Framework/GameContent/GameController.cs @@ -80,7 +80,11 @@ namespace Demo.Game { IEnumerator Run() { +#if ENABLE_CLASS_Interaction var clipFile = new Interaction(clipPath); +#else + var clipFile = new ToolFile(clipPath); +#endif if (clipFile.Exists() == false) clipFile = new(MainConfig.GetFile(clipPath).GetFullPath()); if (clipFile.Exists() == false) @@ -109,6 +113,7 @@ namespace Demo.Game { ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen; ScriptableObject.IsAutoPlay = content.IsAutoPlay; + ScriptableObject.OneBarTime = (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM); SetupSongDuration = GameContent.instance.SetupSongDuration; SetSongCurrentTime = GameContent.instance.SetSongCurrentTime; SongOffset = GameContent.instance.SongOffset; diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index 301aa32..e37a3cb 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -269,6 +269,7 @@ namespace Demo // 数值解析工具 private readonly Dictionary DDTCache = new(); + public static float OneBarTime = 1; /// /// 从时间点列表中获取 @@ -287,15 +288,34 @@ namespace Demo return result; if(value.EndsWith(']')) { - Regex regex = new(@"^(.*)\[(\d)\]$"); - var match = regex.Match(value); - if (match.Success) { - if (FindWithPath(match.Groups[1].Value) is DDT ddt) + Regex regex = new(@"^(.+)\[(\d+)\]$"); + var match = regex.Match(value); + if (match.Success) { - return ddt.Datas[int.Parse(match.Groups[2].Value)]; + if (FindWithPath(match.Groups[1].Value) is DDT ddt) + { + DDTCache[match.Groups[1].Value] = ddt; + } + return DDTCache[match.Groups[1].Value].Datas[int.Parse(match.Groups[2].Value)]; } } + throw new ArgumentException("value is end by ']' but not match on any invlid parse"); + } + if (value.EndsWith('}')) + { + { + Regex regex = new(@"^\{\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\}$"); + var match = regex.Match(value); + if (match.Success) + { + int barSplitTimes = int.Parse(match.Groups[1].Value); + int barCount = int.Parse(match.Groups[2].Value); + int tickCount = int.Parse(match.Groups[3].Value); + return (barCount + tickCount / (float)barSplitTimes) * OneBarTime; + } + } + throw new ArgumentException("value is end by '}' but not match on any invlid parse"); } return float.Parse(value); } @@ -871,7 +891,11 @@ namespace Demo file = file | "Windows"; #endif file = file | ab; +#if ENABLE_CLASS_Interaction var downloader = new Interaction(file.GetFullPath()); +#else + var downloader = new ToolFile(file.GetFullPath()); +#endif if (AssetBundlesItemEntry == null) { var hierarchy = HierarchyWindow.instance;