75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using Ichni.Editor;
|
||
using UnityEngine;
|
||
|
||
namespace Ichni.RhythmGame
|
||
{
|
||
public abstract partial class AnimationBase : GameElement, IHaveTimeDurationSubmodule
|
||
{
|
||
public GameElement animatedObject;
|
||
public FlexibleReturnType animationReturnType;
|
||
|
||
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
||
|
||
public override void SetDefaultSubmodules()
|
||
{
|
||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||
|
||
}
|
||
public override void Initialize(string name, Guid elementGuid, List<string> tags,
|
||
bool isFirstGenerated, GameElement parentElement)
|
||
{
|
||
base.Initialize(name, elementGuid, tags, isFirstGenerated, parentElement);
|
||
if (this.parentElement.submoduleList.Where(e => e is TransformSubmodule).Count() == 0)
|
||
{
|
||
LogWindow.Log("AnimationBase must be attached to a GameElement with TransformSubmodule", Color.red);
|
||
//OnDelete();
|
||
//return;
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// 更新动画
|
||
/// </summary>
|
||
/// <param name="songTime">歌曲时间</param>
|
||
protected abstract void UpdateAnimation(float songTime);
|
||
|
||
protected virtual void Update()
|
||
{
|
||
if (timeDurationSubmodule.CheckTimeInDuration(EditorManager.instance.songInformation.songTime))
|
||
{
|
||
UpdateAnimation(EditorManager.instance.songInformation.songTime);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 施加时间偏移,即移动所有Flexible参数的时间
|
||
/// </summary>
|
||
/// <param name="offset"></param>
|
||
public virtual void ApplyTimeOffset(float offset)
|
||
{
|
||
timeDurationSubmodule.startTime += offset;
|
||
timeDurationSubmodule.endTime += offset;
|
||
}
|
||
}
|
||
|
||
namespace Beatmap
|
||
{
|
||
public abstract class AnimationBase_BM : GameElement_BM
|
||
{
|
||
public AnimationBase_BM()
|
||
{
|
||
|
||
}
|
||
|
||
public AnimationBase_BM(string elementName, Guid elementGuid, List<string> tags,
|
||
GameElement_BM attachedElement) : base(elementName, elementGuid, tags, attachedElement)
|
||
{
|
||
|
||
}
|
||
}
|
||
|
||
}
|
||
} |