private void DrawWindow() { GraphicsFacade g = new GraphicsFacade(gameWindow, textures); g.SetBackground(gameWindow.DisplayRectangle); g.DrawBattleSweeperText("BattleSweeper", 45, new PointF(5, 5)); g.DrawBattleSweeperText("by MELV team", 12, new PointF(430, 45)); g.DrawLine(new PointF(0, 80), new PointF(gameWindow.ClientSize.Width, 80)); g.DrawBattleSweeperBorder(4, playerBoardBounds); g.DrawBattleSweeperBorder(4, enemyBoardBounds); g.DrawBattleSweeperBorder(2, shotTypeSelectorBounds); g.Dispose(); }
private void StaggeredDrawGame(Game game, GraphicsFacade g, bool fullRedraw, int startLine, int lineCount) { gameUpdateTimer.Stop(); if (redrawButton) { g.DrawImage(shotTypes[selectedShotType], shotTypeSelectorBounds); redrawButton = false; } g.DrawBattleSweeperNumbers(game.Player1.Board.CountAllMines(false, false), 3, playerMinesBounds); g.DrawBattleSweeperNumbers(game.Player1.AmmoCount, 3, playerAmmoBounds); g.DrawBattleSweeperNumbers(game.Settings.SimpleMineCount + game.Settings.WideMineCount - game.Player2.Board.CountAllMines(true, false), 3, enemyMinesBounds); g.DrawBattleSweeperNumbers(game.Player2.AmmoCount, 3, enemyAmmoBounds); if (fullRedraw) { g.DrawBattleSweeperBoard(game.Player1.Board, playerBoardBounds, boardCellSize, startLine, lineCount); g.DrawBattleSweeperBoard(game.Player2.Board, enemyBoardBounds, boardCellSize, startLine, lineCount); } else { g.DrawBattleSweeperBoard(game.Player1.Board, playerBoardBounds, boardCellSize, game.RedrawPoints); g.DrawBattleSweeperBoard(game.Player2.Board, enemyBoardBounds, boardCellSize, game.RedrawPoints); } if (startLine + lineCount >= gameSettings.BoardSize || !fullRedraw) { // we done, next update after 15ms - can afford to do that now since the ui thread doesnt hang as much gameUpdateTimer.Interval = 15; timerTickAction = () => { StaggeredUpdateGame(); }; g.Dispose(); } else { timerTickAction = () => { StaggeredDrawGame(game, g, fullRedraw, startLine + lineCount, lineCount); }; } gameUpdateTimer.Start(); }
private void DrawGame(Game game, bool fullRedraw = false) { GraphicsFacade g = new GraphicsFacade(gameWindow, textures); if (redrawButton) { g.DrawImage(shotTypes[selectedShotType], shotTypeSelectorBounds); redrawButton = false; } g.DrawBattleSweeperNumbers(game.Player1.Board.CountAllMines(false, false), 3, playerMinesBounds); g.DrawBattleSweeperNumbers(game.Player1.AmmoCount, 3, playerAmmoBounds); g.DrawBattleSweeperNumbers(game.Settings.SimpleMineCount + game.Settings.WideMineCount - game.Player2.Board.CountAllMines(true, false), 3, enemyMinesBounds); g.DrawBattleSweeperNumbers(game.Player2.AmmoCount, 3, enemyAmmoBounds); g.DrawBattleSweeperBoard(game.Player1.Board, playerBoardBounds, boardCellSize); g.DrawBattleSweeperBoard(game.Player2.Board, enemyBoardBounds, boardCellSize); g.Dispose(); }
private async void StaggeredUpdateGame(bool fullRedraw = false) { gameUpdateTimer.Stop(); Game game = await APIAccessorSingleton.Instance.GetGameState(this.gameKey, fullRedraw? -1 : this.lastState); this.lastState = game.HistoryLastIndex; if (game != null) { GraphicsFacade g = new GraphicsFacade(gameWindow, textures); gameUpdateTimer.Interval = 1; timerTickAction = () => { StaggeredDrawGame(game, g, fullRedraw, 0, 2); }; } gameUpdateTimer.Start(); }