完成Note预制体的创建体系
This commit is contained in:
@@ -4,8 +4,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Convention;
|
using Convention;
|
||||||
using Unity.VisualScripting;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace Demo.Editor
|
namespace Demo.Editor
|
||||||
{
|
{
|
||||||
@@ -20,42 +18,56 @@ namespace Demo.Editor
|
|||||||
private static void WriteCPPClassBase(StreamWriter stream, Type currentType)
|
private static void WriteCPPClassBase(StreamWriter stream, Type currentType)
|
||||||
{
|
{
|
||||||
if (currentType == typeof(ScriptableObject))
|
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(@"/*
|
||||||
|
<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ
|
||||||
|
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;
|
string baseTypeName = currentType.BaseType.Name;
|
||||||
if (baseTypeName.Contains('`'))
|
if (baseTypeName.Contains('`'))
|
||||||
{
|
{
|
||||||
baseTypeName = baseTypeName[..baseTypeName.LastIndexOf('`')];
|
baseTypeName = baseTypeName[..baseTypeName.LastIndexOf('`')];
|
||||||
}
|
}
|
||||||
stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n#define {typeName}\n\n");
|
stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n");
|
||||||
stream.Write(@"/*
|
|
||||||
<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭ
|
|
||||||
e.g: LoadSubScript(SplineCore, ""SplineCore.h"") with(r = 1, g = 1, b = 1);
|
|
||||||
*/");
|
|
||||||
stream.Write($"#define with(...)\n\n");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void WriteCPPStyleFunction(StreamWriter stream, string name, IEnumerable<string> paramList, string description)
|
private static void WriteCPPStyleFunction(StreamWriter stream, string name, IEnumerable<string> paramList, string description)
|
||||||
{
|
{
|
||||||
if (name == nameof(ScriptableObject.LoadSubScript))
|
if (name == nameof(ScriptableObject.LoadSubScript))
|
||||||
{
|
{
|
||||||
stream.WriteLine("#define __build_in_pragma #");
|
stream.WriteLine("#define __build_in_pragma #");
|
||||||
stream.WriteLine("#define __build_in_to_text(x) #x");
|
stream.WriteLine("#define __build_in_to_text(x) #x");
|
||||||
|
|
||||||
stream.Write("/*\n" + description + "\n*/\n");
|
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)}) __build_in_pragma include {paramList.ToArray()[1]}\n\n");
|
||||||
//stream.Write($"#define {name}({string.Join(',', paramList)})\n\n");
|
//stream.Write($"#define {name}({string.Join(',', paramList)})\n\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
stream.Write("/*\n" + description + "\n*/\n");
|
stream.Write("/*\n" + description + "\n*/\n");
|
||||||
stream.Write($"#define {name}({string.Join(',', paramList)}) \n\n");
|
stream.Write($"#define {name}({string.Join(',', paramList)}) \n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CreateHelperFiles(string dir, ProjectDefaultFileStyle style = ProjectDefaultFileStyle.CPP)
|
public static void CreateHelperFiles(string dir, ProjectDefaultFileStyle style = ProjectDefaultFileStyle.CPP)
|
||||||
|
|||||||
@@ -120,12 +120,33 @@ namespace Demo.Game
|
|||||||
// Setup Game Rules (Main)
|
// Setup Game Rules (Main)
|
||||||
if (Editor.EditorController.instance.MainGameController == this)
|
if (Editor.EditorController.instance.MainGameController == this)
|
||||||
{
|
{
|
||||||
ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen;
|
// Config ScriptableObject
|
||||||
ScriptableObject.IsAutoPlay = content.IsAutoPlay;
|
{
|
||||||
ScriptableObject.OneBarTime = 60.0f / (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM);
|
ScriptableObject.FastScriptableObjectTypen = content.ScriptableObjectTypen;
|
||||||
SongOffset = (float)MainConfig.FindItem(nameof(SongOffset), SongOffset);
|
ScriptableObject.IsAutoPlay = content.IsAutoPlay;
|
||||||
SetupSongDuration = GameContent.instance.SetupSongDuration;
|
ScriptableObject.OneBarTime = 60.0f / (float)MainConfig.FindItem(nameof(Editor.EditorController.BPM), Editor.EditorController.instance.BPM);
|
||||||
SetSongCurrentTime = GameContent.instance.SetSongCurrentTime;
|
}
|
||||||
|
// 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
|
// Setup Game Rules
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,6 +43,11 @@ namespace Demo.Game
|
|||||||
|
|
||||||
public void EnableScript(string sourcePath, string scriptPath, GameController parent)
|
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);
|
base.EnableScript(sourcePath, scriptPath, nameof(RootObject), null);
|
||||||
RootGameController = parent;
|
RootGameController = parent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -618,6 +618,8 @@ namespace Demo
|
|||||||
// Hierarchy
|
// Hierarchy
|
||||||
|
|
||||||
public PropertiesWindow.ItemEntry MyHierarchyItem;
|
public PropertiesWindow.ItemEntry MyHierarchyItem;
|
||||||
|
public static PropertiesWindow.ItemEntry AllScriptableObjectCounterHierarchyItem;
|
||||||
|
public static int AllScriptableObjectCounter = 0;
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
|
|
||||||
@@ -1003,6 +1005,11 @@ namespace Demo
|
|||||||
{
|
{
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
// 增数
|
||||||
|
{
|
||||||
|
AllScriptableObjectCounter++;
|
||||||
|
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||||
|
}
|
||||||
yield return ParseScript2Expr(script);
|
yield return ParseScript2Expr(script);
|
||||||
IsEnableUpdate = true;
|
IsEnableUpdate = true;
|
||||||
}
|
}
|
||||||
@@ -1040,6 +1047,9 @@ namespace Demo
|
|||||||
this.name = "<Unload>";
|
this.name = "<Unload>";
|
||||||
// 清理Cache
|
// 清理Cache
|
||||||
DDTCache.Clear();
|
DDTCache.Clear();
|
||||||
|
// 减数
|
||||||
|
AllScriptableObjectCounter--;
|
||||||
|
AllScriptableObjectCounterHierarchyItem.GetHierarchyItem().text = $"ScriptableObjectCount: {AllScriptableObjectCounter}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,14 @@ namespace Demo.Game
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void OnInit()
|
||||||
|
{
|
||||||
|
foreach (var child in Prefabs)
|
||||||
|
{
|
||||||
|
child.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void OnBegin()
|
public override void OnBegin()
|
||||||
{
|
{
|
||||||
foreach (var child in Prefabs)
|
foreach (var child in Prefabs)
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Convention;
|
using Convention;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@@ -19,6 +18,7 @@ namespace Demo.Game
|
|||||||
[Content, SerializeField] private IInteraction MyInteractionModule;
|
[Content, SerializeField] private IInteraction MyInteractionModule;
|
||||||
[Content, SerializeField] private InteractiveEffectType MyInteractiveLevel = default;
|
[Content, SerializeField] private InteractiveEffectType MyInteractiveLevel = default;
|
||||||
|
|
||||||
|
public abstract void OnInit();
|
||||||
public abstract void OnBegin();
|
public abstract void OnBegin();
|
||||||
public abstract void OnEnd();
|
public abstract void OnEnd();
|
||||||
|
|
||||||
@@ -31,24 +31,28 @@ namespace Demo.Game
|
|||||||
{
|
{
|
||||||
case InteractiveEffectType.VisibleDuration:
|
case InteractiveEffectType.VisibleDuration:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.VisibleDurationBeforeEvent.AddListener(OnInit);
|
||||||
MyInteractionModule.VisibleDurationBeginEvent.AddListener(OnBegin);
|
MyInteractionModule.VisibleDurationBeginEvent.AddListener(OnBegin);
|
||||||
MyInteractionModule.VisibleDurationEndEvent.AddListener(OnEnd);
|
MyInteractionModule.VisibleDurationEndEvent.AddListener(OnEnd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractiveEffectType.InteractiveDuration:
|
case InteractiveEffectType.InteractiveDuration:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.InteractiveDurationBeforeEvent.AddListener(OnInit);
|
||||||
MyInteractionModule.InteractiveDurationBeginEvent.AddListener(OnBegin);
|
MyInteractionModule.InteractiveDurationBeginEvent.AddListener(OnBegin);
|
||||||
MyInteractionModule.InteractiveDurationEndEvent.AddListener(OnEnd);
|
MyInteractionModule.InteractiveDurationEndEvent.AddListener(OnEnd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractiveEffectType.InteractableScoreInterval:
|
case InteractiveEffectType.InteractableScoreInterval:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.InteractableScoreIntervalBeforeEvent.AddListener(OnInit);
|
||||||
MyInteractionModule.InteractableScoreIntervalBeginEvent.AddListener(OnBegin);
|
MyInteractionModule.InteractableScoreIntervalBeginEvent.AddListener(OnBegin);
|
||||||
MyInteractionModule.InteractableScoreIntervalEndEvent.AddListener(OnEnd);
|
MyInteractionModule.InteractableScoreIntervalEndEvent.AddListener(OnEnd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractiveEffectType.InteractableIntervalThatCanScoreBest:
|
case InteractiveEffectType.InteractableIntervalThatCanScoreBest:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.InteractableIntervalThatCanScoreBestBeforeEvent.AddListener(OnInit);
|
||||||
MyInteractionModule.InteractableIntervalThatCanScoreBestBeginEvent.AddListener(OnBegin);
|
MyInteractionModule.InteractableIntervalThatCanScoreBestBeginEvent.AddListener(OnBegin);
|
||||||
MyInteractionModule.InteractableIntervalThatCanScoreBestEndEvent.AddListener(OnEnd);
|
MyInteractionModule.InteractableIntervalThatCanScoreBestEndEvent.AddListener(OnEnd);
|
||||||
}
|
}
|
||||||
@@ -65,24 +69,28 @@ namespace Demo.Game
|
|||||||
{
|
{
|
||||||
case InteractiveEffectType.VisibleDuration:
|
case InteractiveEffectType.VisibleDuration:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.VisibleDurationBeforeEvent.RemoveListener(OnInit);
|
||||||
MyInteractionModule.VisibleDurationBeginEvent.RemoveListener(OnBegin);
|
MyInteractionModule.VisibleDurationBeginEvent.RemoveListener(OnBegin);
|
||||||
MyInteractionModule.VisibleDurationEndEvent.RemoveListener(OnEnd);
|
MyInteractionModule.VisibleDurationEndEvent.RemoveListener(OnEnd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractiveEffectType.InteractiveDuration:
|
case InteractiveEffectType.InteractiveDuration:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.InteractiveDurationBeforeEvent.RemoveListener(OnInit);
|
||||||
MyInteractionModule.InteractiveDurationBeginEvent.RemoveListener(OnBegin);
|
MyInteractionModule.InteractiveDurationBeginEvent.RemoveListener(OnBegin);
|
||||||
MyInteractionModule.InteractiveDurationEndEvent.RemoveListener(OnEnd);
|
MyInteractionModule.InteractiveDurationEndEvent.RemoveListener(OnEnd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractiveEffectType.InteractableScoreInterval:
|
case InteractiveEffectType.InteractableScoreInterval:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.InteractableScoreIntervalBeforeEvent.RemoveListener(OnInit);
|
||||||
MyInteractionModule.InteractableScoreIntervalBeginEvent.RemoveListener(OnBegin);
|
MyInteractionModule.InteractableScoreIntervalBeginEvent.RemoveListener(OnBegin);
|
||||||
MyInteractionModule.InteractableScoreIntervalEndEvent.RemoveListener(OnEnd);
|
MyInteractionModule.InteractableScoreIntervalEndEvent.RemoveListener(OnEnd);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case InteractiveEffectType.InteractableIntervalThatCanScoreBest:
|
case InteractiveEffectType.InteractableIntervalThatCanScoreBest:
|
||||||
{
|
{
|
||||||
|
MyInteractionModule.InteractableIntervalThatCanScoreBestBeforeEvent.RemoveListener(OnInit);
|
||||||
MyInteractionModule.InteractableIntervalThatCanScoreBestBeginEvent.RemoveListener(OnBegin);
|
MyInteractionModule.InteractableIntervalThatCanScoreBestBeginEvent.RemoveListener(OnBegin);
|
||||||
MyInteractionModule.InteractableIntervalThatCanScoreBestEndEvent.RemoveListener(OnEnd);
|
MyInteractionModule.InteractableIntervalThatCanScoreBestEndEvent.RemoveListener(OnEnd);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Convention;
|
using Convention;
|
||||||
using Demo.Editor.UI;
|
using Demo.Editor.UI;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@@ -19,6 +19,7 @@ namespace Demo.Game
|
|||||||
item.SetupDuration(new(VisibleDuration.x, VisibleDuration.y), GetTimelineItemColor());
|
item.SetupDuration(new(VisibleDuration.x, VisibleDuration.y), GetTimelineItemColor());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
public enum DurationStats
|
public enum DurationStats
|
||||||
{
|
{
|
||||||
BeforeBegin = 0,
|
BeforeBegin = 0,
|
||||||
@@ -27,24 +28,34 @@ namespace Demo.Game
|
|||||||
Judgement
|
Judgement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public const float IdentifiableJudgementTerminal = 0.16f;
|
||||||
|
|
||||||
[Header(nameof(VisibleDuration))]
|
[Header(nameof(VisibleDuration))]
|
||||||
[Content, SerializeField] private Vector2 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;
|
[Content, SerializeField] private DurationStats VisibleDurationStats = default;
|
||||||
|
|
||||||
[Header(nameof(InteractiveDuration))]
|
[Header(nameof(InteractiveDuration))]
|
||||||
[Content, SerializeField] private Vector2 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;
|
[Content, SerializeField] private DurationStats InteractiveDurationStats = default;
|
||||||
|
|
||||||
[Header(nameof(InteractableScoreInterval))]
|
[Header(nameof(InteractableScoreInterval))]
|
||||||
[Content, SerializeField] private Vector2 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;
|
[Content, SerializeField] private DurationStats InteractableScoreIntervalStats = default;
|
||||||
|
|
||||||
[Header(nameof(InteractableIntervalThatCanScoreBest))]
|
[Header(nameof(InteractableIntervalThatCanScoreBest))]
|
||||||
[Content, SerializeField] private Vector2 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;
|
[Content, SerializeField] private DurationStats InteractableIntervalThatCanScoreBestStats = default;
|
||||||
|
|
||||||
[Header("Judgement")]
|
[Header("Judgement")]
|
||||||
@@ -70,9 +81,9 @@ namespace Demo.Game
|
|||||||
public override IEnumerator LoadScript(string script)
|
public override IEnumerator LoadScript(string script)
|
||||||
{
|
{
|
||||||
yield return base.LoadScript(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();
|
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)
|
float current, DurationStats currentStats)
|
||||||
{
|
{
|
||||||
if (currentStats == DurationStats.After)
|
if (currentStats == DurationStats.After)
|
||||||
return DurationStats.After;
|
return DurationStats.After;
|
||||||
else if (current < begin)
|
else if (current < begin)
|
||||||
|
{
|
||||||
|
if (currentStats != DurationStats.BeforeBegin)
|
||||||
|
beforeEvent.Invoke();
|
||||||
return DurationStats.BeforeBegin;
|
return DurationStats.BeforeBegin;
|
||||||
|
}
|
||||||
else if (current < end)
|
else if (current < end)
|
||||||
{
|
{
|
||||||
if (currentStats == DurationStats.BeforeBegin)
|
if (currentStats == DurationStats.BeforeBegin)
|
||||||
@@ -136,41 +151,103 @@ namespace Demo.Game
|
|||||||
|
|
||||||
public abstract JudgementLevel JudgementBehaviour(float timePoint);
|
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)
|
protected override void UpdateTicks(float currentTime, float deltaTime, TickType tickType)
|
||||||
{
|
{
|
||||||
if (tickType == TickType.Start || tickType == TickType.Reset)
|
base.UpdateTicks(currentTime, deltaTime, tickType);
|
||||||
{
|
// 预判断
|
||||||
VisibleDurationStats = DurationStats.BeforeBegin;
|
|
||||||
InteractiveDurationStats = DurationStats.BeforeBegin;
|
|
||||||
InteractableScoreIntervalStats = DurationStats.BeforeBegin;
|
|
||||||
InteractableIntervalThatCanScoreBestStats = DurationStats.BeforeBegin;
|
|
||||||
}
|
|
||||||
//预判断
|
|
||||||
if (VisibleDurationStats == DurationStats.Judgement)
|
if (VisibleDurationStats == DurationStats.Judgement)
|
||||||
return;
|
return;
|
||||||
//检定
|
// 检定
|
||||||
InvokeJudgement(JudgementBehaviour(currentTime));
|
InvokeJudgement(JudgementBehaviour(currentTime));
|
||||||
if (tickType == TickType.Update)
|
// 更新状态
|
||||||
{
|
DoUpdateJudgementStats(currentTime);
|
||||||
// 可见区间
|
}
|
||||||
VisibleDurationStats = UpdateDurationStats(VisibleDuration.x, VisibleDurationBeginEvent, VisibleDuration.y, VisibleDurationEndEvent,
|
|
||||||
currentTime, VisibleDurationStats);
|
public void DoSetupJudgementLevels(
|
||||||
if (VisibleDurationStats != DurationStats.BeforeEnd)
|
float bestJudgementTimePoint,
|
||||||
return;
|
float interactableIntervalThatCanScoreBest,
|
||||||
// 可判定区间
|
float interactableScoreInterval,
|
||||||
InteractiveDurationStats = UpdateDurationStats(InteractiveDuration.x, InteractiveDurationBeginEvent, InteractiveDuration.y, InteractiveDurationEndEvent,
|
float interactiveDuration,
|
||||||
currentTime, InteractiveDurationStats);
|
float visibleDuration)
|
||||||
if (InteractiveDurationStats != DurationStats.BeforeEnd)
|
{
|
||||||
return;
|
this.BestJudgementTimePoint = bestJudgementTimePoint;
|
||||||
// 1级判定区间
|
var bestJudgementTimePointValue = bestJudgementTimePoint;
|
||||||
InteractableScoreIntervalStats = UpdateDurationStats(InteractableScoreInterval.x, InteractableScoreIntervalBeginEvent, InteractableScoreInterval.y, InteractableScoreIntervalEndEvent,
|
// InteractableIntervalThatCanScoreBest
|
||||||
currentTime, InteractableScoreIntervalStats);
|
var interactableIntervalThatCanScoreBestValue = interactableIntervalThatCanScoreBest * 0.5f;
|
||||||
if (InteractableScoreIntervalStats != DurationStats.BeforeEnd)
|
InteractableIntervalThatCanScoreBest = new(bestJudgementTimePointValue - interactableIntervalThatCanScoreBestValue,
|
||||||
return;
|
bestJudgementTimePointValue + interactableIntervalThatCanScoreBestValue);
|
||||||
// 0级判定区间
|
|
||||||
InteractableIntervalThatCanScoreBestStats = UpdateDurationStats(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBestBeginEvent, InteractableIntervalThatCanScoreBest.y, InteractableIntervalThatCanScoreBestEndEvent,
|
// InteractableScoreInterval
|
||||||
currentTime, InteractableIntervalThatCanScoreBestStats);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用配置中的区间长度设置以最佳判定点为中心的各级区间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bestJudgementTimePoint">最佳判定点</param>
|
||||||
|
[ScriptableCall(@"
|
||||||
|
<summary>
|
||||||
|
使用配置中的区间长度设置以最佳判定点为中心的各级区间
|
||||||
|
</summary>
|
||||||
|
<param name=""bestJudgementTimePoint"">最佳判定点</param>
|
||||||
|
")]
|
||||||
|
public void SetupJudgement(string bestJudgementTimePoint)
|
||||||
|
{
|
||||||
|
DoSetupJudgement(Parse(bestJudgementTimePoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -206,26 +283,12 @@ namespace Demo.Game
|
|||||||
string interactiveDuration,
|
string interactiveDuration,
|
||||||
string visibleDuration)
|
string visibleDuration)
|
||||||
{
|
{
|
||||||
var bestJudgementTimePointValue = Parse(bestJudgementTimePoint);
|
DoSetupJudgementLevels(
|
||||||
// InteractableIntervalThatCanScoreBest
|
Parse(bestJudgementTimePoint),
|
||||||
var interactableIntervalThatCanScoreBestValue = Parse(interactableIntervalThatCanScoreBest) * 0.5f;
|
Parse(interactableIntervalThatCanScoreBest),
|
||||||
InteractableIntervalThatCanScoreBest = new(bestJudgementTimePointValue - interactableIntervalThatCanScoreBestValue,
|
Parse(interactableScoreInterval),
|
||||||
bestJudgementTimePointValue + interactableIntervalThatCanScoreBestValue);
|
Parse(interactiveDuration),
|
||||||
|
Parse(visibleDuration));
|
||||||
// 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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -328,6 +391,10 @@ namespace Demo.Game
|
|||||||
public void SetInteractableIntervalThatCanScoreBestBegin(string value)
|
public void SetInteractableIntervalThatCanScoreBestBegin(string value)
|
||||||
{
|
{
|
||||||
InteractableIntervalThatCanScoreBest.x = Parse(value);
|
InteractableIntervalThatCanScoreBest.x = Parse(value);
|
||||||
|
if (BestJudgementTimePoint < 0)
|
||||||
|
{
|
||||||
|
BestJudgementTimePoint = Mathf.Lerp(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBest.y, 0.5f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置0级判定区间(最佳判定)结束时间
|
/// 设置0级判定区间(最佳判定)结束时间
|
||||||
@@ -342,6 +409,10 @@ namespace Demo.Game
|
|||||||
public void SetInteractableIntervalThatCanScoreBestEnd(string value)
|
public void SetInteractableIntervalThatCanScoreBestEnd(string value)
|
||||||
{
|
{
|
||||||
InteractableIntervalThatCanScoreBest.y = Parse(value);
|
InteractableIntervalThatCanScoreBest.y = Parse(value);
|
||||||
|
if (BestJudgementTimePoint < 0)
|
||||||
|
{
|
||||||
|
BestJudgementTimePoint = Mathf.Lerp(InteractableIntervalThatCanScoreBest.x, InteractableIntervalThatCanScoreBest.y, 0.5f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Demo.Game;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Demo.Game
|
namespace Demo.Game
|
||||||
@@ -14,6 +13,14 @@ namespace Demo.Game
|
|||||||
|
|
||||||
public SplineCore MySplineCore { get; set; }
|
public SplineCore MySplineCore { get; set; }
|
||||||
public BasicSplineRenderer MySplineRenderer { 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();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载并绑定到新样条线
|
/// 加载并绑定到新样条线
|
||||||
@@ -37,7 +44,8 @@ namespace Demo.Game
|
|||||||
")]
|
")]
|
||||||
public void EvaluatePosition(string value)
|
public void EvaluatePosition(string value)
|
||||||
{
|
{
|
||||||
transform.position = MySplineCore.MySplineComputer.EvaluatePosition(Parse(value));
|
MySplineOffset = Parse(value);
|
||||||
|
Updater = () => transform.position = MySplineCore.MySplineComputer.EvaluatePosition(MySplineOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -56,7 +64,9 @@ namespace Demo.Game
|
|||||||
")]
|
")]
|
||||||
public void LoadSplineRenderer(string path, string time)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
|
||||||
using Dreamteck.Splines;
|
using Dreamteck.Splines;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user