using System; 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, Guid id, List tags, BaseElement targetObject, FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ) { Scale scale = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent(); scale.Initialize(elementName, id, tags); scale.targetObject = 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.SetParent(targetObject); scale.timeDurationSubmodule.SetDuration(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; } else { animationReturnType = FlexibleReturnType.MiddleInterval; } } } }