Files
ft/Client/Assets/Scripts/EventBossFight/Panel/BossFightTimelineCell/EventBossFightTimelineBossCell.cs
2026-06-29 21:18:33 +08:00

65 lines
2.2 KiB
C#

using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Playables;
namespace EventBossFight
{
public class EventBossFightTimelineBossCell : EventBossFightTimelineCell, IEventBossFightBossCell
{
public PlayableAsset attacked1Timeline;
public PlayableAsset attacked2Timeline;
public PlayableAsset attackTimeline;
[Header("boss attack")]
[Tooltip("玩家攻击的震动数据,必须有五个")]
public EventBossFightShakeData bossAttackShakeData;
[Header("boss attacked")]
[Tooltip("material _FillPhase")]
[Range(0, 1)]
[SerializeField] private float bossAttackedFillPhase = 0.5f;
[Tooltip("material 恢复闪白")]
[SerializeField] private float bossAttackedRevertTime = 0.5f;
[Header("boss attack")]
public GameObject playerAttackedFx;
EventBossFightShakeData IEventBossFightBossCell.BossAttackShakeData => bossAttackShakeData;
GameObject IEventBossFightBossCell.PlayerAttackedFx => playerAttackedFx;
/// <summary>一般为父级「boss」根上的 <see cref="PlayableDirector"/>。</summary>
public PlayableDirector BossTimelineDirector => GetComponentInParent<PlayableDirector>();
private int _nameID;
public async Task PlayTimelineAttack(PlayableDirector bossDirector)
{
await PlayTimeline(bossDirector, attackTimeline);
}
public async Task PlayTimelineAttacked(PlayableDirector bossDirector, int index)
{
_ = PlayFlash();
if (index == 1)
{
await PlayTimeline(bossDirector, attacked1Timeline);
}
else
{
await PlayTimeline(bossDirector, attacked2Timeline);
}
}
private async Task PlayFlash()
{
Spine.material.SetFloat("_FillPhase", bossAttackedFillPhase);
await Awaiters.Seconds(bossAttackedRevertTime);
Spine.material.SetFloat("_FillPhase", 0);
}
public void InitFlash()
{
Spine.material.SetFloat("_FillPhase", 0);
}
public void ShowGameObject()
{
this.gameObject.SetActive(true);
}
}
}