You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
818 B
45 lines
818 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Health : MonoBehaviour
|
|
{
|
|
public int PreHP;
|
|
public int MaxHP {get; private set;}
|
|
public int Hp {get; private set;}
|
|
private void Start()
|
|
{
|
|
MaxHP = PreHP;
|
|
Hp = MaxHP;
|
|
}
|
|
public void RemoveHP(int Damage)
|
|
{
|
|
Hp -= Damage;
|
|
hpCheck();
|
|
}
|
|
public void AddHP(int In)
|
|
{
|
|
Hp += In;
|
|
hpCheck();
|
|
}
|
|
public void AddMax(int hp)
|
|
{
|
|
|
|
}
|
|
private void hpCheck()
|
|
{
|
|
if(Hp <=0)
|
|
{
|
|
if(gameObject.CompareTag("Enemy"))
|
|
{
|
|
GameObject.Destroy(gameObject);
|
|
}
|
|
Debug.Log("Dead");
|
|
}
|
|
if(Hp > MaxHP)
|
|
{
|
|
Hp = MaxHP;
|
|
}
|
|
}
|
|
}
|