Example #1
0
 public void OnDamage(DamageInfo damage)
 {
     life -= damage.calcAbsoluteDmg(dmgfactor);
     if (healthbar)
     {
         healthbar.SetHealthVisual(life / maxlife);
     }
     if (life <= 0)
     {
         Destroy(this.gameObject);
     }
 }
Example #2
0
 // Initialisierung
 void Start()
 {
     life        = maxlife;
     agent       = GetComponent <NavMeshAgent>();
     agent.speed = speed;
     if (target)
     {
         agent.SetDestination(target.transform.position);
     }
     healthbar = GetComponentInChildren <Healthbar>();
     if (healthbar)
     {
         healthbar.SetHealthVisual(life / maxlife);
     }
 }
Example #3
0
 // Funktion wird bei jedem Treffer ausgeführt
 public void OnDamage(DamageInfo damage)
 {
     life -= damage.calcAbsoluteDmg(resistance);
     if (healthbar)
     {
         healthbar.SetHealthVisual(life / maxlife);
     }
     if (life <= 0)
     {
         if (!gaveBounty)
         {
             if (enemy)
             {
                 enemy.Gold += bounty;
                 gaveBounty  = true;
             }
         }
         Destroy(this.gameObject);
     }
 }