基础内容-3
Swirl Scale动画 四种Note代码建立 Note Judge Submodule构思中
This commit is contained in:
@@ -18,7 +18,7 @@ namespace Ichni.RhythmGame
|
||||
public static Displacement GenerateElement(string elementName, BaseElement targetObject,
|
||||
FlexibleFloat positionX, FlexibleFloat positionY, FlexibleFloat positionZ)
|
||||
{
|
||||
Displacement displacement = LeanPool.Spawn(new GameObject()).AddComponent<Displacement>();//TODO: 替换 new GameObject();
|
||||
Displacement displacement = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Displacement>();
|
||||
|
||||
displacement.NewInitialize(elementName, targetObject);
|
||||
|
||||
@@ -35,54 +35,13 @@ namespace Ichni.RhythmGame
|
||||
{
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
displacement.SetTimeDuration();
|
||||
|
||||
displacement.SetTimeDuration(positionX, positionY, positionZ);
|
||||
|
||||
return displacement;
|
||||
}
|
||||
|
||||
public override void SetTimeDuration()
|
||||
{
|
||||
positionX.Sort();
|
||||
positionY.Sort();
|
||||
positionZ.Sort();
|
||||
|
||||
List<float> startTimes = new List<float>();
|
||||
List<float> endTimes = new List<float>();
|
||||
|
||||
if (positionX.animations.Count > 0)
|
||||
{
|
||||
startTimes.Add(positionX.animations[0].startTime);
|
||||
endTimes.Add(positionX.animations[^1].endTime);
|
||||
}
|
||||
|
||||
if (positionY.animations.Count > 0)
|
||||
{
|
||||
startTimes.Add(positionY.animations[0].startTime);
|
||||
endTimes.Add(positionY.animations[^1].endTime);
|
||||
}
|
||||
|
||||
if (positionZ.animations.Count > 0)
|
||||
{
|
||||
startTimes.Add(positionZ.animations[0].startTime);
|
||||
endTimes.Add(positionZ.animations[^1].endTime);
|
||||
}
|
||||
|
||||
float startTime = startTimes.Min();
|
||||
float endTime = endTimes.Max();
|
||||
|
||||
timeDurationSubmodule = new TimeDurationSubmodule(startTime, endTime);
|
||||
}
|
||||
|
||||
protected void Update()
|
||||
{
|
||||
if (timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songModule.songTime))
|
||||
{
|
||||
UpdateAnimation(EditorManager.instance.songModule.songTime);
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateAnimation(float songTime)
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
positionX.UpdateFlexibleFloat(songTime);
|
||||
positionY.UpdateFlexibleFloat(songTime);
|
||||
|
||||
55
Assets/Scripts/Animations/Transform/Scale.cs
Normal file
55
Assets/Scripts/Animations/Transform/Scale.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class Scale : AnimationBase
|
||||
{
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat scaleX, scaleY, scaleZ;
|
||||
|
||||
public static Scale GenerateElement(string elementName, BaseElement targetObject,
|
||||
FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ)
|
||||
{
|
||||
Scale scale = Lean.Pool.LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Scale>();
|
||||
|
||||
scale.NewInitialize(elementName, targetObject);
|
||||
|
||||
scale.scaleX = scaleX;
|
||||
scale.scaleY = scaleY;
|
||||
scale.scaleZ = scaleZ;
|
||||
scale.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.transformSubmodule != null)
|
||||
{
|
||||
scale.targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
scale.SetTimeDuration(scaleX, scaleY, scaleZ);
|
||||
|
||||
return scale;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
scaleX.UpdateFlexibleFloat(songTime);
|
||||
scaleY.UpdateFlexibleFloat(songTime);
|
||||
scaleZ.UpdateFlexibleFloat(songTime);
|
||||
|
||||
if (scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
scaleZ.returnType is FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
||||
targetTransformSubmodule.scaleOffset.Add(currentScale);
|
||||
targetTransformSubmodule.scaleDirtyMark = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Animations/Transform/Scale.cs.meta
Normal file
11
Assets/Scripts/Animations/Transform/Scale.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1119784540bef4e73b37c7cb9f597065
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
56
Assets/Scripts/Animations/Transform/Swirl.cs
Normal file
56
Assets/Scripts/Animations/Transform/Swirl.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Lean.Pool;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class Swirl : AnimationBase
|
||||
{
|
||||
public TransformSubmodule targetTransformSubmodule;
|
||||
public FlexibleFloat eulerAngleX, eulerAngleY, eulerAngleZ;
|
||||
|
||||
public static Swirl GenerateElement(string elementName, BaseElement targetObject,
|
||||
FlexibleFloat eulerAngleX, FlexibleFloat eulerAngleY, FlexibleFloat eulerAngleZ)
|
||||
{
|
||||
Swirl swirl = LeanPool.Spawn(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Swirl>();
|
||||
|
||||
swirl.NewInitialize(elementName, targetObject);
|
||||
|
||||
swirl.eulerAngleX = eulerAngleX;
|
||||
swirl.eulerAngleY = eulerAngleY;
|
||||
swirl.eulerAngleZ = eulerAngleZ;
|
||||
swirl.animationReturnType = FlexibleReturnType.Before;
|
||||
|
||||
if (targetObject.transformSubmodule != null)
|
||||
{
|
||||
swirl.targetTransformSubmodule = targetObject.transformSubmodule;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.Exception("Target object does not have a TransformSubmodule");
|
||||
}
|
||||
|
||||
swirl.SetTimeDuration(eulerAngleX, eulerAngleY, eulerAngleZ);
|
||||
|
||||
return swirl;
|
||||
}
|
||||
|
||||
protected override void UpdateAnimation(float songTime)
|
||||
{
|
||||
eulerAngleX.UpdateFlexibleFloat(songTime);
|
||||
eulerAngleY.UpdateFlexibleFloat(songTime);
|
||||
eulerAngleZ.UpdateFlexibleFloat(songTime);
|
||||
|
||||
if (eulerAngleX.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
eulerAngleY.returnType is FlexibleReturnType.MiddleExecuting ||
|
||||
eulerAngleZ.returnType is FlexibleReturnType.MiddleExecuting)
|
||||
{
|
||||
animationReturnType = FlexibleReturnType.MiddleExecuting;
|
||||
Vector3 currentEulerAngles = new Vector3(eulerAngleX.value, eulerAngleY.value, eulerAngleZ.value);
|
||||
targetTransformSubmodule.eulerAnglesOffset.Add(currentEulerAngles);
|
||||
targetTransformSubmodule.eulerAnglesDirtyMark = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Animations/Transform/Swirl.cs.meta
Normal file
11
Assets/Scripts/Animations/Transform/Swirl.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e6daf69621681491bb09cc72e2ff4bdb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user