/
Game.cs
58 lines (47 loc) · 1.66 KB
/
Game.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
using Microsoft.Xna.Framework;
using NullRPG.Interfaces;
using NullRPG.Managers;
using NullRPG.Windows;
using SadConsole;
namespace NullRPG
{
internal class Game
{
public static GameSession GameSession { get; set; }
public static TitleWindow TitleWindow { get; private set; }
private static void Main()
{
SadConsole.Settings.ResizeMode = Settings.WindowResizeOptions.Stretch;
// Setup the engine and create the main window.
SadConsole.Game.Create(Constants.GameWidth, Constants.GameHeight);
// Hook the start event so we can add consoles to the system.
SadConsole.Game.OnInitialize = Init;
// Hook the update event so we can check for key presses.
SadConsole.Game.OnUpdate = Update;
// Start the game.
SadConsole.Game.Instance.Run();
SadConsole.Game.Instance.Dispose();
}
private static void Update(GameTime gameTime)
{
if (UserInterfaceManager.IsInitialized == true)
UserInterfaceManager.AutoVisiblity();
}
public static void Reset()
{
UserInterfaceManager.IsInitialized = false;
// perhaps add window exceptions
foreach (var window in UserInterfaceManager.GetAll<IUserInterface>())
{
UserInterfaceManager.Remove(window);
}
}
private static void Init()
{
GameSession = new GameSession();
// Shows the main menu
TitleWindow = TitleWindow.Show();
Global.CurrentScreen.IsFocused = true;
}
}
}