79 lines
2.5 KiB
C#
79 lines
2.5 KiB
C#
using System.Collections;
|
||
using Animancer;
|
||
using BaseGames.Boss;
|
||
using BaseGames.Combat;
|
||
using UnityEngine;
|
||
|
||
namespace BaseGames.Enemies.Boss
|
||
{
|
||
/// <summary>
|
||
/// 嘲风击落计数器(Phase 2)。
|
||
/// 由 <see cref="ChaoFengBoss.OnDamageTaken"/> 直接调用 <see cref="OnBossHit"/>,
|
||
/// 累计命中达到阈值后触发击落序列(下落 → 硬直 → 复位浮空)。
|
||
///
|
||
/// ⚠️ HurtBox 无公开 OnDamageTaken 事件,必须通过 EnemyBase.OnDamageTaken 虚方法转发。
|
||
/// </summary>
|
||
public class ChaoFengKnockdownCounter : MonoBehaviour
|
||
{
|
||
[SerializeField] private int _threshold = 8;
|
||
|
||
[Header("依赖引用")]
|
||
[SerializeField] private ChaoFengBoss _boss;
|
||
[SerializeField] private ChaoFengFloatController _floatCtrl;
|
||
|
||
[Header("击落动画")]
|
||
[SerializeField] private ClipTransition _knockdownHitClip;
|
||
[Tooltip("击落后硬直动画(复用 Defeat_Pant Clip)")]
|
||
[SerializeField] private ClipTransition _staggerClip;
|
||
|
||
[SerializeField] private float _staggerDuration = 3f;
|
||
|
||
private int _count;
|
||
private bool _inKnockdown;
|
||
|
||
/// <summary>
|
||
/// 由 <see cref="ChaoFengBoss.OnDamageTaken"/> 调用,累计受击并在达到阈值时触发击落。
|
||
/// </summary>
|
||
public void OnBossHit(DamageInfo info)
|
||
{
|
||
if (_inKnockdown || _boss == null || _boss.CurrentPhase != 1) return;
|
||
|
||
_count++;
|
||
if (_count >= _threshold)
|
||
{
|
||
_count = 0;
|
||
StartCoroutine(KnockdownSequence());
|
||
}
|
||
}
|
||
|
||
/// <summary>强制结束正在进行中的击落序列(由 ChaoFengBoss.DefeatSequence 调用)。</summary>
|
||
public void ForceEnd()
|
||
{
|
||
StopAllCoroutines();
|
||
_inKnockdown = false;
|
||
_count = 0;
|
||
}
|
||
|
||
private IEnumerator KnockdownSequence()
|
||
{
|
||
_inKnockdown = true;
|
||
|
||
_boss.GetComponentInChildren<BossSkillExecutor>()?.InterruptCurrentSkill();
|
||
|
||
if (_knockdownHitClip.Clip != null)
|
||
_boss.Animancer.Play(_knockdownHitClip);
|
||
|
||
yield return _floatCtrl.FallDown();
|
||
|
||
if (_staggerClip.Clip != null)
|
||
_boss.Animancer.Play(_staggerClip);
|
||
|
||
yield return new WaitForSeconds(_staggerDuration);
|
||
|
||
yield return _floatCtrl.FloatUp();
|
||
|
||
_inKnockdown = false;
|
||
}
|
||
}
|
||
}
|