diff --git a/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs b/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs index 3dfc0b2..ba0fa77 100644 --- a/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs +++ b/Assets/Scripts/Framework/EditiorContent/ProjectCreateHelper.cs @@ -4,8 +4,6 @@ using System.IO; using System.Linq; using System.Reflection; using Convention; -using Unity.VisualScripting; -using UnityEngine; namespace Demo.Editor { @@ -20,42 +18,56 @@ namespace Demo.Editor private static void WriteCPPClassBase(StreamWriter stream, Type currentType) { if (currentType == typeof(ScriptableObject)) - return; - string typeName = currentType.Name; - if (typeName.Contains('`')) { - typeName = typeName[..typeName.LastIndexOf('`')]; + + foreach (var asm in AppDomain.CurrentDomain.GetAssemblies()) + { + foreach (var type in asm.GetTypes()) + { + // Functions + if (typeof(ScriptableObject).IsAssignableFrom(type)) + { + string typeName = type.Name; + if (typeName.Contains('`')) + { + typeName = typeName[..typeName.LastIndexOf('`')]; + } + stream.WriteLine($"#define {typeName}"); + } + } + } + + stream.Write(@"/* +临时设置上下文变量, 在运行完语句后将还原 +e.g: LoadSubScript(SplineCore, ""SplineCore.h"") with(r = 1, g = 1, b = 1); +*/"); + stream.Write($"#define with(...)\n\n"); + return; } string baseTypeName = currentType.BaseType.Name; if (baseTypeName.Contains('`')) { baseTypeName = baseTypeName[..baseTypeName.LastIndexOf('`')]; } - stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n#define {typeName}\n\n"); - stream.Write(@"/* -临时设置上下文变量, 在运行完语句后将还原 -e.g: LoadSubScript(SplineCore, ""SplineCore.h"") with(r = 1, g = 1, b = 1); -*/"); - stream.Write($"#define with(...)\n\n"); - + stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n"); } private static void WriteCPPStyleFunction(StreamWriter stream, string name, IEnumerable paramList, string description) { - if (name == nameof(ScriptableObject.LoadSubScript)) - { + if (name == nameof(ScriptableObject.LoadSubScript)) + { stream.WriteLine("#define __build_in_pragma #"); stream.WriteLine("#define __build_in_to_text(x) #x"); stream.Write("/*\n" + description + "\n*/\n"); stream.Write($"#define {name}({string.Join(',', paramList)}) __build_in_pragma include {paramList.ToArray()[1]}\n\n"); //stream.Write($"#define {name}({string.Join(',', paramList)})\n\n"); - } - else - { - stream.Write("/*\n" + description + "\n*/\n"); - stream.Write($"#define {name}({string.Join(',', paramList)}) \n\n"); - } + } + else + { + stream.Write("/*\n" + description + "\n*/\n"); + stream.Write($"#define {name}({string.Join(',', paramList)}) \n\n"); + } } public static void CreateHelperFiles(string dir, ProjectDefaultFileStyle style = ProjectDefaultFileStyle.CPP) diff --git a/Assets/Scripts/Framework/GameContent/GameController.cs b/Assets/Scripts/Framework/GameContent/GameController.cs index 69d6301..88d8ccc 100644 --- a/Assets/Scripts/Framework/GameContent/GameController.cs +++ b/Assets/Scripts/Framework/GameContent/GameController.cs @@ -120,12 +120,33 @@ namespace Demo.Game // Setup Game Rules (Main) if (Editor.EditorController.instance.MainGameController == this) { - ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen; - ScriptableObject.IsAutoPlay = content.IsAutoPlay; - ScriptableObject.OneBarTime = 60.0f / (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM); - SongOffset = (float)MainConfig.FindItem(nameof(SongOffset), SongOffset); - SetupSongDuration = GameContent.instance.SetupSongDuration; - SetSongCurrentTime = GameContent.instance.SetSongCurrentTime; + // Config ScriptableObject + { + ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen; + ScriptableObject.IsAutoPlay = content.IsAutoPlay; + ScriptableObject.OneBarTime = 60.0f / (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM); + } + // Default IInteraction + { + IInteraction.DefaultInteractableIntervalLengthThatCanScoreBest = (float)MainConfig.FindItem( + nameof(IInteraction.DefaultInteractableIntervalLengthThatCanScoreBest), + IInteraction.DefaultInteractableIntervalLengthThatCanScoreBest); + IInteraction.DefaultInteractableScoreIntervalLength = (float)MainConfig.FindItem( + nameof(IInteraction.DefaultInteractableScoreIntervalLength), + IInteraction.DefaultInteractableScoreIntervalLength); + IInteraction.DefaultInteractiveLength = (float)MainConfig.FindItem( + nameof(IInteraction.DefaultInteractiveLength), + IInteraction.DefaultInteractiveLength); + IInteraction.DefaultVisibleLength = (float)MainConfig.FindItem( + nameof(IInteraction.DefaultVisibleLength), + IInteraction.DefaultVisibleLength); + } + // Config Game + { + SongOffset = (float)MainConfig.FindItem(nameof(SongOffset), SongOffset); + SetupSongDuration = GameContent.instance.SetupSongDuration; + SetSongCurrentTime = GameContent.instance.SetSongCurrentTime; + } } // Setup Game Rules { diff --git a/Assets/Scripts/Framework/RootObject.cs b/Assets/Scripts/Framework/RootObject.cs index e8b8482..f6508d8 100644 --- a/Assets/Scripts/Framework/RootObject.cs +++ b/Assets/Scripts/Framework/RootObject.cs @@ -43,6 +43,11 @@ namespace Demo.Game public void EnableScript(string sourcePath, string scriptPath, GameController parent) { + AllScriptableObjectCounter = 0; + if (AllScriptableObjectCounterHierarchyItem == null) + { + AllScriptableObjectCounterHierarchyItem = HierarchyWindow.instance.CreateRootItemEntryWithBinders(typeof(ScriptableObject))[0]; + } base.EnableScript(sourcePath, scriptPath, nameof(RootObject), null); RootGameController = parent; } diff --git a/Assets/Scripts/Framework/ScriptableObject.cs b/Assets/Scripts/Framework/ScriptableObject.cs index 51ec24c..d26e7d3 100644 --- a/Assets/Scripts/Framework/ScriptableObject.cs +++ b/Assets/Scripts/Framework/ScriptableObject.cs @@ -618,6 +618,8 @@ namespace Demo // Hierarchy public PropertiesWindow.ItemEntry MyHierarchyItem; + public static PropertiesWindow.ItemEntry AllScriptableObjectCounterHierarchyItem; + public static int AllScriptableObjectCounter = 0; // Cache @@ -1003,6 +1005,11 @@ namespace Demo { yield break; } + // 澧炴暟 + { + AllScriptableObjectCounter++; + AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}"; + } yield return ParseScript2Expr(script); IsEnableUpdate = true; } @@ -1040,6 +1047,9 @@ namespace Demo this.name = ""; // 娓呯悊Cache DDTCache.Clear(); + // 鍑忔暟 + AllScriptableObjectCounter--; + AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}"; } } } diff --git a/Assets/Scripts/Interaction/Effect/ParticleEffect.cs b/Assets/Scripts/Interaction/Effect/ParticleEffect.cs index 889594c..974f7d4 100644 --- a/Assets/Scripts/Interaction/Effect/ParticleEffect.cs +++ b/Assets/Scripts/Interaction/Effect/ParticleEffect.cs @@ -48,6 +48,14 @@ namespace Demo.Game }); } + public override void OnInit() + { + foreach (var child in Prefabs) + { + child.SetActive(false); + } + } + public override void OnBegin() { foreach (var child in Prefabs) diff --git a/Assets/Scripts/Interaction/IEffectHookObject.cs b/Assets/Scripts/Interaction/IEffectHookObject.cs index 8c2acaa..3c5d1da 100644 --- a/Assets/Scripts/Interaction/IEffectHookObject.cs +++ b/Assets/Scripts/Interaction/IEffectHookObject.cs @@ -1,6 +1,5 @@ using System; using System.Collections; -using System.Collections.Generic; using Convention; using UnityEngine; @@ -19,6 +18,7 @@ namespace Demo.Game [Content, SerializeField] private IInteraction MyInteractionModule; [Content, SerializeField] private InteractiveEffectType MyInteractiveLevel = default; + public abstract void OnInit(); public abstract void OnBegin(); public abstract void OnEnd(); @@ -31,24 +31,28 @@ namespace Demo.Game { case InteractiveEffectType.VisibleDuration: { + MyInteractionModule.VisibleDurationBeforeEvent.AddListener(OnInit); MyInteractionModule.VisibleDurationBeginEvent.AddListener(OnBegin); MyInteractionModule.VisibleDurationEndEvent.AddListener(OnEnd); } break; case InteractiveEffectType.InteractiveDuration: { + MyInteractionModule.InteractiveDurationBeforeEvent.AddListener(OnInit); MyInteractionModule.InteractiveDurationBeginEvent.AddListener(OnBegin); MyInteractionModule.InteractiveDurationEndEvent.AddListener(OnEnd); } break; case InteractiveEffectType.InteractableScoreInterval: { + MyInteractionModule.InteractableScoreIntervalBeforeEvent.AddListener(OnInit); MyInteractionModule.InteractableScoreIntervalBeginEvent.AddListener(OnBegin); MyInteractionModule.InteractableScoreIntervalEndEvent.AddListener(OnEnd); } break; case InteractiveEffectType.InteractableIntervalThatCanScoreBest: { + MyInteractionModule.InteractableIntervalThatCanScoreBestBeforeEvent.AddListener(OnInit); MyInteractionModule.InteractableIntervalThatCanScoreBestBeginEvent.AddListener(OnBegin); MyInteractionModule.InteractableIntervalThatCanScoreBestEndEvent.AddListener(OnEnd); } @@ -65,24 +69,28 @@ namespace Demo.Game { case InteractiveEffectType.VisibleDuration: { + MyInteractionModule.VisibleDurationBeforeEvent.RemoveListener(OnInit); MyInteractionModule.VisibleDurationBeginEvent.RemoveListener(OnBegin); MyInteractionModule.VisibleDurationEndEvent.RemoveListener(OnEnd); } break; case InteractiveEffectType.InteractiveDuration: { + MyInteractionModule.InteractiveDurationBeforeEvent.RemoveListener(OnInit); MyInteractionModule.InteractiveDurationBeginEvent.RemoveListener(OnBegin); MyInteractionModule.InteractiveDurationEndEvent.RemoveListener(OnEnd); } break; case InteractiveEffectType.InteractableScoreInterval: { + MyInteractionModule.InteractableScoreIntervalBeforeEvent.RemoveListener(OnInit); MyInteractionModule.InteractableScoreIntervalBeginEvent.RemoveListener(OnBegin); MyInteractionModule.InteractableScoreIntervalEndEvent.RemoveListener(OnEnd); } break; case InteractiveEffectType.InteractableIntervalThatCanScoreBest: { + MyInteractionModule.InteractableIntervalThatCanScoreBestBeforeEvent.RemoveListener(OnInit); MyInteractionModule.InteractableIntervalThatCanScoreBestBeginEvent.RemoveListener(OnBegin); MyInteractionModule.InteractableIntervalThatCanScoreBestEndEvent.RemoveListener(OnEnd); } diff --git a/Assets/Scripts/Interaction/IInteraction.cs b/Assets/Scripts/Interaction/IInteraction.cs index e1c726d..804e80a 100644 --- a/Assets/Scripts/Interaction/IInteraction.cs +++ b/Assets/Scripts/Interaction/IInteraction.cs @@ -1,5 +1,5 @@ +using System; using System.Collections; -using System.Collections.Generic; using Convention; using Demo.Editor.UI; using UnityEngine; @@ -19,6 +19,7 @@ namespace Demo.Game item.SetupDuration(new(VisibleDuration.x, VisibleDuration.y), GetTimelineItemColor()); } + [Serializable] public enum DurationStats { BeforeBegin = 0, @@ -27,24 +28,34 @@ namespace Demo.Game Judgement } + public const float IdentifiableJudgementTerminal = 0.16f; + [Header(nameof(VisibleDuration))] [Content, SerializeField] private Vector2 VisibleDuration; - [Content, SerializeField] public UnityEvent VisibleDurationBeginEvent = new(), VisibleDurationEndEvent = new(); + public static float DefaultVisibleLength = IdentifiableJudgementTerminal * 15; + [Content, SerializeField] public UnityEvent VisibleDurationBeforeEvent = new(), + VisibleDurationBeginEvent = new(), VisibleDurationEndEvent = new(); [Content, SerializeField] private DurationStats VisibleDurationStats = default; [Header(nameof(InteractiveDuration))] [Content, SerializeField] private Vector2 InteractiveDuration; - [Content, SerializeField] public UnityEvent InteractiveDurationBeginEvent = new(), InteractiveDurationEndEvent = new(); + public static float DefaultInteractiveLength = IdentifiableJudgementTerminal * 9; + [Content, SerializeField] public UnityEvent InteractiveDurationBeforeEvent = new(), + InteractiveDurationBeginEvent = new(), InteractiveDurationEndEvent = new(); [Content, SerializeField] private DurationStats InteractiveDurationStats = default; [Header(nameof(InteractableScoreInterval))] [Content, SerializeField] private Vector2 InteractableScoreInterval; - [Content, SerializeField] public UnityEvent InteractableScoreIntervalBeginEvent = new(), InteractableScoreIntervalEndEvent = new(); + public static float DefaultInteractableScoreIntervalLength = IdentifiableJudgementTerminal * 6; + [Content, SerializeField] public UnityEvent InteractableScoreIntervalBeforeEvent = new(), + InteractableScoreIntervalBeginEvent = new(), InteractableScoreIntervalEndEvent = new(); [Content, SerializeField] private DurationStats InteractableScoreIntervalStats = default; [Header(nameof(InteractableIntervalThatCanScoreBest))] [Content, SerializeField] private Vector2 InteractableIntervalThatCanScoreBest; - [Content, SerializeField] public UnityEvent InteractableIntervalThatCanScoreBestBeginEvent = new(), InteractableIntervalThatCanScoreBestEndEvent = new(); + public static float DefaultInteractableIntervalLengthThatCanScoreBest = IdentifiableJudgementTerminal * 3; + [Content, SerializeField] public UnityEvent InteractableIntervalThatCanScoreBestBeforeEvent = new(), + InteractableIntervalThatCanScoreBestBeginEvent = new(), InteractableIntervalThatCanScoreBestEndEvent = new(); [Content, SerializeField] private DurationStats InteractableIntervalThatCanScoreBestStats = default; [Header("Judgement")] @@ -70,9 +81,9 @@ namespace Demo.Game public override IEnumerator LoadScript(string script) { yield return base.LoadScript(script); - if (BestJudgementTimePoint < 0) + if (BestJudgementTimePoint <= 0) { - BestJudgementTimePoint = Mathf.Lerp(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBest.y, 0.5f); + DoSetupJudgement(0); } } @@ -105,13 +116,17 @@ namespace Demo.Game InteractableIntervalThatCanScoreBestEndEvent.Invoke(); } - private static DurationStats UpdateDurationStats(float begin, UnityEvent beginEvent, float end, UnityEvent endEvent, + private static DurationStats UpdateDurationStats(float begin, UnityEvent beforeEvent, UnityEvent beginEvent, float end, UnityEvent endEvent, float current, DurationStats currentStats) { if (currentStats == DurationStats.After) return DurationStats.After; else if (current < begin) + { + if (currentStats != DurationStats.BeforeBegin) + beforeEvent.Invoke(); return DurationStats.BeforeBegin; + } else if (current < end) { if (currentStats == DurationStats.BeforeBegin) @@ -136,41 +151,103 @@ namespace Demo.Game public abstract JudgementLevel JudgementBehaviour(float timePoint); + private void DoUpdateJudgementStats(float currentTime) + { + // 鍙鍖洪棿 + VisibleDurationStats = UpdateDurationStats(VisibleDuration.x, VisibleDurationBeforeEvent, + VisibleDurationBeginEvent, VisibleDuration.y, VisibleDurationEndEvent, + currentTime, VisibleDurationStats); + if (VisibleDurationStats != DurationStats.BeforeEnd) + return; + // 鍙垽瀹氬尯闂 + InteractiveDurationStats = UpdateDurationStats(InteractiveDuration.x, InteractiveDurationBeforeEvent, + InteractiveDurationBeginEvent, InteractiveDuration.y, InteractiveDurationEndEvent, + currentTime, InteractiveDurationStats); + if (InteractiveDurationStats != DurationStats.BeforeEnd) + return; + // 1绾у垽瀹氬尯闂 + InteractableScoreIntervalStats = UpdateDurationStats(InteractableScoreInterval.x, InteractableScoreIntervalBeforeEvent, + InteractableScoreIntervalBeginEvent, InteractableScoreInterval.y, InteractableScoreIntervalEndEvent, + currentTime, InteractableScoreIntervalStats); + if (InteractableScoreIntervalStats != DurationStats.BeforeEnd) + return; + // 0绾у垽瀹氬尯闂 + InteractableIntervalThatCanScoreBestStats = UpdateDurationStats(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBestBeforeEvent, + InteractableIntervalThatCanScoreBestBeginEvent, InteractableIntervalThatCanScoreBest.y, InteractableIntervalThatCanScoreBestEndEvent, + currentTime, InteractableIntervalThatCanScoreBestStats); + } + + public override void ResetEnterGameStatus() + { + base.ResetEnterGameStatus(); + DoUpdateJudgementStats(Mathf.NegativeInfinity); + } + protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType) { - if (tickType == TickType.Start || tickType == TickType.Reset) - { - VisibleDurationStats = DurationStats.BeforeBegin; - InteractiveDurationStats = DurationStats.BeforeBegin; - InteractableScoreIntervalStats = DurationStats.BeforeBegin; - InteractableIntervalThatCanScoreBestStats = DurationStats.BeforeBegin; - } - //棰勫垽鏂 + base.UpdateTicks(currentTime, deltaTime, tickType); + // 棰勫垽鏂 if (VisibleDurationStats == DurationStats.Judgement) return; - //妫瀹 + // 妫瀹 InvokeJudgement(JudgementBehaviour(currentTime)); - if (tickType == TickType.Update) - { - // 鍙鍖洪棿 - VisibleDurationStats = UpdateDurationStats(VisibleDuration.x, VisibleDurationBeginEvent, VisibleDuration.y, VisibleDurationEndEvent, - currentTime, VisibleDurationStats); - if (VisibleDurationStats != DurationStats.BeforeEnd) - return; - // 鍙垽瀹氬尯闂 - InteractiveDurationStats = UpdateDurationStats(InteractiveDuration.x, InteractiveDurationBeginEvent, InteractiveDuration.y, InteractiveDurationEndEvent, - currentTime, InteractiveDurationStats); - if (InteractiveDurationStats != DurationStats.BeforeEnd) - return; - // 1绾у垽瀹氬尯闂 - InteractableScoreIntervalStats = UpdateDurationStats(InteractableScoreInterval.x, InteractableScoreIntervalBeginEvent, InteractableScoreInterval.y, InteractableScoreIntervalEndEvent, - currentTime, InteractableScoreIntervalStats); - if (InteractableScoreIntervalStats != DurationStats.BeforeEnd) - return; - // 0绾у垽瀹氬尯闂 - InteractableIntervalThatCanScoreBestStats = UpdateDurationStats(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBestBeginEvent, InteractableIntervalThatCanScoreBest.y, InteractableIntervalThatCanScoreBestEndEvent, - currentTime, InteractableIntervalThatCanScoreBestStats); - } + // 鏇存柊鐘舵 + DoUpdateJudgementStats(currentTime); + } + + public void DoSetupJudgementLevels( + float bestJudgementTimePoint, + float interactableIntervalThatCanScoreBest, + float interactableScoreInterval, + float interactiveDuration, + float visibleDuration) + { + this.BestJudgementTimePoint = bestJudgementTimePoint; + var bestJudgementTimePointValue = bestJudgementTimePoint; + // InteractableIntervalThatCanScoreBest + var interactableIntervalThatCanScoreBestValue = interactableIntervalThatCanScoreBest * 0.5f; + InteractableIntervalThatCanScoreBest = new(bestJudgementTimePointValue - interactableIntervalThatCanScoreBestValue, + bestJudgementTimePointValue + interactableIntervalThatCanScoreBestValue); + + // InteractableScoreInterval + var interactableScoreIntervalValue = interactableScoreInterval * 0.5f; + InteractableScoreInterval = new(bestJudgementTimePointValue - interactableScoreIntervalValue, + bestJudgementTimePointValue + interactableScoreIntervalValue); + + // InteractiveDuration + var interactiveDurationValue = interactiveDuration * 0.5f; + InteractiveDuration = new(bestJudgementTimePointValue - interactiveDurationValue, + bestJudgementTimePointValue + interactiveDurationValue); + + // InteractableScoreInterval + var visibleDurationValue = visibleDuration * 0.5f; + VisibleDuration = new(bestJudgementTimePointValue - visibleDurationValue, + bestJudgementTimePointValue + visibleDurationValue); + } + + public void DoSetupJudgement(float bestJudgementTimePoint) + { + DoSetupJudgementLevels( + bestJudgementTimePoint, + DefaultInteractableIntervalLengthThatCanScoreBest, + DefaultInteractableScoreIntervalLength, + DefaultInteractiveLength, + DefaultVisibleLength); + } + + /// + /// 浣跨敤閰嶇疆涓殑鍖洪棿闀垮害璁剧疆浠ユ渶浣冲垽瀹氱偣涓轰腑蹇冪殑鍚勭骇鍖洪棿 + /// + /// 鏈浣冲垽瀹氱偣 + [ScriptableCall(@" + +浣跨敤閰嶇疆涓殑鍖洪棿闀垮害璁剧疆浠ユ渶浣冲垽瀹氱偣涓轰腑蹇冪殑鍚勭骇鍖洪棿 + +鏈浣冲垽瀹氱偣 +")] + public void SetupJudgement(string bestJudgementTimePoint) + { + DoSetupJudgement(Parse(bestJudgementTimePoint)); } /// @@ -206,26 +283,12 @@ namespace Demo.Game string interactiveDuration, string visibleDuration) { - var bestJudgementTimePointValue = Parse(bestJudgementTimePoint); - // InteractableIntervalThatCanScoreBest - var interactableIntervalThatCanScoreBestValue = Parse(interactableIntervalThatCanScoreBest) * 0.5f; - InteractableIntervalThatCanScoreBest = new(bestJudgementTimePointValue - interactableIntervalThatCanScoreBestValue, - bestJudgementTimePointValue + interactableIntervalThatCanScoreBestValue); - - // InteractableScoreInterval - var interactableScoreIntervalValue = Parse(interactableScoreInterval) * 0.5f; - InteractableScoreInterval = new(bestJudgementTimePointValue - interactableScoreIntervalValue, - bestJudgementTimePointValue + interactableScoreIntervalValue); - - // InteractiveDuration - var interactiveDurationValue = Parse(interactiveDuration) * 0.5f; - InteractiveDuration = new(bestJudgementTimePointValue - interactiveDurationValue, - bestJudgementTimePointValue + interactiveDurationValue); - - // InteractableScoreInterval - var visibleDurationValue = Parse(visibleDuration) * 0.5f; - VisibleDuration = new(bestJudgementTimePointValue - visibleDurationValue, - bestJudgementTimePointValue + visibleDurationValue); + DoSetupJudgementLevels( + Parse(bestJudgementTimePoint), + Parse(interactableIntervalThatCanScoreBest), + Parse(interactableScoreInterval), + Parse(interactiveDuration), + Parse(visibleDuration)); } /// @@ -328,6 +391,10 @@ namespace Demo.Game public void SetInteractableIntervalThatCanScoreBestBegin(string value) { InteractableIntervalThatCanScoreBest.x = Parse(value); + if (BestJudgementTimePoint < 0) + { + BestJudgementTimePoint = Mathf.Lerp(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBest.y, 0.5f); + } } /// /// 璁剧疆0绾у垽瀹氬尯闂达紙鏈浣冲垽瀹氾級缁撴潫鏃堕棿 @@ -342,6 +409,10 @@ namespace Demo.Game public void SetInteractableIntervalThatCanScoreBestEnd(string value) { InteractableIntervalThatCanScoreBest.y = Parse(value); + if (BestJudgementTimePoint < 0) + { + BestJudgementTimePoint = Mathf.Lerp(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBest.y, 0.5f); + } } } } diff --git a/Assets/Scripts/MoreSpline/SplineAnchor.cs b/Assets/Scripts/MoreSpline/SplineAnchor.cs index ab9b305..97a9565 100644 --- a/Assets/Scripts/MoreSpline/SplineAnchor.cs +++ b/Assets/Scripts/MoreSpline/SplineAnchor.cs @@ -1,6 +1,5 @@ +using System; using System.Collections; -using System.Collections.Generic; -using Demo.Game; using UnityEngine; namespace Demo.Game @@ -14,6 +13,14 @@ namespace Demo.Game public SplineCore MySplineCore { get; set; } public BasicSplineRenderer MySplineRenderer { get; set; } + public float MySplineOffset = 0; + private Action Updater = null; + + protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType) + { + base.UpdateTicks(currentTime, deltaTime, tickType); + Updater?.Invoke(); + } /// /// 鍔犺浇骞剁粦瀹氬埌鏂版牱鏉$嚎 @@ -37,7 +44,8 @@ namespace Demo.Game ")] public void EvaluatePosition(string value) { - transform.position = MySplineCore.MySplineComputer.EvaluatePosition(Parse(value)); + MySplineOffset = Parse(value); + Updater = () => transform.position = MySplineCore.MySplineComputer.EvaluatePosition(MySplineOffset); } /// @@ -56,7 +64,9 @@ namespace Demo.Game ")] public void LoadSplineRenderer(string path, string time) { - transform.position = this.LoadSplineRendererTool(path).EvaluateClipToPosition(Parse(time)); + MySplineRenderer = this.LoadSplineRendererTool(path); + MySplineOffset = Parse(time); + Updater =()=> transform.position = MySplineRenderer.EvaluateClipToPosition(MySplineOffset); } } } diff --git a/Assets/Scripts/MoreSpline/SplineNode.cs b/Assets/Scripts/MoreSpline/SplineNode.cs index 2705890..e2375e8 100644 --- a/Assets/Scripts/MoreSpline/SplineNode.cs +++ b/Assets/Scripts/MoreSpline/SplineNode.cs @@ -1,5 +1,4 @@ using System.Collections; -using System.Collections.Generic; using Dreamteck.Splines; using UnityEngine;