DEG-108 [Fix] OnNext에서 공격 처리

This commit is contained in:
Sehyeon 2025-04-25 15:48:11 +09:00
parent 7539b84a1f
commit 59625fa8ff
3 changed files with 14 additions and 15 deletions

View File

@ -70,6 +70,8 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
_actionDash = new PlayerActionDash();
PlayerInit();
SwitchBattleMode();
}
private void Update()
@ -211,6 +213,16 @@ public class PlayerController : CharacterBase, IObserver<GameObject>
public void OnNext(GameObject value)
{
float playerAttackPower = _weaponController.AttackPower * attackPower;
if (value.CompareTag("Enemy")) // 적이 Enemy일 때만 공격 처리
{
var enemyController = value.transform.GetComponent<EnemyController>();
if (enemyController != null)
{
enemyController.TakeDamage(playerAttackPower);
}
}
}
public void OnError(Exception error)

View File

@ -105,16 +105,6 @@ public class WeaponController : MonoBehaviour, IObservable<GameObject>
if (!_hitColliders.Contains(hit.collider))
{
_hitColliders.Add(hit.collider);
if (hit.collider.gameObject.CompareTag("Enemy"))
{
var enemyController = hit.transform.GetComponent<EnemyController>();
if (enemyController != null && _playerController != null)
{
enemyController.TakeDamage(AttackPower * _playerController.attackPower);
}
}
Notify(hit.collider.gameObject);
}
}

View File

@ -20,11 +20,8 @@ public class DungeonPanelController : MonoBehaviour
public bool SetPlayerHealth()
{
StartCoroutine(WaitForOneSecond());
if (_countHealth > _playerHealthImages.Length - 1) // out of index error 방지
{
return false;
}
// out of index error 방지
if (_countHealth > _playerHealthImages.Length - 1) return false;
_playerHealthImages[_countHealth].color = Color.black;
_countHealth++;