DEG-108 [Fix] 어느 한 쪽 사망시 더이상 공격 안하도록 처리
This commit is contained in:
parent
b944d8ced9
commit
7539b84a1f
@ -88,6 +88,7 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
|
||||
// 공격 입력 처리
|
||||
if (Input.GetKeyDown(KeyCode.X) && (_currentAction == null || !_currentAction.IsActive)) {
|
||||
Debug.Log("X 버튼 Down 됨");
|
||||
StartAttackAction();
|
||||
}
|
||||
|
||||
@ -171,6 +172,7 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
if (_weaponController.IsAttacking) return; // 이미 공격 중이면 실행 안함
|
||||
|
||||
if (_currentAction == _attackAction) {
|
||||
Debug.Log($"Attack True");
|
||||
_attackAction.EnableCombo();
|
||||
_weaponController.AttackStart();
|
||||
}
|
||||
@ -178,8 +180,10 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
|
||||
|
||||
public void SetAttackComboFalse() {
|
||||
if (_currentAction == _attackAction) {
|
||||
Debug.Log($"Attack False");
|
||||
// 이벤트 중복 호출? 공격 종료 시 SetAttackComboFalse가 아니라 ~True로 끝나서 오류 발생. (공격 안하는 상태여도 공격으로 판정됨)
|
||||
_attackAction.DisableCombo();
|
||||
_weaponController.AttackEnd();
|
||||
_weaponController.AttackEnd(); // IsAttacking = false로 변경
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,6 @@ public class WeaponController : MonoBehaviour, IObservable<GameObject>
|
||||
{
|
||||
_hitColliders.Add(hit.collider);
|
||||
|
||||
Debug.Log("hit.collider.name: " + hit.collider.name);
|
||||
if (hit.collider.gameObject.CompareTag("Enemy"))
|
||||
{
|
||||
var enemyController = hit.transform.GetComponent<EnemyController>();
|
||||
|
@ -39,6 +39,8 @@ public class DungeonLogic : MonoBehaviour
|
||||
|
||||
private void OnPlayerGetHit(CharacterBase player)
|
||||
{
|
||||
if (isFailed || isCompleted) return; // 어느 한 쪽 사망시 더이상 피격 X
|
||||
|
||||
var result = _dungeonPanelController.SetPlayerHealth();
|
||||
if (!result) // 하트 모두 소모
|
||||
{
|
||||
@ -48,7 +50,8 @@ public class DungeonLogic : MonoBehaviour
|
||||
|
||||
private void OnEnemyGetHit(CharacterBase enemy)
|
||||
{
|
||||
Debug.Log("Enemy HP: " + enemy.currentHP);
|
||||
if (isFailed || isCompleted) return;
|
||||
|
||||
_dungeonPanelController.SetBossHealthBar(enemy.currentHP);
|
||||
}
|
||||
|
||||
@ -79,6 +82,8 @@ public class DungeonLogic : MonoBehaviour
|
||||
isCompleted = true;
|
||||
OnDungeonSuccess?.Invoke();
|
||||
|
||||
_dungeonPanelController.SetBossHealthBar(0.0f); // 보스 체력 0 재설정
|
||||
|
||||
_player.SetState(PlayerState.Win);
|
||||
// TODO: 강화 시스템으로 넘어가고 일상 맵으로 이동
|
||||
}
|
||||
@ -94,6 +99,11 @@ public class DungeonLogic : MonoBehaviour
|
||||
OnDungeonFailure?.Invoke();
|
||||
|
||||
_player.SetState(PlayerState.Dead);
|
||||
|
||||
// enemy가 더이상 Trace 하지 않도록 처리
|
||||
_player.gameObject.layer = LayerMask.NameToLayer("Ignore Raycast");
|
||||
_enemy.SetState(EnemyState.Idle);
|
||||
|
||||
StartCoroutine(DelayedSceneChange()); // 3초 대기 후 전환
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ public class DungeonPanelController : MonoBehaviour
|
||||
// false 반환 시 사망 처리
|
||||
public bool SetPlayerHealth()
|
||||
{
|
||||
StartCoroutine(WaitForOneSecond());
|
||||
|
||||
if (_countHealth > _playerHealthImages.Length - 1) // out of index error 방지
|
||||
{
|
||||
return false;
|
||||
@ -28,4 +30,9 @@ public class DungeonPanelController : MonoBehaviour
|
||||
_countHealth++;
|
||||
return _countHealth <= _playerHealthImages.Length - 1;
|
||||
}
|
||||
|
||||
IEnumerator WaitForOneSecond()
|
||||
{
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
}
|
||||
}
|
||||
|
BIN
Assets/KSH/DungeonTestScene.unity
(Stored with Git LFS)
BIN
Assets/KSH/DungeonTestScene.unity
(Stored with Git LFS)
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user