private void drawGameBoard(CanvasAnimatedDrawEventArgs args, GameBoardConfig config) { double xCord = config.GameBoard.X; for (int xUnit = 0; xUnit < config.SpaceCountX; xUnit += 1) { xCord += config.SpaceXMargin; double yCord = config.GameBoard.Y; for (int yUnit = 0; yUnit < config.SpaceCountY; yUnit += 1) { yCord += config.SpaceYMargin; GridEntity entity = game.gridEntity[xUnit, yUnit]; bool revealed = entity.positionRevealed; bool bomb = entity.isBomb; bool flag = entity.flagSet; bool question = entity.questionSet; int number = entity.value; Rect spaceRect = new Rect(xCord, yCord, config.SpaceWidth, config.SpaceHeight); drawSpace(args.DrawingSession, spaceRect, revealed, bomb, flag, question, number); yCord += config.SpaceHeight; yCord += config.SpaceYMargin; } xCord += config.SpaceWidth; xCord += config.SpaceXMargin; } }
public override void OnClick(int x, int y) { GridEntity entity = game.gridEntity[x, y]; if (!entity.positionRevealed) { game.revealSpaces(x, y); } else { } }
public Minesweeper(GridDefinition gridDefinition) { gridEntity = new GridEntity[gridDefinition.width, gridDefinition.height]; Definition = gridDefinition; for (int x = 0; x < gridDefinition.width; x += 1) { for (int y = 0; y < gridDefinition.height; y += 1) { gridEntity[x, y] = new GridEntity(); } } fillBombs(); numberOfNonBombSpots = (gridDefinition.height * gridDefinition.width) - gridDefinition.numOfBomb; numberOfRevealedSpots = 0; bombTriggered = false; gameOver = false; isWinner = false; StartTime = DateTime.Now; Notifier = new NotifierImp(this); }
public override void OnRightClick(int x, int y) { GridEntity entity = game.gridEntity[x, y]; entity.cycleState(); }