完成Note预制体的创建体系
This commit is contained in:
@@ -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(@"/*
|
||||
<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;
|
||||
if (baseTypeName.Contains('`'))
|
||||
{
|
||||
baseTypeName = baseTypeName[..baseTypeName.LastIndexOf('`')];
|
||||
}
|
||||
stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n#define {typeName}\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");
|
||||
|
||||
stream.Write($"#include \"{baseTypeName}.helper.h\"\n\n");
|
||||
}
|
||||
|
||||
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_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)
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 = "<Unload>";
|
||||
// 清理Cache
|
||||
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()
|
||||
{
|
||||
foreach (var child in Prefabs)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用配置中的区间长度设置以最佳判定点为中心的各级区间
|
||||
/// </summary>
|
||||
/// <param name="bestJudgementTimePoint">最佳判定点</param>
|
||||
[ScriptableCall(@"
|
||||
<summary>
|
||||
使用配置中的区间长度设置以最佳判定点为中心的各级区间
|
||||
</summary>
|
||||
<param name=""bestJudgementTimePoint"">最佳判定点</param>
|
||||
")]
|
||||
public void SetupJudgement(string bestJudgementTimePoint)
|
||||
{
|
||||
DoSetupJudgement(Parse(bestJudgementTimePoint));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 设置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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载并绑定到新样条线
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user