public void gainHealth() { healthUI health_ui = GameObject.Find("Health").GetComponent <healthUI>(); if (health < 5) { health_ui.gainLife(health); health += damage; } }
// Use this for initialization void Start() { //if (this.image == null) //{ // Debug.LogError("Error: No image on " + this.name); //} //this.targetAlpha = 0;// this.image.color.a; // at startup the green is not visible. //this.green.CrossFadeAlpha(0.0f, 0.0f, true); healthUI.singleton = this; }
public void takeDamage(int damage) { healthUI health_ui = GameObject.Find("Health").GetComponent <healthUI>(); health_ui.loseLife(health - 1); health -= damage; spriteRenderer.color = Color.red; dazedTime = startDazedTime; if (health > 0) { Invoke("resetMaterial", 0.2f); } }