private void TargetNearbyEnemies() { // Find all things on "Enemy" layer 10m around us Collider2D[] enemiesToAttack = Physics2D.OverlapCircleAll(player.transform.position, 10f, AI.EnemyLayermask); System.Array.Sort <Component>(enemiesToAttack, new System.Comparison <Component>(ClosestComponentCompare)); foreach (Collider2D col in enemiesToAttack) { // We can only hit things that have IStrikeable attached if (col.gameObject.GetComponent <IStrikeable>() != null) { // AddImmediateToTargetList(col.gameObject); // Send a child off to attack this if (inventory.GetWaterLevel() > 0) { GameObject offspring = Instantiate(waterSpriteChildPrefab); offspring.transform.position = this.transform.position; WaterSpriteOffspring waterSpriteOffspring = offspring.GetComponent <WaterSpriteOffspring>(); waterSpriteOffspring.SetTarget(col.gameObject); inventory.ChangeWaterLevel(-1); } } } }