-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameManager.cs
61 lines (51 loc) · 1.42 KB
/
GameManager.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
using System;
using AsteroidsGdiApp.GameObjects.Meteors;
namespace AsteroidsGdiApp.Core
{
public class GameManager
{
private AsteroidsGame _game;
private static GameManager _gameManager;
public event EventHandler<MeteorHitEventArgs> MeteorWasHit;
public static GameManager CreateTheGame(AsteroidsGame game)
{
if(_gameManager == null)
{
_gameManager = new GameManager(game);
}
return _gameManager;
}
public static GameManager TheGameManager
{
get { return _gameManager; }
}
private GameManager(AsteroidsGame game)
{
_game = game;
}
public void Draw()
{
_game.Draw();
}
public void ReInitializeGame(IGameController gameController)
{
_game.Init(gameController);
}
public static void RaiseMeteorHit(Meteor meteor)
{
TheGameManager.InvokeMeteorHit(meteor);
}
private void InvokeMeteorHit(Meteor meteor)
{
if (MeteorWasHit != null)
{
MeteorWasHit(this,
new MeteorHitEventArgs {Meteor = meteor });
}
}
}
public class MeteorHitEventArgs : EventArgs
{
public Meteor Meteor;
}
}