public GameBoard(int width, int height) { Height = height; Width = width; TileArea = new TileArea(Width, Height); ObjectArea = new GameObjectArea(Width, Height); }
public EditCommand(Key key, MovementArea movementArea, GameObjectArea objectArea) : base(key) { this.objectArea = objectArea; this.movementArea = movementArea; }
public bool IsGameOver(GameObjectArea objectArea) { bool isGameOver = true; for (int i = 0; i < tileArea.Height; ++i) { for (int j = 0; j < tileArea.Width; ++j) { if (objectArea[i, j].Name == Pipe.Name) { if (objectArea[i, j] is Pipe pipe && !pipe.IsFilled) { IList <Point> neigbors = tileArea[i, j].Neighbors; bool isSourceNear = CanContinue(objectArea, neigbors, IsSource); bool isFilledPipeNear = CanContinue(objectArea, neigbors, IsFilledPipe); isGameOver = !(isSourceNear || isFilledPipeNear); if (!isGameOver) { break; } } } } if (!isGameOver) { break; } } return(isGameOver); }
private void FillNeighbors(GameObjectArea objectSpace, IList <Point> neighbors) { foreach (var neighbor in neighbors) { if (objectSpace[neighbor.X, neighbor.Y] is Pipe pipe && !pipe.IsFilled) { pipe.IsFilled = true; } } }
private bool CanContinue(GameObjectArea objectArea, IList <Point> neighbors, GameObjectPredicate predicate) { bool canContinue = false; foreach (var neighbor in neighbors) { canContinue = predicate(objectArea[neighbor.X, neighbor.Y]); if (canContinue) { break; } } return(canContinue); }
public EnterCommand(Key key, MovementArea movementArea, GameObjectArea objectArea, TileArea tileArea) : base(key, movementArea, objectArea) { this.tileArea = tileArea; }
public SCommand(Key key, MovementArea movementArea, GameObjectArea objectArea) : base(key, movementArea, objectArea) { }