2025-06-03 02:42:28 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Ichni.RhythmGame
|
|
|
|
|
|
{
|
|
|
|
|
|
public abstract partial class AnimationBase : GameElement, IHaveTimeDurationSubmodule
|
|
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#region [属性和相关对象] Attributes & Related Objects
|
2025-06-03 02:42:28 -04:00
|
|
|
|
public GameElement animatedObject;
|
|
|
|
|
|
public FlexibleReturnType animationReturnType;
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#endregion
|
2025-06-03 02:42:28 -04:00
|
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#region [子模块接口] Submodule Interfaces
|
2025-06-03 02:42:28 -04:00
|
|
|
|
public TimeDurationSubmodule timeDurationSubmodule { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
public override void SetDefaultSubmodules()
|
|
|
|
|
|
{
|
|
|
|
|
|
timeDurationSubmodule = new TimeDurationSubmodule(this);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#endregion
|
2025-07-21 05:42:20 -04:00
|
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#region [生命周期与控制管理] Lifecycle & Management
|
2025-07-21 05:42:20 -04:00
|
|
|
|
public override void AfterInitialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.AfterInitialize();
|
2026-03-14 03:13:10 -04:00
|
|
|
|
|
|
|
|
|
|
// 【新增】受管家管控
|
|
|
|
|
|
GameManager.Instance.animationManager.RegisterAnimation(this);
|
|
|
|
|
|
float delay = GameManager.Instance.songInformation.delay;
|
2025-07-21 05:42:20 -04:00
|
|
|
|
if (timeDurationSubmodule.CheckTimeInDuration(delay))
|
|
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
|
UpdateAnimation(0f); // 确保与最新的 SongTime 同步
|
2025-07-21 05:42:20 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-03 02:42:28 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 更新动画
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="songTime">歌曲时间</param>
|
|
|
|
|
|
protected abstract void UpdateAnimation(float songTime);
|
|
|
|
|
|
|
2026-03-14 03:13:10 -04:00
|
|
|
|
public virtual void ManualUpdate(float currentSongTime)
|
2025-06-03 02:42:28 -04:00
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
|
if (timeDurationSubmodule.CheckTimeInDuration(currentSongTime))
|
2025-07-08 14:28:40 -04:00
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
|
UpdateAnimation(currentSongTime);
|
2025-07-08 14:28:40 -04:00
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
|
|
|
|
|
|
|
if (timeDurationSubmodule.CheckAfterEndTime(currentSongTime))
|
2025-06-03 02:42:28 -04:00
|
|
|
|
{
|
2026-03-14 03:13:10 -04:00
|
|
|
|
GameManager.Instance.animationManager.UnregisterAnimation(this);
|
2025-06-03 02:42:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 施加时间偏移,即移动所有Flexible参数的时间
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="offset"></param>
|
|
|
|
|
|
public virtual void ApplyTimeOffset(float offset)
|
|
|
|
|
|
{
|
|
|
|
|
|
timeDurationSubmodule.startTime += offset;
|
|
|
|
|
|
timeDurationSubmodule.endTime += offset;
|
|
|
|
|
|
}
|
2026-03-14 03:13:10 -04:00
|
|
|
|
#endregion
|
2025-06-03 02:42:28 -04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|