-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameOver.cs
68 lines (63 loc) · 2.17 KB
/
GameOver.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using PointFHelp;
using XInputWrapper;
using HighScore;
namespace Hunt_the_Wumpus
{
class GameOver : Menu
{
bool Won;
uint Time;
public GameOver(bool Won, uint Time)
{
this.Won = Won;
this.Time = Time;
FirstUpdate = true;
}
public override void Initialize()
{
base.Initialize();
GameObject Background;
Game.LifeCounter.Visible = false; // clearing background
Game.DiskCounter.Visible = false; // clearing background
if(Won) // if you win: prompt the win screen and input name for highscore
{
Background = new GameObject("Win", "Win.png", 1366, 768);
Game.RoomMessage.Text = "You had a time of " + (float)(Time / 1000) + " seconds\nEnter your name!";
Game.NameEnter.Visible = true; // allow name entry
string playerName = "";
if (Player1.IsBPressed && CanPressB) // save the name when B is clicked
{
playerName = Game.NameEnter.Text;
}
HighScores.AddEntry(Time, playerName); // add the name and score to the high scores
}
else // if loss: prompt the loss screen
{
Game.RoomMessage.Text = "You had a time of " + (float)(Time / 1000) + " seconds";
Background = new GameObject("Loss", "Loss.png", 1366, 768);
}
ObjectManager.AddGameObject(Background);
}
bool FirstUpdate;
public override void Update()
{
base.Update();
if(FirstUpdate)
{
FirstUpdate = false;
this.Initialize();
}
if(InputManager.IsKeyPressed(Keys.Escape) || (Player1.IsBPressed && CanPressB))
{
Game.RoomMessage.Visible = false;
GameStateManager.CurrentState = new MainMenu();
}
}
}
}