public override void Draw(GameTime gameTime, StereoEye stereoEye) { int w = Game.GraphicsDevice.DisplayBounds.Width; int h = Game.GraphicsDevice.DisplayBounds.Height; var sb = Game.GetService <SpriteBatch>(); var rand = new Random(); // Game.GraphicsDevice.ClearBackbuffer(Color4.Black); Game.GraphicsDevice.ClearBackbuffer(Color4.White); sb.Begin(); foreach (var cell in Field) { var coord = new Vector2(); cell.cartCoord(out coord); var xTopLeft = w / 2 + coord.X - hexW / 2; var yTopLeft = h / 2 + coord.Y - hexH / 2; sb.Draw(hex, xTopLeft, yTopLeft, hexW, hexH, (cell.mark == cellStatus.OPENED) ? new Color(132, 204, 129) : new Color(75, 70, 105)); switch (cell.mark) { case cellStatus.FLAG: sb.Draw(flag, xTopLeft + 0.2f * hexW, yTopLeft + 0.2f * hexH, hexW * 0.6f, hexH * 0.6f, Color.White); break; case cellStatus.QUESTION: sb.Draw(question, xTopLeft, yTopLeft, hexW, hexH, Color.White); break; case cellStatus.OPENED: // if (cell.bombNeighboursCount > 0) font.DrawString(sb, cell.bombNeighboursCount.ToString(), xTopLeft + 0.5f * (hexW - font.MeasureString(cell.bombNeighboursCount.ToString()).Width), yTopLeft + 0.5f * (hexH + font.AverageCapitalLetterHeight), Color.Black); if (cell.bombNeighboursCount > 0) { font.DrawString(sb, cell.bombNeighboursCount.ToString(), xTopLeft + 0.5f * (hexW - font.MeasureString(cell.bombNeighboursCount.ToString()).Width), yTopLeft + 0.5f * (hexH + 10), Color.Black); } break; } if (status != gameStatus.CONTINUES && cell.hasBomb) { sb.Draw(bomb, xTopLeft + 0.2f * hexW, yTopLeft + 0.2f * hexH, hexW * 0.6f, hexH * 0.6f, Color.White); } } if (status != gameStatus.CONTINUES) { if (status == gameStatus.LOST) { sb.Draw(loser, (w - loserWidth) / 2, (h - loserHeight) / 2, loserWidth, loserHeight, Color.White); } else { sb.Draw(winner, (w - winnerWidth) / 2, (h - winnerHeight) / 2, winnerWidth, winnerHeight, Color.White); } } sb.End(); base.Draw(gameTime, stereoEye); }
public override void Update(GameTime gameTime) { if (status == gameStatus.CONTINUES) { var ds = Game.GetService <DebugStrings>(); ds.Add(Color.Yellow, "Total number of bombs on the map: {0}", bombCounter); } base.Update(gameTime); }