protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); spriteFont = Content.Load <SpriteFont>("Calibri"); spriteFontVaue = Content.Load <SpriteFont>("Value"); textureManager.LoadContent(); gameGrid = new GameGrid(this.spriteBatch, this.GraphicsDevice, textureManager, this.gridData1, this.spriteFont, this.spriteFontVaue, this.position, this.size); answer = new Answer(this.spriteBatch, this.GraphicsDevice, textureManager, this.gridData1, this.spriteFont, this.spriteFontVaue, this.position, this.size); mainMenu = new MainMenu(this.spriteBatch, this.GraphicsDevice, textureManager, this.spriteFont, this.spriteFontVaue, this.position); }
public void DrawCreateData(GameGrid gameGrid, int gridCount, ref GridData gridData, MouseState mouseState, Vector2 mouseInWorld, int position, int size, GridCell selectedCell, KeyboardState keyboardState, KeyboardState previousState1) { do { if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <position + size& mouseInWorld.Y> position & mouseInWorld.X <position + size& mouseInWorld.X> position) { int tempMouseInWorldX = (int)mouseInWorld.X / 100; tempMouseInWorldX *= 100; int tempMouseInWorldY = (int)mouseInWorld.Y / 100; tempMouseInWorldY *= 100; selectedCell = new GridCell((tempMouseInWorldY - position - (gridData.gridCount / size)) / 100, (tempMouseInWorldX - position - (gridData.gridCount / size)) / 100, gridData.sections[0], gridData); } } while (keyboardState.IsKeyDown(Keys.Enter) & !previousState1.IsKeyDown( Keys.Enter)); gameGrid.Draw(gridData); }
public void UpdateGamePlay(MouseState mouseState, Vector2 mouseInWorld, int position, int size, ref GridCell selectedCell, ref GridData gridData, ref GridData solveGridData, GridSolver gridSolver, GameGrid gameGrid) { if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <position + size& mouseInWorld.Y> position & mouseInWorld.X <position + size& mouseInWorld.X> position) { int tempMouseInWorldX = (int)mouseInWorld.X / 100; tempMouseInWorldX *= 100; int tempMouseInWorldY = (int)mouseInWorld.Y / 100; tempMouseInWorldY *= 100; selectedCell = new GridCell((tempMouseInWorldY - position - (gridData.gridCount / size)) / 100, (tempMouseInWorldX - position - (gridData.gridCount / size)) / 100, gridData.sections[0], gridData); } if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <= 210 & mouseInWorld.Y > 110 & mouseInWorld.X <= position + 100 & mouseInWorld.X >= position & selectedCell != null) { selectedCell.value = 1; gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex].value = selectedCell.value; updatePossibilities(gridData, gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex]); selectedCell = null; } else if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <= 210 & mouseInWorld.Y > 110 & mouseInWorld.X <= position + 100 + (1 * 110) & mouseInWorld.X >= position + (1 * 110) & selectedCell != null) { selectedCell.value = 2; gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex].value = selectedCell.value; updatePossibilities(gridData, gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex]); selectedCell = null; } else if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <= 210 & mouseInWorld.Y > 110 & mouseInWorld.X <= position + 100 + (2 * 110) & mouseInWorld.X >= position + (2 * 110) & selectedCell != null) { selectedCell.value = 3; gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex].value = selectedCell.value; updatePossibilities(gridData, gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex]); selectedCell = null; } else if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <= 210 & mouseInWorld.Y > 110 & mouseInWorld.X <= position + 100 + (3 * 110) & mouseInWorld.X >= position + (3 * 110) & selectedCell != null) { selectedCell.value = 4; gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex].value = selectedCell.value; updatePossibilities(gridData, gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex]); selectedCell = null; } else if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <= 210 & mouseInWorld.Y > 110 & mouseInWorld.X <= position + 100 + (4 * 110) & mouseInWorld.X >= position + (4 * 110) & selectedCell != null) { selectedCell.value = 5; gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex].value = selectedCell.value; updatePossibilities(gridData, gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex]); selectedCell = null; } else if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <= 210 & mouseInWorld.Y > 110 & mouseInWorld.X <= position + 100 + (5 * 110) & mouseInWorld.X >= position + (5 * 110) & selectedCell != null) { selectedCell.value = 6; gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex].value = selectedCell.value; updatePossibilities(gridData, gridData.gridCells[selectedCell.rowIndex, selectedCell.columnIndex]); selectedCell = null; } else if (mouseState.LeftButton == ButtonState.Pressed & mouseInWorld.Y <= 210 & mouseInWorld.Y > 110 & mouseInWorld.X <= position + 100 + (7 * 110) & mouseInWorld.X >= position + (7 * 110)) { solveGridData = gridSolver.SolveAll(solveGridData); this.currentState = State.Answer; } if (mouseState.LeftButton == ButtonState.Pressed & (mouseInWorld.Y > position + size | mouseInWorld.Y <position | mouseInWorld.X> position + size | mouseInWorld.X < position)) { selectedCell = null; } gameGrid.Update(); }
public void DrawGamePlay(GameGrid gameGrid, GridData gridData) { gameGrid.Draw(gridData); }