基础内容-3
Swirl Scale动画 四种Note代码建立 Note Judge Submodule构思中
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user