using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class HealthManager02 : MonoBehaviour {
public static float health;
public Slider healthBar;
public int maxHealth;
private int delayTime;
public int healthDecrease;
public int delay;
private GameObject death;
// Use this for initialization
void Start () {
healthBar = GetComponent();
health = maxHealth;
health = 100;
death = GameObject.Find ("Cell");
}
// Update is called once per frame
void Update () {
healthBar.value = health;
StartCoroutine(waitToSeconds(5));
}
void OnTriggerStay2D(Collider2D other){
if (other.tag == "SunLight" && health < 100) {
health = health + 0.14f;
}
}
public void giveEnergy(int energyToGive){
health += energyToGive;
}
public void giveDamage(int damageToGive){
health -= damageToGive;
}
IEnumerator waitToSeconds(float delay){
health -= 0.08f;
yield return new WaitForSeconds(delay);
}
}
↧