public override string DrawEnemiesAndBullets(IEnemyCollection enemies, IList <Bullet> spaceshipBullets) { FileLogger.Log("Alien Template method pattern: drawing enemies"); var builder = new StringBuilder(); var skip = false; for (var column = 0; column < Contracts.GameSizeHeight; column++) { if (skip) { builder.AppendLine(); skip = false; } else { for (var row = 0; row < Contracts.GameSizeWidth; row++) { var contains = enemies.Count(x => x.Position.From.X < row && row <= x.Position.To.X) != 0; builder.Append(contains ? "\u2021" : " "); } skip = true; } if (!skip) { skip = enemies.Count(x => x.Position.From.Y < column && column <= x.Position.To.Y) == 0; } } return(builder.ToString()); }
public override string DrawEnemiesAndBullets(IEnemyCollection enemies, IList <Bullet> spaceshipBullets) { FileLogger.Log("Simple Template method pattern: drawing enemies"); var builder = new StringBuilder(); for (var column = 0; column < Contracts.GameSizeHeight; column++) { for (var row = 0; row < Contracts.GameSizeWidth; row++) { var containsEnemy = enemies.Count( x => x.Position.From.X < row && row <= x.Position.To.X && column == x.Position.From.Y) != 0; var containsBullet = spaceshipBullets.Count( x => x.Position.X == row && x.Position.Y == column) != 0; if (containsEnemy) { builder.Append("\u2302"); } else if (containsBullet) { builder.Append("|"); } else { builder.Append(" "); } } builder.AppendLine(); } return(builder.ToString()); }
public bool Done() { FileLogger.Log("Concrete Iterator: done"); return(_current >= _collection.Count()); }
// Adding enemies to the board public void EnemiesSubscribe(Enemy enemy) { _enemies[_enemies.Count()] = enemy; }