/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize () { // TODO: Add your initialization logic here ui = new UIt(); base.Initialize (); handler = new GameHandler (ui, ui.GetController()); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here ui = new UIt(); base.Initialize(); handler = new GameHandler(ui, ui.GetController()); }
public void Update() { if (gamePlaying) { ctrl.applyConfig(); int results = playerList [plIndex].Play(ui); if (results == 1) { if (ui.GetController().GameEnd()) { gamePlaying = false; System.IO.File.Delete("Savestate.xml"); } else { plIndex = (plIndex + 1) % playerList.Count; State state = new State(); state.getState(ctrl); state.saveToXML(); } } } }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { graphics.GraphicsDevice.Clear(Color.TransparentBlack); //TODO: Add your drawing code her spriteBatch.Begin(); if (ui.GetController().GameEnd() == false) { drawTextString(ui.GetLetterSelected().ToString(), 40, 16, 16); int boardX = 200; int boardY = 10; int boardsize = 350; int bw = 2; // Border width int bricksy = boardsize + 30; //BRÄDE BAKGRUND: spriteBatch.Draw(ikonen, new Rectangle(boardX, boardY, boardsize, boardsize), Color.White); //KNAPPAR: spriteBatch.Draw(putword, new Rectangle(200, bricksy + boardsize / 7, 100, 50), Color.White); spriteBatch.Draw(newbricks, new Rectangle(200 + 120, bricksy + boardsize / 7, 100, 50), Color.White); spriteBatch.Draw(clear, new Rectangle(200 + 240, bricksy + boardsize / 7, 100, 50), Color.White); //SKRIVA UT BRÄDET: var t = new Texture2D(GraphicsDevice, 1, 1); t.SetData(new[] { Color.White }); spriteBatch.Draw(t, new Rectangle(boardX, boardY, bw, boardsize), Color.White); // Left spriteBatch.Draw(t, new Rectangle(boardX + boardsize, boardY, bw, boardsize), Color.White); // Right spriteBatch.Draw(t, new Rectangle(boardX, boardY, boardsize, bw), Color.White); // Top spriteBatch.Draw(t, new Rectangle(boardX, boardY + boardsize, boardsize, bw), Color.White); // Bottom for (int i = 1; i < 15; i++) { spriteBatch.Draw(t, new Rectangle(boardX, boardY + i * boardsize / 15, boardsize, bw), Color.White); spriteBatch.Draw(t, new Rectangle(boardX + i * boardsize / 15, boardY, bw, boardsize), Color.White); } //SKRIVA UT SPELARENS BRICKOR: spriteBatch.Draw(t, new Rectangle(boardX, bricksy, boardsize, bw), Color.White); spriteBatch.Draw(t, new Rectangle(boardX, bricksy + boardsize / 7, boardsize, bw), Color.White); for (int i = 0; i < 8; i++) { spriteBatch.Draw(t, new Rectangle(boardX + i * boardsize / 7, bricksy, bw, boardsize / 7), Color.White); } drawTextString(ui.GetPlayerLetters(), boardsize / 7, boardX, bricksy); String name = ui.GetPlayerName(); String points = ui.GetScore().ToString(); drawTextString(points, 60 / points.Length, boardX + boardsize + 40, bricksy - 100); drawTextString(name, 160 / name.Length, boardX + boardsize + 40, bricksy); DrawBoard(350, 200, 10); } else { string winner = ui.GetWinnerName(); drawTextString(winner + " won", 300 / winner.Length + 4, 100, 100); } spriteBatch.End(); base.Draw(gameTime); }