基础内容-2

Track Percent Point 和 Track Head Point 重构优化

Note基础

特效框架(Effect Submodule 和 Effect基础类),将用于“时间触发型特效容器”与“Note特效容器“
This commit is contained in:
SoulliesOfficial
2025-01-27 10:29:38 -05:00
parent 8d0abec75f
commit 8d887d5a7c
25 changed files with 449 additions and 102 deletions

View File

@@ -19,7 +19,8 @@ namespace Ichni
public float totalTime; //总时间
public AnimationCurveType animationCurveType; //动画曲线类型
public AnimatedFloat(float startTime, float endTime, float startValue, float endValue, AnimationCurveType animationCurveType)
public AnimatedFloat(float startTime, float endTime, float startValue, float endValue,
AnimationCurveType animationCurveType)
{
this.startValue = startValue;
this.endValue = endValue;
@@ -66,8 +67,8 @@ namespace Ichni
{
animations.Sort();
}
/// <summary>
/// 在动画脚本的Update中更新value
/// </summary>
@@ -78,7 +79,8 @@ namespace Ichni
if (nowAnimatedFloat != null) //如果能获取到,表明当前时间点存在动画
{
//获取songTime时间点时基于动画曲线的AnimatedFloat比例点->01
float nowPercent = AnimationCurveEvaluator.Evaluate(nowAnimatedFloat.animationCurveType, (nowTime - nowAnimatedFloat.startTime) / nowAnimatedFloat.totalTime);
float nowPercent = AnimationCurveEvaluator.Evaluate(nowAnimatedFloat.animationCurveType,
(nowTime - nowAnimatedFloat.startTime) / nowAnimatedFloat.totalTime);
value = nowAnimatedFloat.startValue + nowPercent * nowAnimatedFloat.differenceValue; //计算value
returnType = FlexibleReturnType.MiddleExecuting;
return;
@@ -98,10 +100,11 @@ namespace Ichni
{
value = nowAnimatedFloat.startValue;
}
returnType = FlexibleReturnType.Before;
return;
}
if (nowTime > finalEndTime) //如果当前时间大于最后一个动画的结束时间
{
nowAnimatedFloat = animations[animations.Count - 1];
@@ -111,14 +114,16 @@ namespace Ichni
{
value = nowAnimatedFloat.endValue;
}
returnType = FlexibleReturnType.After;
return;
}
if (currentAnimationIndex >= 0)//如果当前时间点在动画之间
if (currentAnimationIndex >= 0) //如果当前时间点在动画之间
{
value = animations[currentAnimationIndex].endValue;
}
returnType = FlexibleReturnType.MiddleInterval;
return;
}
@@ -147,88 +152,5 @@ namespace Ichni
return null;
}
// [BurstCompile]
// public void UpdateFlexibleFloat(float nowTime)
// {
// var animationData = new NativeArray<AnimatedFloat>(animations.ToArray(), Allocator.TempJob);
// var result = new NativeArray<float>(1, Allocator.TempJob);
// var returnTypeResult = new NativeArray<FlexibleReturnType>(1, Allocator.TempJob);
//
// var job = new FlexibleFloatJob
// {
// nowTime = nowTime,
// animationData = animationData,
// result = result,
// returnTypeResult = returnTypeResult
// };
//
// var handle = job.Schedule();
// handle.Complete();
//
// value = result[0];
// returnType = returnTypeResult[0];
//
// animationData.Dispose();
// result.Dispose();
// returnTypeResult.Dispose();
// }
}
/*
[BurstCompile]
struct FlexibleFloatJob : IJob
{
public float nowTime;
[ReadOnly] public NativeArray<AnimatedFloat> animationData;
public NativeArray<float> result;
public NativeArray<FlexibleReturnType> returnTypeResult;
public void Execute()
{
FlexibleReturnType currentReturnType = FlexibleReturnType.None;
float outputValue = 0;
if(animationData.Length == 0)
{
result[0] = outputValue;
returnTypeResult[0] = currentReturnType;
return;
}
if (nowTime < animationData[0].startTime)
{
outputValue = animationData[0].startValue;
currentReturnType = FlexibleReturnType.Before;
}
else if (nowTime > animationData[animationData.Length - 1].endTime)
{
outputValue = animationData[animationData.Length - 1].endValue;
currentReturnType = FlexibleReturnType.After;
}
for (int i = 0; i < animationData.Length; i++)
{
var anim = animationData[i];
if (nowTime >= anim.startTime && nowTime <= anim.endTime)
{
float nowPercent = AnimationCurveEvaluator.Evaluate(anim.animationCurveType,(nowTime - anim.startTime) / anim.totalTime);
outputValue = anim.startValue + nowPercent * anim.differenceValue;
currentReturnType = FlexibleReturnType.MiddleExecuting;
break;
}
}
if (currentReturnType == FlexibleReturnType.None)
{
currentReturnType = FlexibleReturnType.MiddleInterval;
}
result[0] = outputValue;
returnTypeResult[0] = currentReturnType;
}
}*/
}

View File

@@ -28,6 +28,10 @@ namespace Ichni.RhythmGame
this.emissionEnabled = false;
this.originalEmissionColor = Color.black;
this.originalEmissionIntensity = 0;
this.currentBaseColor = originalBaseColor;
this.currentEmissionColor = Color.black;
this.currentEmissionIntensity = 0;
}
public ColorSubmodule(Color originalBaseColor, bool emissionEnabled, Color originalEmissionColor, float originalEmissionIntensity)
@@ -36,6 +40,10 @@ namespace Ichni.RhythmGame
this.emissionEnabled = emissionEnabled;
this.originalEmissionColor = originalEmissionColor;
this.originalEmissionIntensity = originalEmissionIntensity;
this.currentBaseColor = originalBaseColor;
this.currentEmissionColor = originalEmissionColor;
this.currentEmissionIntensity = originalEmissionIntensity;
}
}
}

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ichni.RhythmGame
{
public class EffectSubmodule : SubmoduleBase
{
public List<EffectBase> effectList;
}
public abstract class EffectBase
{
public abstract void Execute();
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67578ca8780234f6d9108a4ea88a5c82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -9,6 +9,9 @@ public class BasePrefabsCollection : SerializedScriptableObject
[Title("基础预制体")]
public GameObject emptyObject;
public GameObject elementFolder;
[Title("Track相关")]
public GameObject track;
public GameObject pathNode;
public Material defaultTrackMaterial;
}

View File

@@ -30,7 +30,7 @@ namespace Ichni
(t0.trackTimeSubmodule as TrackTimeSubmoduleMovable).NewInitialize(t0, 0, 1, 1, AnimationCurveType.Linear);
(t0.trackRendererSubmodule as TrackRendererSubmoduleAutoOrient).NewInitialize(t0);
var p0 = PathNode.GeneratePathNode("PathNode-0", t0, 0, Vector3.zero, Vector3.forward, 1, Color.white);
var p1 = PathNode.GeneratePathNode("PathNode-1", t0, 1, Vector3.one * 10f, Vector3.left, 0, Color.white);
var p1 = PathNode.GeneratePathNode("PathNode-1", t0, 1, Vector3.one * 10f, Vector3.left, 0, Color.red);
t0.AfterInitialize();
}

View File

@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PostProcessingManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b242683d247c4ee59ef50fd8ef06701
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: