void OnTriggerExit(Collider other) { if (other.tag == "Enemy") { iMovement enemyOutOfRange = other.GetComponent <iMovement>(); enemies.Remove(enemyOutOfRange); enemyOutOfRange.DeathEvent().RemoveListener(delegate { BookKeepEnemy(enemyOutOfRange); }); SetTarget(); } }
void OnTriggerEnter(Collider other) { if (other.tag == "Enemy") { iMovement newEnemyDetected = other.GetComponent <iMovement>(); enemies.Add(newEnemyDetected); newEnemyDetected.DeathEvent().AddListener(delegate { BookKeepEnemy(newEnemyDetected); }); } if (enemies.Count > 0) { SetTarget(); } }
private IEnumerator SpawnGroup(Group @group) { while (@group.numberOfEnemies > 0) { yield return(new WaitForSeconds(@group.spawnTime)); GameObject enemy = Instantiate(@group.enemy); iMovement e = enemy.GetComponent <iMovement>(); e.DeathEvent().AddListener(delegate { reportDeath(); }); enemy.transform.parent = gameObject.transform; enemy.GetComponent <iMovement>().Initialize(waypointManager); @group.numberOfEnemies--; } trigger = true; }