Skip to content
Snippets Groups Projects
Commit 99ace40f authored by Trandinh Thien's avatar Trandinh Thien
Browse files

Added which player wins, and which player's turn it is on GUI

parent 03e73b62
No related branches found
No related tags found
No related merge requests found
......@@ -37,6 +37,28 @@ namespace View
}
}
}
/**
Draw who's player turn it currently is. The method takes in the texture containing that info, spriteBatch and the int for the player's whose turn it is.
The method will print the texture for player 1 on left side of screen if it is currently player 1's turn, otherwise it will print it on right side.
\param spriteBatch to draw 2D bitmap to screen
\param player The current player
\param turnInfo the Texture2D containing the text on which player's turn it currently is.
*/
public static void DrawPlayerTurn(SpriteBatch spriteBatch, int player, SpriteFont largestFont)
{
if (player == 1)
{
spriteBatch.DrawString(largestFont, "Player 1 Turn", new Vector2 (50,50), Color.LightBlue, 0,
Vector2.Zero, 1f, SpriteEffects.None, 0.15f);
}
else
{
spriteBatch.DrawString(largestFont, "Player 2 Turn", new Vector2(670, 50), Color.Red, 0,
Vector2.Zero, 1f, SpriteEffects.None, 0.15f);
}
}
/**
Draw Damage pop up numbers from attacking. If GameState currentPlayerDamagePopup is true, draw the damage dealt by attacking player on top of the enemy unit.
If GameState enemyPlayerDamagePopup is true, draw the damage received by defender on top of the recipient.
......@@ -333,7 +355,7 @@ namespace View
}
/**
Draw Game over menu. A game over button texture, the string "Game Over", and a darkened background is drawn to screen.
Draw Game over menu. A game over button texture, the string "Game Over", which player won, and a darkened background is drawn to screen.
\param spriteBatch to draw 2D bitmap to screen
\param gameOver The game over button Texture2D
\param background The background Texture2D
......@@ -342,9 +364,10 @@ namespace View
public static void drawGameOverMenu(SpriteBatch spriteBatch, Texture2D gameOver, Texture2D backGround, SpriteFont largestFont)
{
Vector2 gameOverLocation = new Vector2(-370, -300);
spriteBatch.DrawString(largestFont, "Game Over", new Vector2(350, 200), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f); //draws Game Over Text
spriteBatch.DrawString(largestFont, "Game Over", new Vector2(350, 150), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f); //draws Game Over Text
spriteBatch.DrawString(largestFont, "Player "+ GameState.winningPlayer + " wins" , new Vector2(280, 220), Color.White, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f); //draws Game Over Text
spriteBatch.Draw(gameOver, Vector2.Zero, null, Color.White, 0, gameOverLocation, 1f, SpriteEffects.None, 0f);
spriteBatch.Draw(backGround, Vector2.Zero, null, Color.Black * 0.5f, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.9f);
spriteBatch.Draw(backGround, Vector2.Zero, null, Color.Black * 0.5f, 0, Vector2.Zero, 1f, SpriteEffects.None, 0.2f);
}
/**
......
......@@ -415,6 +415,16 @@ namespace Controller
DrawClass.drawTurnTransition(spriteBatch, player1Transition, player2Transition);
}
if (!GameState.gameOver) {
if (GameState.currentPlayer == player1)
{
DrawClass.DrawPlayerTurn(spriteBatch, 1, largeFont);
} else
{
DrawClass.DrawPlayerTurn(spriteBatch, 2, largeFont);
}
}
spriteBatch.End();
#endregion
......
......@@ -119,12 +119,14 @@ namespace Controller
// if player1 does not have anymore units, game is over
if (player1.getNumOfUnits() <= 0)
{
GameState.winningPlayer = 2;
return true;
}
// if player2 does not have anymore units, game is over
if (player2.getNumOfUnits() <= 0)
{
GameState.winningPlayer = 1;
return true;
}
......
......@@ -164,6 +164,10 @@ namespace Model
Sets and gets movable nodes that can be retrieved without calling path finding
*/
public static LinkedList<Node> moveableNodes { get; set; }
/**
Sets and gets the winning player
*/
public static int winningPlayer { get; set; }
}
/**
enumerated list for different possible Game States
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment