52 lines
1.9 KiB
C#
52 lines
1.9 KiB
C#
using UnityEngine;
|
||
using BaseGames.Combat;
|
||
using BaseGames.Core.Events;
|
||
|
||
namespace BaseGames.Boss
|
||
{
|
||
/// <summary>
|
||
/// 管理 Boss 的专属弱点 HurtBox(如核心、眼睛等)。
|
||
/// 弱点激活期间受到的伤害会乘以 DamageMultiplier。
|
||
/// </summary>
|
||
public class WeakPointSystem : MonoBehaviour
|
||
{
|
||
[System.Serializable]
|
||
public struct WeakPoint
|
||
{
|
||
public HurtBox hurtBox;
|
||
public GameObject visualIndicator;
|
||
}
|
||
|
||
[SerializeField] private WeakPoint[] _weakPoints;
|
||
[SerializeField] private string _bossId;
|
||
[SerializeField] private StringEventChannelSO _onVulnerabilityWindowOpened;
|
||
|
||
private float _damageMultiplier = 1f;
|
||
|
||
/// <summary>激活或关闭弱点 HurtBox 及视觉指示器。</summary>
|
||
/// <param name="active">是否激活。</param>
|
||
/// <param name="multiplier">激活时的受击伤害乘数。</param>
|
||
/// <param name="activateSpecific">true = 仅激活弱点专属 HurtBox;false = 全身视为弱点(不改变 HurtBox 状态)。</param>
|
||
public void SetActive(bool active, float multiplier = 1f, bool activateSpecific = false)
|
||
{
|
||
_damageMultiplier = active ? multiplier : 1f;
|
||
|
||
if (activateSpecific)
|
||
{
|
||
foreach (var wp in _weakPoints)
|
||
{
|
||
wp.hurtBox.gameObject.SetActive(active);
|
||
if (wp.visualIndicator != null)
|
||
wp.visualIndicator.SetActive(active);
|
||
}
|
||
}
|
||
|
||
if (active)
|
||
_onVulnerabilityWindowOpened?.Raise(_bossId);
|
||
}
|
||
|
||
/// <summary>弱点 HurtBox 受击时,由 BossStats 调用此方法获取最终伤害系数。</summary>
|
||
public float GetDamageMultiplier() => _damageMultiplier;
|
||
}
|
||
}
|