107 lines
3.9 KiB
C#
107 lines
3.9 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
|
|
{
|
|
public TransformSubmodule targetTransformSubmodule;
|
|
public FlexibleFloat scaleX, scaleY, scaleZ;
|
|
|
|
public static Scale GenerateElement(string elementName, Guid id,
|
|
List<string> tags, bool isFirstGenerated, GameElement animatedObject,
|
|
FlexibleFloat scaleX, FlexibleFloat scaleY, FlexibleFloat scaleZ)
|
|
{
|
|
Scale scale = Instantiate(EditorManager.instance.basePrefabs.emptyObject).AddComponent<Scale>();
|
|
|
|
scale.Initialize(elementName, id, tags, isFirstGenerated);
|
|
|
|
scale.animatedObject = animatedObject;
|
|
|
|
scale.scaleX = scaleX;
|
|
scale.scaleY = scaleY;
|
|
scale.scaleZ = scaleZ;
|
|
scale.animationReturnType = FlexibleReturnType.Before;
|
|
|
|
scale.targetTransformSubmodule = (animatedObject as IHaveTransformSubmodule).transformSubmodule;
|
|
|
|
scale.SetParent(animatedObject);
|
|
//scale.timeDurationSubmodule.SetDuration(scaleX, scaleY, scaleZ);
|
|
|
|
return scale;
|
|
}
|
|
|
|
protected override void SetDefaultSubmodules()
|
|
{
|
|
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
|
submoduleList.Add(timeDurationSubmodule);
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
|
|
public partial class Scale
|
|
{
|
|
public override void SaveBM()
|
|
{
|
|
matchedBM = new Scale_BM(elementName, elementGuid, tags, parentElement.matchedBM as GameElement_BM,
|
|
scaleX.ConvertToBM(), scaleY.ConvertToBM(), scaleZ.ConvertToBM());
|
|
}
|
|
}
|
|
|
|
namespace Beatmap
|
|
{
|
|
public class Scale_BM : GameElement_BM
|
|
{
|
|
public FlexibleFloat_BM scaleX, scaleY, scaleZ;
|
|
|
|
public Scale_BM()
|
|
{
|
|
|
|
}
|
|
|
|
public Scale_BM(string elementName, Guid elementGuid, List<string> tags, GameElement_BM attachedElement,
|
|
FlexibleFloat_BM scaleX, FlexibleFloat_BM scaleY, FlexibleFloat_BM scaleZ)
|
|
: base(elementName, elementGuid, tags, attachedElement)
|
|
{
|
|
this.scaleX = scaleX;
|
|
this.scaleY = scaleY;
|
|
this.scaleZ = scaleZ;
|
|
}
|
|
|
|
public override void ExecuteBM()
|
|
{
|
|
Scale.GenerateElement(elementName, elementGuid, tags, false, GetElement(attachedElementGuid),
|
|
scaleX.ConvertToGameType(), scaleY.ConvertToGameType(), scaleZ.ConvertToGameType());
|
|
}
|
|
|
|
public override GameElement DuplicateBM(GameElement parent)
|
|
{
|
|
return Scale.GenerateElement(elementName, elementGuid, tags, false,
|
|
parent, scaleX.ConvertToGameType(), scaleY.ConvertToGameType(), scaleZ.ConvertToGameType());
|
|
}
|
|
}
|
|
}
|
|
} |