摄像机区域的架构改动
This commit is contained in:
32
Assets/_Game/Scripts/Enemies/BodyContactDamage.cs
Normal file
32
Assets/_Game/Scripts/Enemies/BodyContactDamage.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using BaseGames.Combat;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BaseGames.Enemies
|
||||
{
|
||||
/// <summary>
|
||||
/// 接触伤害:组件启用时持续激活 HitBox,令敌人对接触到的目标定期造成伤害。
|
||||
/// 适用于无攻击动画的简单障碍物、环境危险或测试场景。
|
||||
/// </summary>
|
||||
[RequireComponent(typeof(HitBox))]
|
||||
public class BodyContactDamage : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float _repeatInterval = 0.5f;
|
||||
|
||||
private HitBox _hitBox;
|
||||
private float _timer;
|
||||
|
||||
private void Awake() => _hitBox = GetComponent<HitBox>();
|
||||
private void OnEnable() { _hitBox?.Activate(); _timer = 0f; }
|
||||
private void OnDisable() => _hitBox?.Deactivate();
|
||||
|
||||
private void Update()
|
||||
{
|
||||
_timer += Time.deltaTime;
|
||||
if (_timer >= _repeatInterval)
|
||||
{
|
||||
_timer = 0f;
|
||||
_hitBox.Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user