mirror of
https://github.com/ConjureETS/Labo_2_equ_2_a15.git
synced 2026-03-24 09:31:07 +00:00
40 lines
597 B
C#
40 lines
597 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public class Health : MonoBehaviour {
|
|
|
|
public int maxHP;
|
|
private int hp;
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
hp = maxHP;
|
|
}
|
|
|
|
public int removeHP(int amount)
|
|
{
|
|
hp -= amount;
|
|
if (hp < 0)
|
|
hp = 0;
|
|
return hp;
|
|
}
|
|
|
|
public int addHP(int amount)
|
|
{
|
|
hp += amount;
|
|
if (hp > maxHP)
|
|
hp = maxHP;
|
|
return hp;
|
|
}
|
|
|
|
public int getHP()
|
|
{
|
|
return hp;
|
|
}
|
|
|
|
public void setMaxHP(int amount)
|
|
{
|
|
maxHP = amount;
|
|
}
|
|
}
|