Files
zeling_v2/Assets/_Game/Scripts/Enemies/Abilities/MultiDashAbility.cs
Joywayer a1b4e629aa feat: Implement Room Streaming System
- Add RoomStreamingManager to manage room loading and unloading based on player proximity.
- Create StreamingBudgetConfigSO for memory and performance budgeting of the streaming system.
- Introduce TransitionDirector to handle seamless and atmospheric fade transitions between rooms.
- Develop WorldGraph to represent room connectivity and facilitate neighbor queries and distance calculations.
- Implement RoomNode and RoomEdge classes to structure room data and connections.
2026-05-23 19:10:29 +08:00

50 lines
1.9 KiB
C#

using System.Collections;
using UnityEngine;
namespace BaseGames.Enemies.Abilities
{
/// <summary>
/// 连续冲刺能力:将另一个 ChargeAbility 作为单次冲刺单元顺序触发 dashCount 次。
/// 每次冲刺之间间隔 pauseBetweenDashes 秒,每次冲刺前可重新朝向目标。
/// </summary>
public sealed class MultiDashAbility : EnemyAbilityBase
{
[Header("冲刺单元")]
[Tooltip("作为冲刺单元的 ChargeAbility 的 abilityId")]
[SerializeField] private string _dashAbilityId = "charge";
[Header("节奏")]
[SerializeField, Min(1)] private int _dashCount = 3;
[SerializeField, Min(0f)] private float _pauseBetweenDashes = 0.25f;
[SerializeField] private bool _refaceTargetEachDash = true;
protected override IEnumerator ExecuteCoroutine()
{
if (_enemy == null) yield break;
var dash = _enemy.Abilities.Get(_dashAbilityId);
if (dash == null)
{
Debug.LogWarning($"[MultiDashAbility] 找不到冲刺单元 abilityId='{_dashAbilityId}'", this);
yield break;
}
for (int i = 0; i < _dashCount; i++)
{
if (_refaceTargetEachDash && _enemy.PlayerTransform != null)
FaceTarget(_enemy.PlayerTransform);
// 强制执行子冲刺(连段语义,忽略冷却)
if (!dash.ForceExecute())
{
Debug.LogWarning($"[MultiDashAbility] ForceExecute 失败(第 {i + 1} 次)", this);
yield break;
}
while (dash.IsRunning) yield return null;
if (i < _dashCount - 1 && _pauseBetweenDashes > 0f)
yield return EnemyAbilityWaits.Get(_pauseBetweenDashes);
}
}
}
}