2026-05-20 적 경직추가
This commit is contained in:
@@ -34,12 +34,11 @@ private enum AIState
|
||||
[SerializeField] private float _attackLockDuration = 0.45f;
|
||||
[SerializeField] private float _attackCooldown = 1f;
|
||||
[SerializeField] private Vector2 _attackHitVelocity = new Vector2(3f, 0f);
|
||||
[SerializeField] private string _targetHitReactionAnimationState;
|
||||
|
||||
[Header("Animation")]
|
||||
[SerializeField] private string _idleAnimationState = "";
|
||||
[SerializeField] private string _runAnimationState = "";
|
||||
[SerializeField] private string _attackAnimationState = "";
|
||||
[SerializeField] private string _idleAnimationState = "Idle";
|
||||
[SerializeField] private string _runAnimationState = "Run";
|
||||
[SerializeField] private string _attackAnimationState = "PunchA";
|
||||
|
||||
private Enemy _enemy;
|
||||
private Health _health;
|
||||
@@ -75,9 +74,17 @@ private void OnEnable()
|
||||
_hasAppliedAttackDamage = false;
|
||||
_attackTimer = 0f;
|
||||
_attackCooldownTimer = 0f;
|
||||
if (_enemy != null)
|
||||
_enemy.OnDamaged += HandleDamaged;
|
||||
ResolveTarget();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_enemy != null)
|
||||
_enemy.OnDamaged -= HandleDamaged;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
TickCooldown();
|
||||
@@ -282,6 +289,14 @@ private void CancelAttack()
|
||||
_isAttacking = false;
|
||||
_hasAppliedAttackDamage = false;
|
||||
_attackTimer = 0f;
|
||||
_state = AIState.Idle;
|
||||
_activeAnimationState = null;
|
||||
}
|
||||
|
||||
private void HandleDamaged()
|
||||
{
|
||||
CancelAttack();
|
||||
_attackCooldownTimer = Mathf.Max(_attackCooldownTimer, _attackCooldown);
|
||||
}
|
||||
|
||||
private void TryApplyAttackDamage()
|
||||
@@ -295,7 +310,7 @@ private void TryApplyAttackDamage()
|
||||
if (!IsTargetLayerValid()) return;
|
||||
|
||||
Vector2 hitVelocity = new Vector2(_attackHitVelocity.x * _facingDirection, _attackHitVelocity.y);
|
||||
_targetDamageable.TakeDamage(_attackDamage, hitVelocity, _targetHitReactionAnimationState);
|
||||
_targetDamageable.TakeDamage(_attackDamage, hitVelocity);
|
||||
}
|
||||
|
||||
private bool IsTargetLayerValid()
|
||||
|
||||
Reference in New Issue
Block a user