84 lines
3.3 KiB
C#
84 lines
3.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Ichni.RhythmGame.Beatmap;
|
|
using UnityEngine;
|
|
|
|
namespace Ichni.RhythmGame
|
|
{
|
|
public partial class Scale : AnimationBase
|
|
{
|
|
#region [暴露属性字段与关联] Exposed Fields & References
|
|
public TransformSubmodule targetTransformSubmodule;
|
|
public FlexibleFloat scaleX, scaleY, scaleZ;
|
|
#endregion
|
|
|
|
#region [生命周期与工厂] Lifecycle & Factory
|
|
public static Scale GenerateElement(string elementName, Guid id,
|
|
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
|
|
FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ)
|
|
{
|
|
Scale scale = Instantiate(GameManager.Instance.basePrefabs.emptyObject).AddComponent<Scale>();
|
|
|
|
scale.Initialize(elementName, id, tags, isFirstGenerated, animatedObject);
|
|
|
|
scale.animatedObject = animatedObject;
|
|
|
|
scale.scaleX = scaleX;
|
|
scale.scaleY = scaleY;
|
|
scale.scaleZ = scaleZ;
|
|
scale.animationReturnType = FlexibleReturnType.Before;
|
|
|
|
scale.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule;
|
|
//scale.timeDurationSubmodule.SetDuration(scaleX, scaleY, scaleZ);
|
|
|
|
return scale;
|
|
}
|
|
|
|
public override void SetDefaultSubmodules()
|
|
{
|
|
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
|
}
|
|
#endregion
|
|
|
|
#region [核心动画逻辑] Core Animation Logic
|
|
|
|
protected override void UpdateAnimation(float songTime, bool forceUpdate)
|
|
{
|
|
scaleX.UpdateFlexibleFloat(songTime);
|
|
scaleY.UpdateFlexibleFloat(songTime);
|
|
scaleZ.UpdateFlexibleFloat(songTime);
|
|
|
|
if (forceUpdate || scaleX.returnType is FlexibleReturnType.MiddleExecuting ||
|
|
scaleY.returnType is FlexibleReturnType.MiddleExecuting ||
|
|
scaleZ.returnType is FlexibleReturnType.MiddleExecuting)
|
|
{
|
|
if(!forceUpdate) animationReturnType = FlexibleReturnType.MiddleExecuting;
|
|
Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
|
targetTransformSubmodule.scaleOffset += currentScale;
|
|
targetTransformSubmodule.scaleDirtyMark = true;
|
|
}
|
|
else if (scaleX.isSwitchingReturnType || scaleY.isSwitchingReturnType || scaleZ.isSwitchingReturnType)
|
|
{
|
|
//animationReturnType = FlexibleReturnType.MiddleExecuting;
|
|
//Vector3 currentScale = new Vector3(scaleX.value, scaleY.value, scaleZ.value);
|
|
//targetTransformSubmodule.scaleOffset += currentScale;
|
|
//targetTransformSubmodule.scaleDirtyMark = true;
|
|
}
|
|
else
|
|
{
|
|
animationReturnType = FlexibleReturnType.MiddleInterval;
|
|
}
|
|
}
|
|
|
|
public override void ApplyTimeOffset(float offset)
|
|
{
|
|
base.ApplyTimeOffset(offset);
|
|
scaleX.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
|
|
scaleY.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
|
|
scaleZ.animations.ForEach(anim => anim.ApplyTimeOffset(offset));
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
} |