示例#1
0
 public void updateBar()
 {
     if (hBar != null)
     {
         hBar.setSize(health / startHealth);
     }
 }
示例#2
0
 void Awake()
 {
     bndCheck  = GetComponent <BoundsCheck>();
     bar       = GameObject.Find("HealthBar");
     healthbar = bar.GetComponent <healthBar>();
     healthbar.setSize(1f);
 }
示例#3
0
    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;
        }
    }