적군 구현
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user