적군 구현

This commit is contained in:
김도환
2026-04-18 17:30:41 +09:00
parent 00b52e8b79
commit aec5dfbcf6
7 changed files with 421 additions and 7 deletions

View File

@@ -1,11 +1,14 @@
using System;
using UnityEngine;
public class LivingEntity : MonoBehaviour
public abstract class LivingEntity : MonoBehaviour
{
public float health;
protected abstract void OnDamaged(float damage);
public void Damage(float amount)
{
OnDamaged(amount);
health -= amount;
if (health <= 0)
{
@@ -16,8 +19,7 @@ public class LivingEntity : MonoBehaviour
{
if (other.gameObject.layer == LayerMask.NameToLayer("Bullet"))
{
Destroy(gameObject);
other.gameObject.SetActive(false);
Damage(5);
}
}
}