private bool HasValidTarget(EnemyEntity enemy) { var aimLeft = new Vector3(enemy.ProjectileSpawnPosition.x - enemiesConfiguration.AimingDelta, enemy.ProjectileSpawnPosition.y, enemy.ProjectileSpawnPosition.z); var aimRight = new Vector3(enemy.ProjectileSpawnPosition.x + enemiesConfiguration.AimingDelta, enemy.ProjectileSpawnPosition.y, enemy.ProjectileSpawnPosition.z); var aimLeftResult = Aim(aimLeft); var aimRightResult = Aim(aimRight); return(!(aimLeftResult.enemyInFront || aimRightResult.enemyInFront) && (aimLeftResult.playerInFront || aimRightResult.playerInFront)); }
public void Add(EnemyEntity entity) { enemies.Add(entity); if (leftmostEntity == null || entity.transform.position.x < leftmostEntity.transform.position.x) { leftmostEntity = entity; } if (rightmostEntity == null || entity.transform.position.x > rightmostEntity.transform.position.x) { rightmostEntity = entity; } }
public void Remove(EnemyEntity entity) { enemies.Remove(entity); if (entity == leftmostEntity) { leftmostEntity = FindLeftmostEntity(enemies); } if (entity == rightmostEntity) { rightmostEntity = FindRightmostEntity(enemies); } }