-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameSystem.cs
312 lines (292 loc) · 12.5 KB
/
GameSystem.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.IO;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Media;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SAIYASASTRA
{
/// <summary>
/// This is the main type for your game.
/// </summary>
public class GameSystem : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont font;
string Textg1 = "0";
public List<SoundEffect> ButtonSFX;
public List<SoundEffect> SoundSFX;
public List<SoundEffect> CutSenceSFX;
public List <SoundEffect> FootStepSFX;
public Song MusicMainMenu,
MusicLevel,
MusicGhostAttack,
MusicEnding,
MusicEnding2;
public Song[] MusicCutScene = new Song[5];
public Intro_Screen mIntro_Screen;
public MainMenu mMainMenu;
public PauseAndDiedMenu mPauseDiedMenu;
public Screen ScreenCurrent;
public Level1 mLevel1;
public Level2 mLevel2;
public Level3 mLevel3;
public Level4 mLevel4;
public EndingScene mEndingScene;
public Transition_Game GetTransition;
public GameIn GetTransitionIn;
public GameOut GetTransitionOut;
public Effect_Level2 GetEffectLevel2;
public JumpScareEffact GetJumpScareEffact;
public Vector2 MousePosition;
public int FrameTransitionIn,
FrameTransitionOut,
Level = 0,
Holy_Num = 0,
Text_Num = 0,
GhostPos = -192,
SpeedGhostLevel1 = 0,
SpeedGhostLevel2 = 0,
GhostPos_Level2 = -192,
SpeedGhostLevel3 = 0,
GhostPos_Level3 = -192,
GhostWalkBackward = 0,
CharHart = 100;
public bool PlayTransitionIn = false,
PlayTransitionOut = false,
PlayEffectLevel2 = false,
IsGhost_DiedLevel2 = false,
IsGhost_DiedLevel3 = false,
IsShowChar = true,
IsPlaySFXGhostSee = true,
PlayJumpScareEffact = false,
ISGhostBackward = false,
IsGhost_See = false,
IsPauseMenu = false,
IsDiedMenu = false,
IsPlayMusic = true,
IsPlaySFX = true,
IsReset = false,
IsPlaySFXCutSence = true,
IsplayMusicGAttack = true,
IsplayMusicLevel = false,
IsGamePause = false;
public GameSystem()
{
graphics = new GraphicsDeviceManager(this);
graphics.GraphicsProfile = GraphicsProfile.HiDef;
IsMouseVisible = true;
Content.RootDirectory = "Content";
ButtonSFX = new List<SoundEffect>();
CutSenceSFX = new List<SoundEffect>();
SoundSFX = new List<SoundEffect>();
FootStepSFX = new List<SoundEffect>();
}
/// <summary>
/// Allows the game to perform any initialization it needs to before starting to run.
/// This is where it can query for any required services and load any non-graphic
/// related content. Calling base.Initialize will enumerate through any components
/// and initialize them as well.
/// </summary>
protected override void Initialize()
{
// TODO: Add your initialization logic here
graphics.PreferredBackBufferWidth = 1280;
graphics.PreferredBackBufferHeight = 720;
graphics.ApplyChanges();
base.Initialize();
}
/// <summary>
/// LoadContent will be called once per game and is the place to load
/// all of your content.
/// </summary>
protected override void LoadContent()
{
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
font = Content.Load<SpriteFont>("November");
mIntro_Screen = new Intro_Screen(this, new EventHandler(GameScreenEvent));
mMainMenu = new MainMenu(this, new EventHandler(GameScreenEvent));
mPauseDiedMenu = new PauseAndDiedMenu(this, new EventHandler(GameScreenEvent));
mLevel1 = new Level1(this, new EventHandler(GameScreenEvent));
mLevel2 = new Level2(this, new EventHandler(GameScreenEvent));
mLevel3 = new Level3(this, new EventHandler(GameScreenEvent));
mLevel4 = new Level4(this, new EventHandler(GameScreenEvent));
mEndingScene = new EndingScene(this, new EventHandler(GameScreenEvent));
GetTransitionIn = new GameIn(this, new EventHandler(GameTransitionEvent));
GetTransitionOut = new GameOut(this, new EventHandler(GameTransitionEvent));
GetEffectLevel2 = new Effect_Level2(this, new EventHandler(GameTransitionEvent));
GetJumpScareEffact = new JumpScareEffact(this, new EventHandler(GameTransitionEvent));
ScreenCurrent = mIntro_Screen;
GetTransition = GetTransitionIn;
//เสียงเท้า
FootStepSFX.Add(Content.Load<SoundEffect>("EndingFootStep1"));
FootStepSFX.Add(Content.Load<SoundEffect>("EndingFootStep2"));
FootStepSFX.Add(Content.Load<SoundEffect>("EndingFootStep3"));
//เสียง SFX
ButtonSFX.Add(Content.Load<SoundEffect>("Button01"));
ButtonSFX.Add(Content.Load<SoundEffect>("Button02"));
ButtonSFX.Add(Content.Load<SoundEffect>("Button03"));
CutSenceSFX.Add(Content.Load<SoundEffect>("CutSenceSFX"));
//เสียงเดิน/กระโดด 0 - 2
SoundSFX.Add(Content.Load<SoundEffect>("Walk_Footstep"));
SoundSFX.Add(Content.Load<SoundEffect>("Jump Up"));
SoundSFX.Add(Content.Load<SoundEffect>("Jump Landing"));
//เสียงเก็บขวดน้ำมนต์ 3 - 6
SoundSFX.Add(Content.Load<SoundEffect>("Item1SFX"));
SoundSFX.Add(Content.Load<SoundEffect>("HolySFX"));
SoundSFX.Add(Content.Load<SoundEffect>("HolyUseSFX"));
SoundSFX.Add(Content.Load<SoundEffect>("TossItem"));
//เสียงยันต์ 7 - 9
SoundSFX.Add(Content.Load<SoundEffect>("TalismanSFX"));
SoundSFX.Add(Content.Load<SoundEffect>("TalismanPickSFX"));
SoundSFX.Add(Content.Load<SoundEffect>("TalismanPlaceSFX"));
//เสียงผีร้อง 10 - 11
SoundSFX.Add(Content.Load<SoundEffect>("GhostLauhing"));
SoundSFX.Add(Content.Load<SoundEffect>("GhostScream"));
//ตาย 12
SoundSFX.Add(Content.Load<SoundEffect>("DeadSFX"));
//วาร์ป 13 - 14
SoundSFX.Add(Content.Load<SoundEffect>("WarpSFX"));
SoundSFX.Add(Content.Load<SoundEffect>("DoorLevel2SFX"));
//พลัง 15
SoundSFX.Add(Content.Load<SoundEffect>("TalismanPowerSFX"));
//เสียงน้อนเปรต 16 - 18
SoundSFX.Add(Content.Load<SoundEffect>("GhostLevel4"));
SoundSFX.Add(Content.Load<SoundEffect>("GhostAttack01"));
SoundSFX.Add(Content.Load<SoundEffect>("GhostAttack02"));
SoundEffect.MasterVolume = 1.0f;
this.MusicMainMenu = Content.Load<Song>("MainMenuMusic");
this.MusicEnding = Content.Load<Song>("MusicCredit");
this.MusicEnding2 = Content.Load<Song>("MusicCredit2");
this.MusicCutScene[4] = Content.Load<Song>("CutSenceMusic");
this.MusicCutScene[0] = Content.Load<Song>("MusicCutSence1");
this.MusicLevel = Content.Load<Song>("LevelMusic");
this.MusicGhostAttack = Content.Load<Song>("GhostMusic");
}
/// <summary>
/// UnloadContent will be called once per game and is the place to unload
/// game-specific content.
/// </summary>
protected override void UnloadContent()
{
// TODO: Unload any non ContentManager content here
}
/// <summary>
/// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Update(GameTime gameTime)
{
// TODO: Add your update logic here
MouseState mouseState = Mouse.GetState();
MousePosition.X = mouseState.X;
MousePosition.Y = mouseState.Y;
Textg1 = Convert.ToString(MousePosition + " <Out> " + FrameTransitionOut + " <In> " + FrameTransitionIn + " <GhostPos> " + GhostPos + " <IsPauseMenu> " + IsPauseMenu +" <> "+ IsplayMusicGAttack);
if(IsReset == true)
{
mLevel1.Reset_To_Level();
mLevel2.Reset_To_Level();
mLevel3.Reset_To_Level();
mLevel4.Reset_To_Level();
mEndingScene.Reset();
IsReset = false;
}
ScreenCurrent.UpdateGame(gameTime);
GetTransition.Update(gameTime);
GetEffectLevel2.Update(gameTime);
GetJumpScareEffact.Update(gameTime);
base.Update(gameTime);
}
/// <summary>
/// This is called when the game should draw itself.
/// </summary>
/// <param name="gameTime">Provides a snapshot of timing values.</param>
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.Black);
// TODO: Add your drawing code here
spriteBatch.Begin();
//DrawGame
ScreenCurrent.Draw(spriteBatch);
//Effect
if (PlayJumpScareEffact == true && IsGamePause == false)
{
GetJumpScareEffact.Draw(spriteBatch);
}
if (PlayEffectLevel2 == true)
{
GetEffectLevel2.Draw(spriteBatch);
}
//Transition
if(PlayTransitionIn == true)
{
GetTransition = GetTransitionIn;
GetTransition.Draw(spriteBatch);
} else
{
FrameTransitionIn = 0;
}
if (PlayTransitionOut == true)
{
GetTransition = GetTransitionOut;
GetTransition.Draw(spriteBatch);
} else
{
FrameTransitionOut = 6;
}
//String
//spriteBatch.DrawString(font, Textg1, new Vector2(20, 650), Color.White);
spriteBatch.End();
base.Draw(gameTime);
}
public void GameScreenEvent(object obj, EventArgs e)
{
ScreenCurrent = (Screen)obj;
}
public void GameTransitionEvent(object obj, EventArgs e)
{
GetTransition = (Transition_Game)obj;
}
public void ResetGame()
{
Text_Num = 0;
PlayTransitionIn = false;
PlayTransitionOut = false;
PlayEffectLevel2 = false;
IsGhost_DiedLevel2 = false;
IsGhost_DiedLevel3 = false;
IsShowChar = true;
IsPlaySFXGhostSee = true;
PlayJumpScareEffact = false;
ISGhostBackward = false;
IsGhost_See = false;
IsPauseMenu = false;
IsDiedMenu = false;
IsPlayMusic = true;
IsPlaySFX = true;
IsPlaySFXCutSence = true;
IsplayMusicGAttack = true;
IsplayMusicLevel = false;
IsGamePause = false;
Level = 0;
Holy_Num = 0;
GhostPos = -192;
SpeedGhostLevel1 = 0;
SpeedGhostLevel2 = 0;
GhostPos_Level2 = -192;
SpeedGhostLevel3 = 0;
GhostPos_Level3 = -192;
GhostWalkBackward = 0;
CharHart = 100;
}
}
}