public void OnDamage(DamageInfo damage) { life -= damage.calcAbsoluteDmg(dmgfactor); if (healthbar) { healthbar.SetHealthVisual(life / maxlife); } if (life <= 0) { Destroy(this.gameObject); } }
// 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); } }
// 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); } }