private void Die() { EnemyManager.AddKill(); isAlive = false; StartCoroutine(DestroyObjectAfterSomeTime(2f)); agent.isStopped = true; }
public void OnTakeDamage(Projectile.Damage damage) { if (damage.effectiveAgainst == type || damage.effectiveAgainst == Colour.None) { health -= damage.damage; } else { health -= Mathf.RoundToInt(damage.damage * Game.difficulty.weaponDamageToDifferentColor); } if (health < 0) { if (!isDead) { isDead = true; Game.credits += GetValue(value, EnemyManager.ExternalWaveNumber); SendMessage("OnDeath", SendMessageOptions.DontRequireReceiver); if (damage.weapon) { damage.weapon.AddKill(); } if (deathParticle) { deathParticle.transform.parent = null; deathParticle.Emit(particleAmount); Invoke("DisableParticle", particleLifetime); } if (EnemyManager.spawnedResearch < Game.difficulty.researchPerRound) { if ((Random.Range(0, EnemyManager.chanceToSpawnResearch) == 0) || EnemyManager.cur.currentEnemies <= Game.difficulty.researchPerRound - EnemyManager.spawnedResearch) { Instantiate(researchPoint, transform.position, Quaternion.identity); EnemyManager.spawnedResearch++; } } EnemyManager.AddKill(enemyName); } gameObject.SetActive(false); } }