-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathResultScreen.cs
48 lines (42 loc) · 1.8 KB
/
ResultScreen.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace ShogiClient
{
/// <summary>
/// The screen that is displayed after someone has won
/// </summary>
public class ResultScreen : Screen
{
// Have yet to implement a screen stack so this will have to do for now
private GameplayScreenState gameplayState;
private Texture2D background;
private UIPanel panel;
public ResultScreen(Game1 game, GameplayScreenState gameplayState, Texture2D background) : base(game)
{
this.gameplayState = gameplayState;
this.background = background;
panel = new UIPanel(game)
{
Position = new Vector2(100, 100),
Size = Game.WindowSize - new Vector2(200, 200),
};
}
public override void Update(GameTime gameTime, KeyboardState keyboardState, KeyboardState prevKeyboardState, MouseState mouseState, MouseState prevMouseState)
{
if (keyboardState.IsKeyDown(Keys.Escape) && prevKeyboardState.IsKeyUp(Keys.Escape))
{
Game.SetCurrentScreen(new MainMenuScreen(Game));
return;
}
}
public override void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(background, new Rectangle(Point.Zero, Game.WindowSize.ToPoint()), null, Color.White);
panel.Draw(spriteBatch);
var winner = gameplayState.IsPlayerOneTurn ? "Player 2" : "Player 1";
var winnerText = $"{winner} Won after {gameplayState.TurnList.Count} turns!";
spriteBatch.DrawString(Resources.PieceFont, winnerText, Game.WindowSize / 2 - Resources.PieceFont.MeasureString(winnerText) / 2, Color.White);
}
}
}