28 lines
557 B
C#
28 lines
557 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class ObjectStats : MonoBehaviour
|
||
|
|
{
|
||
|
|
float curHealth = 100;
|
||
|
|
[SerializeField] float maxHealth = 100;
|
||
|
|
public float damage = 25f;
|
||
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
curHealth = maxHealth;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Update is called once per frame
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
public void TakeDamage()
|
||
|
|
{
|
||
|
|
curHealth -= damage;
|
||
|
|
if (curHealth <= 0)
|
||
|
|
{
|
||
|
|
Destroy(gameObject);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|