This repository has been archived by the owner on Jun 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainGame.cs
74 lines (62 loc) · 2.41 KB
/
MainGame.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
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.IO;
using System;
namespace NerdOrDungeons
{
public class MainGame : Game
{
public static MainGame RiferimentoGlobaleAlGioco;
public SpriteBatch SpriteBatch;
public Scenario Level;
public Arena ArenaMultiplayer;
public Menu MenuPrincipale;
public float DifficultyMultiplier;
public bool Joystick;
public bool PossoUscire;
private GraphicsDeviceManager graphics;
public MainGame()
{
//Posso Uscire Solo Dal Portale EXIT (Non Cliccando Sulla X)
// ((Form)Form.FromHandle(this.Window.Handle)).FormClosing += new FormClosingEventHandler(ImpedisciChiusura);
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = @"Content";
MainGame.RiferimentoGlobaleAlGioco = this;
PossoUscire = false;
SettingsLoad();
}
public void SettingsLoad()
{
StreamReader r = new StreamReader(@".\Content\GameSettings.cfg");
string[] temp = r.ReadLine().Split('/');
r.Close();
r.Dispose();
this.Joystick = Convert.ToBoolean(temp[0]);
this.DifficultyMultiplier = Convert.ToSingle(temp[1]);
}
//private void ImpedisciChiusura(object sender, FormClosingEventArgs e)
//{ e.Cancel = !PossoUscire; }
protected override void LoadContent()
{ this.MenuPrincipale = new Menu(this, @".\Content\Menu"); }
protected override void Update(GameTime gameTime)
{
if (MenuPrincipale != null)
MenuPrincipale.Update(gameTime);
else if (Level != null)
Level.Update(gameTime);
else if (ArenaMultiplayer != null)
ArenaMultiplayer.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
this.SpriteBatch.Begin();
if (MenuPrincipale != null)
MenuPrincipale.Draw(gameTime);
else if (Level != null) // Se sono nel menu non ho il livello istanziato
Level.Draw(gameTime);
else if (ArenaMultiplayer != null)
ArenaMultiplayer.Draw(gameTime);
this.SpriteBatch.End();
}
}
}