-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGameModel.cs
78 lines (68 loc) · 1.53 KB
/
GameModel.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
using SplashKitSDK;
using TombOfTheMask;
public class GameModel
{
private string _state;
private User _currentUser;
private Map _map;
public GameModel()
{
_state = "home";
_currentUser = null;
}
// Loads the map based on the current user's current stage
public void LoadMap()
{
_map = new Map(Color.Black);
_map.LoadMap(CurrentUser.CurrentStage);
}
// Updates the current user
public void UpdateCurrentUser()
{
if (_currentUser != null)
{
_currentUser.Update();
}
}
// Updates the game (map)
public void UpdateGame()
{
if (_map != null)
{
_map.UpdateMap();
}
}
// Updates the current stage
public void UpdateStage()
{
if (_currentUser != null && _map != null)
{
_currentUser.TotalTime += _map.ElapsedTime;
if (CurrentMap.Win)
{
if (_currentUser.CurrentStage < 4)
{
_currentUser.CurrentStage++;
}
}
UpdateCurrentUser();
}
}
// Gets or sets the game state
public string State
{
get { return _state; }
set { _state = value; }
}
// Gets or sets the current user
public User CurrentUser
{
get { return _currentUser; }
set { _currentUser = value; }
}
// Gets the current map
public Map CurrentMap
{
get { return _map; }
}
}