-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame1.cs
More file actions
116 lines (82 loc) · 2.78 KB
/
Game1.cs
File metadata and controls
116 lines (82 loc) · 2.78 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
namespace MyGame;
using Myra;
public class Game1 : Game
{
private GraphicsDeviceManager _graphics;
public static SpriteBatch _spriteBatch;
private GameManager _gameManager;
private MusicManager _musicManager;
public static Texture2D pixel;
private UpgradeManagerUI _upgradeManager;
private ProfileChartsManager _profileChartsManager;
private MainMenu _mainmenu;
public static bool GAMESTART = false, GAMEEXIT = false;
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsMouseVisible = true;
}
protected override void Initialize()
{
Globals.WindowSize = new(1280, 720);
_graphics.PreferredBackBufferWidth = Globals.WindowSize.X;
_graphics.PreferredBackBufferHeight = Globals.WindowSize.Y;
_graphics.ApplyChanges();
Globals.Content = Content;
PythonBridge.ClearJsonData("All");
ProfileManager.ClearCounts();
_gameManager = new();
_gameManager.Init(_musicManager);
GameManager.PauseGame();
base.Initialize();
}
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
Globals.SpriteBatch = _spriteBatch;
MyraEnvironment.Game = this;
_upgradeManager = new UpgradeManagerUI();
_profileChartsManager = new ProfileChartsManager();
_mainmenu = new MainMenu();
_musicManager = new MusicManager();
}
protected override void Update(GameTime gameTime)
{
if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape) || Globals.Exitgame)
Exit();
Globals.Update(gameTime);
_gameManager.Update();
if (Soul.MENUUPDATE)
{
_upgradeManager.UpdatePanelData();
Soul.MENUUPDATE = false;
}
if (GAMEEXIT) this.Exit();
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
pixel = new Texture2D(GraphicsDevice, 1, 1);
pixel.SetData(new[] { Color.Red });
_gameManager.Draw();
if (Soul.UPGRADEMENU) _upgradeManager.Render();
if (GameManager.GAMEOVER)
{
_musicManager.PlayMusic("GameOver");
_profileChartsManager.UpdateChartData();
_profileChartsManager.Render();
_gameManager = new();
_gameManager.Init(_musicManager);
}
if (!GAMESTART)
{
_musicManager.PlayMusic("Menu");
_mainmenu.Render();
_gameManager = new();
_gameManager.Init(_musicManager);
}
base.Draw(gameTime);
}
}