基础内容-2
Track Percent Point 和 Track Head Point 重构优化 Note基础 特效框架(Effect Submodule 和 Effect基础类),将用于“时间触发型特效容器”与“Note特效容器“
This commit is contained in:
@@ -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比例点->(0,1)。
|
||||
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;
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
16
Assets/Scripts/Base/GeneralSubmodules/EffectSubmodule.cs
Normal file
16
Assets/Scripts/Base/GeneralSubmodules/EffectSubmodule.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 67578ca8780234f6d9108a4ea88a5c82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
18
Assets/Scripts/Base/Manager/PostProcessingManager.cs
Normal file
18
Assets/Scripts/Base/Manager/PostProcessingManager.cs
Normal 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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Base/Manager/PostProcessingManager.cs.meta
Normal file
11
Assets/Scripts/Base/Manager/PostProcessingManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b242683d247c4ee59ef50fd8ef06701
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GameElements/EnvironmentObjects.meta
Normal file
8
Assets/Scripts/GameElements/EnvironmentObjects.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f9d3b833668d4a309f2dc75315c18e8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/GameElements/Notes.meta
Normal file
8
Assets/Scripts/GameElements/Notes.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62e1a33dede934d3fb2c3282b6641d59
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/Scripts/GameElements/Notes/NoteBase.cs
Normal file
33
Assets/Scripts/GameElements/Notes/NoteBase.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Sirenix.OdinInspector;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class NoteBase : BaseElement
|
||||
{
|
||||
[Title("Basic Info")]
|
||||
public float exactJudgeTime;
|
||||
|
||||
[Title("Track Info")]
|
||||
public bool isOnTrack;
|
||||
public Track track;
|
||||
public SplinePositioner trackPositioner;
|
||||
|
||||
// [Title("NoteVisual")]
|
||||
// public GeneralNoteVisual noteVisual;
|
||||
//
|
||||
// [Title("NoteEffect")]
|
||||
// public List<NoteEffectGenerate> noteEffectGenerateList;
|
||||
// public List<NoteEffectPerfect> noteEffectPerfectList;
|
||||
// public List<NoteEffectGood> noteEffectGoodList;
|
||||
// public List<NoteEffectMiss> noteEffectMissList;
|
||||
|
||||
[Title("In-Game Info")]
|
||||
public Vector2 noteScreenPosition;
|
||||
public bool isJudged;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/GameElements/Notes/NoteBase.cs.meta
Normal file
11
Assets/Scripts/GameElements/Notes/NoteBase.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95d3a881bc3654f05ba69138e8c703cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -34,11 +34,6 @@ namespace Ichni.RhythmGame
|
||||
this.track = track;
|
||||
this.index = index;
|
||||
|
||||
if (track.trackPathSubmodule.pathNodeList.Count > index)
|
||||
{
|
||||
this.index = track.trackPathSubmodule.pathNodeList.Count;
|
||||
}
|
||||
|
||||
this.transformSubmodule = new TransformSubmodule(nodePosition, Quaternion.LookRotation(nodeNormal, Vector3.up).eulerAngles, Vector3.one * nodeSize);
|
||||
this.colorSubmodule = new ColorSubmodule(nodeColor);
|
||||
|
||||
@@ -40,8 +40,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
public override void AfterInitialize()
|
||||
{
|
||||
trackPathSubmodule.path.RebuildImmediate();
|
||||
//Refresh();
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
8
Assets/Scripts/GameElements/Track/TrackPoints.meta
Normal file
8
Assets/Scripts/GameElements/Track/TrackPoints.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 50c407d9db7cf4ed096db0106bdc3c0c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class TrackHeadPoint : BaseElement
|
||||
{
|
||||
public Track track;
|
||||
public TrackTimeSubmoduleMovable trackTimeSubmoduleMovable;
|
||||
public SplinePositioner trackPositioner;
|
||||
|
||||
public static TrackHeadPoint GenerateElement(string elementName, Track track)
|
||||
{
|
||||
TrackHeadPoint head = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackHeadPoint>();
|
||||
|
||||
head.NewInitialize(elementName, track);
|
||||
head.SetParent(track);
|
||||
return head;
|
||||
}
|
||||
|
||||
private void NewInitialize(string elementName, Track track)
|
||||
{
|
||||
base.NewInitialize(elementName);
|
||||
this.track = track;
|
||||
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
|
||||
this.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
this.trackTimeSubmoduleMovable = track.trackTimeSubmodule as TrackTimeSubmoduleMovable;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (track.timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
|
||||
{
|
||||
trackPositioner.SetPercent(trackTimeSubmoduleMovable.headPercent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5925af6db50645cdaf05d9fbb53f751
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Dreamteck.Splines;
|
||||
using Lean.Pool;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
/// <summary>
|
||||
/// 在轨道上根据百分比进行运动的点
|
||||
/// </summary>
|
||||
public class TrackPercentPoint : BaseElement
|
||||
{
|
||||
public Track track;
|
||||
public SplinePositioner trackPositioner;
|
||||
public FlexibleFloat trackPercent;
|
||||
|
||||
public static TrackPercentPoint GenerateElement(string elementName, Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
TrackPercentPoint point = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject, track.transform).AddComponent<TrackPercentPoint>();
|
||||
|
||||
point.NewInitialize(elementName, track, trackPercent);
|
||||
point.SetParent(track);
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
private void NewInitialize(string elementName, Track track, FlexibleFloat trackPercent)
|
||||
{
|
||||
base.NewInitialize(elementName);
|
||||
this.track = track;
|
||||
this.trackPositioner = gameObject.AddComponent<SplinePositioner>();
|
||||
this.trackPositioner.spline = track.trackPathSubmodule.path;
|
||||
this.trackPercent = trackPercent;
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (trackPercent.animations.Count > 0)
|
||||
{
|
||||
trackPercent.UpdateFlexibleFloat(EditorManager.instance.songModule.songTime);
|
||||
if (trackPercent.returnType == FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
trackPositioner.SetPercent(trackPercent.value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6150424209395469db7104ccaa18bffd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,25 +11,29 @@ namespace Ichni.RhythmGame
|
||||
public Track track;
|
||||
public MeshGenerator meshGenerator;
|
||||
public MeshRenderer meshRenderer;
|
||||
public Material renderMaterial;
|
||||
}
|
||||
|
||||
public class TrackRendererSubmoduleAutoOrient : TrackRendererSubmodule
|
||||
{
|
||||
public SplineRenderer splineRenderer;
|
||||
|
||||
public void NewInitialize(Track track)
|
||||
public void NewInitialize(Track track, Material material = null)
|
||||
{
|
||||
this.track = track;
|
||||
this.track.trackRendererSubmodule = this;
|
||||
this.splineRenderer = track.AddComponent<SplineRenderer>();
|
||||
this.meshRenderer = splineRenderer.GetComponent<MeshRenderer>();
|
||||
this.meshGenerator = splineRenderer;
|
||||
this.renderMaterial = material == null ? EditorManager.instance.basePrefabs.defaultTrackMaterial : material;
|
||||
this.splineRenderer.spline = track.trackPathSubmodule.path;
|
||||
this.splineRenderer.clipFrom = 0;
|
||||
this.splineRenderer.clipTo = 1;
|
||||
this.meshRenderer.material = renderMaterial;
|
||||
Debug.Log(splineRenderer.clipFrom + " " + splineRenderer.clipTo);
|
||||
this.splineRenderer.color = Color.white;
|
||||
}
|
||||
|
||||
|
||||
public override void InitialRefresh()
|
||||
{
|
||||
if (track.trackTimeSubmodule is TrackTimeSubmoduleMovable)
|
||||
|
||||
@@ -37,9 +37,7 @@ namespace Ichni.RhythmGame
|
||||
|
||||
headPercent = GetTrackPercent(songTime);
|
||||
tailPercent = GetTrackPercent(songTime - visibleTrackTimeLength);
|
||||
|
||||
Debug.Log("Head: " + headPercent + " Tail: " + tailPercent);
|
||||
|
||||
|
||||
if (track.trackRendererSubmodule != null)
|
||||
{
|
||||
track.trackRendererSubmodule.meshGenerator.clipFrom = tailPercent;
|
||||
|
||||
Reference in New Issue
Block a user