private void GetDamaged(DamageDealer damageDealer) { if (!isDead) { health -= damageDealer.GetDamage(); healthKeeper.DisplayHealth(); if (health <= 0) { isDead = true; StartCoroutine(Die()); } } }
// Use this for initialization void Start() { float distance = transform.position.z - Camera.main.transform.position.z; Vector3 leftmost = Camera.main.ViewportToWorldPoint(new Vector3(0f, 0f, distance)); Vector3 rightmost = Camera.main.ViewportToWorldPoint(new Vector3(1F, 0f, distance)); //set the borders of the restains of movements xmin = leftmost.x + padding; xmax = rightmost.x - padding; //get current health from static variable health = maxHealth; healthKeeper = GameObject.Find("Health").GetComponent <HealthKeeper>(); healthKeeper.DisplayHealth(health); }
public void HealthUpdate(float health) { healthKeeper.DisplayHealth(health); maxHealth = health; }