추격 포기로 인한 복귀 시, 복귀하는 동안 무적 상태 + 체력 전체 회복
This commit is contained in:
@@ -916,6 +916,16 @@ namespace Northbound
|
||||
switch (state)
|
||||
{
|
||||
case EnemyAIState.Idle:
|
||||
_agent.isStopped = true;
|
||||
_agent.ResetPath();
|
||||
// 즉시 정지를 위해 velocity 초기화
|
||||
_agent.velocity = Vector3.zero;
|
||||
// 복귀 완료 - 무적 해제
|
||||
if (_enemyUnit != null)
|
||||
{
|
||||
_enemyUnit.SetInvulnerable(false);
|
||||
}
|
||||
break;
|
||||
case EnemyAIState.Attack:
|
||||
_agent.isStopped = true;
|
||||
_agent.ResetPath();
|
||||
@@ -940,6 +950,12 @@ namespace Northbound
|
||||
_agent.isStopped = false;
|
||||
_agent.speed = moveSpeed;
|
||||
_agent.SetDestination(_originPosition);
|
||||
// 복귀 시작 - 체력 회복 및 무적
|
||||
if (_enemyUnit != null)
|
||||
{
|
||||
_enemyUnit.HealToFull();
|
||||
_enemyUnit.SetInvulnerable(true);
|
||||
}
|
||||
break;
|
||||
case EnemyAIState.Dead:
|
||||
_agent.isStopped = true;
|
||||
|
||||
@@ -36,6 +36,12 @@ namespace Northbound
|
||||
NetworkVariableWritePermission.Server
|
||||
);
|
||||
|
||||
private NetworkVariable<bool> _isInvulnerable = new NetworkVariable<bool>(
|
||||
false,
|
||||
NetworkVariableReadPermission.Everyone,
|
||||
NetworkVariableWritePermission.Server
|
||||
);
|
||||
|
||||
/// <summary>
|
||||
/// 사망 시 발생하는 이벤트 (매개변수: killerId)
|
||||
/// </summary>
|
||||
@@ -106,6 +112,9 @@ namespace Northbound
|
||||
if (!IsServer) return;
|
||||
if (_currentHealth.Value <= 0) return;
|
||||
|
||||
// 무적 상태면 데미지 무시
|
||||
if (_isInvulnerable.Value) return;
|
||||
|
||||
// 공격자의 팀 확인
|
||||
if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(attackerId, out NetworkObject attackerObj))
|
||||
{
|
||||
@@ -207,6 +216,24 @@ namespace Northbound
|
||||
|
||||
#endregion
|
||||
|
||||
#region Invulnerability & Healing
|
||||
|
||||
public bool IsInvulnerable() => _isInvulnerable.Value;
|
||||
|
||||
public void SetInvulnerable(bool value)
|
||||
{
|
||||
if (!IsServer) return;
|
||||
_isInvulnerable.Value = value;
|
||||
}
|
||||
|
||||
public void HealToFull()
|
||||
{
|
||||
if (!IsServer) return;
|
||||
_currentHealth.Value = maxHealth;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void OnDrawGizmosSelected()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
Reference in New Issue
Block a user