public void updateBar() { if (hBar != null) { hBar.setSize(health / startHealth); } }
void Awake() { bndCheck = GetComponent <BoundsCheck>(); bar = GameObject.Find("HealthBar"); healthbar = bar.GetComponent <healthBar>(); healthbar.setSize(1f); }
void OnCollisionEnter(Collision coll) { GameObject otherGO = coll.gameObject; switch (otherGO.tag) { case "princessProjectile": Projectile p = otherGO.GetComponent <Projectile>(); ShowDamage(); health -= Main.GetWeaponDefinition(p.type).damageOnHit; healthbar.setSize(health * 0.1f); if (health <= 0) { // Destroy this Enemy Destroy(this.gameObject); } Destroy(otherGO); break; default: print("Enemy hit by non-ProjectileHero: " + otherGO.name); // f break; } }