-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameScoreKeeper.cs
More file actions
87 lines (71 loc) · 1.97 KB
/
GameScoreKeeper.cs
File metadata and controls
87 lines (71 loc) · 1.97 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
using System.Drawing;
namespace AsteroidsGdiApp.GameObjects
{
public class GameScoreKeeper
{
private SoundManager _soundManager = new SoundManager();
private int _score;
private int _lives = 10;
private int _level;
private bool _gotFreeLive;
private bool _standAloneMode = true;
public int Lives
{
get
{
return _lives;
}
}
public int Level
{
get
{
return _level;
}
}
public void UpdateScore(int points)
{
if(_standAloneMode)
return;
if (_lives < 1)
return;
_score += points;
if (!_gotFreeLive && _score > 10000)
{
IncrementNumberOfLives();
_gotFreeLive = true;
_soundManager.PlayFreeLiveSound();
}
}
public void SetStandaloneMode()
{
_standAloneMode = true;
}
public void StartGame()
{
_lives = 11;
_level = 0;
_score = 0;
_standAloneMode = false;
}
protected void IncrementNumberOfLives()
{
_lives++;
}
public void DecrementNumberOfLives()
{
if(!_standAloneMode)
_lives--;
}
public void IncrementLevel()
{
_level++;
}
public void Draw(Graphics graphics)
{
Font _font = new Font("Courier New", 13);
graphics.DrawString(string.Format("SCORE: {0} LIVES: {0} LEVEL: {2}", _score, (_lives - 1 > 0 ? _lives - 1 : 0), _level),
_font, Brushes.White, new PointF(10, 10));
}
}
}