71 lines
2.2 KiB
C#
71 lines
2.2 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using UnityEngine;
|
||
|
||
namespace Ichni.RhythmGame
|
||
{
|
||
public abstract partial class AnimationBase : GameElement, IHaveTimeDurationSubmodule
|
||
{
|
||
#region [属性和相关对象] Attributes & Related Objects
|
||
public GameElement animatedObject;
|
||
public FlexibleReturnType animationReturnType;
|
||
#endregion
|
||
|
||
#region [子模块接口] Submodule Interfaces
|
||
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
||
|
||
public override void SetDefaultSubmodules()
|
||
{
|
||
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region [生命周期与控制管理] Lifecycle & Management
|
||
public override void AfterInitialize()
|
||
{
|
||
base.AfterInitialize();
|
||
|
||
// 【新增】受管家管控
|
||
GameManager.Instance.animationManager.RegisterAnimation(this);
|
||
float delay = GameManager.Instance.songInformation.delay;
|
||
if (timeDurationSubmodule.CheckTimeInDuration(-delay))
|
||
{
|
||
ManualUpdate(-delay, true);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新动画
|
||
/// </summary>
|
||
/// <param name="songTime">歌曲时间</param>
|
||
protected abstract void UpdateAnimation(float songTime, bool forceUpdate);
|
||
|
||
public virtual void ManualUpdate(float currentSongTime, bool forceUpdate = false)
|
||
{
|
||
if (timeDurationSubmodule.CheckTimeInDuration(currentSongTime))
|
||
{
|
||
UpdateAnimation(currentSongTime, forceUpdate);
|
||
}
|
||
|
||
if (timeDurationSubmodule.CheckAfterEndTime(currentSongTime))
|
||
{
|
||
GameManager.Instance.animationManager.UnregisterAnimation(this);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 施加时间偏移,即移动所有Flexible参数的时间
|
||
/// </summary>
|
||
/// <param name="offset"></param>
|
||
public virtual void ApplyTimeOffset(float offset)
|
||
{
|
||
timeDurationSubmodule.startTime += offset;
|
||
timeDurationSubmodule.endTime += offset;
|
||
}
|
||
#endregion
|
||
}
|
||
|
||
|
||
} |