-
Notifications
You must be signed in to change notification settings - Fork 11
/
Game.java
200 lines (155 loc) · 5.33 KB
/
Game.java
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
import greenfoot.*;
import java.security.*;
/**
* This class is a façade (http://pt.wikipedia.org/wiki/Fa%C3%A7ade) for the most important functions in the GameScriptFacade.
*
* @author Tony Alexander Hild
* @version 0.1a
*/
public final class Game
{
public static final int WEST = 0;
public static final int NORTH = 1;
public static final int EAST = 2;
public static final int SOUTH = 3;
public static final int NONE = -1;
private static SecureRandom random = new SecureRandom();
private static Inventory inventory = new Inventory();
private static boolean isRunning;
private static boolean isSet;
/**
* Singleton object
*/
/*
private final static Game instance = new Game();
*/
/**
* Constructor for objects of class DialogueManager
*/
private Game() {
}
/*
public static Game getInstance() {
return instance;
}
*/
public static SceneManager getSceneManager() {
return SceneManager.getInstance();
}
public static SoundManager getSoundManager() {
return SoundManager.getInstance();
}
public static DialogueManager getDialogueManager() {
return DialogueManager.getInstance();
}
public static void update() {
SceneManager.getInstance().update();
}
public static void playSound(String sound) {
SoundManager.getInstance().playSound(sound);
}
public static void playLoopSound(String sound) {
SoundManager.getInstance().playSound(sound, true);
}
public static void stopSound(String sound) {
SoundManager.getInstance().stopSound(sound);
}
public static void addEntity(Entity entity) {
SceneManager.getInstance().addEntity(entity);
}
public static Entity getEntity(String name) {
return SceneManager.getInstance().getEntity(name);
}
public static void setCurrentWorld(World world) {
SceneManager.getInstance().setCurrentWorld(world);
}
public static World getCurrentWorld() {
return SceneManager.getInstance().getCurrentWorld();
}
public static void setActionWorld(ActionWorld world) {
SceneManager.getInstance().setActionWorld(world);
}
public static ActionWorld getActionWorld() {
return SceneManager.getInstance().getActionWorld();
}
public static void resumeToActionWorld() {
SceneManager.getInstance().resumeToActionWorld();
}
public static void setPc(PlayerCharacter pc) {
SceneManager.getInstance().setPc(pc);
}
public static PlayerCharacter getPc() {
return SceneManager.getInstance().getPc();
}
public static Dialogue getDialogue(String id) {
return DialogueManager.getInstance().getDialogue(id);
}
public static boolean isDialogueClosed(String id) {
return DialogueManager.getInstance().isDialogueClosed(id);
}
public static Dialogue openDialogue(String id, PlayerCharacter player, Character interlocutor) {
return DialogueManager.getInstance().openDialogue(id, player, interlocutor);
}
public static boolean exitDialogue(String id) {
return DialogueManager.getInstance().exitDialogue(id);
}
public static void enableDialogueChoices(boolean enabled) {
DialogueManager.getInstance().enableDialogueChoices(enabled);
}
public static Dialogue redirectToDialogue(String id, PlayerCharacter player, Character interlocutor) {
return DialogueManager.getInstance().redirectToDialogue(id, player, interlocutor);
}
public static void updateDialogueMessages() {
DialogueManager.getInstance().updateDialogueMessages();
}
public static boolean closeDialogue(String id) {
return DialogueManager.getInstance().closeDialogue(id);
}
public static void setScene(Scene scene) {
SceneManager.getInstance().setScene(scene);
}
public static Scene getScene() {
return SceneManager.getInstance().getScene();
}
public static void addScene(Scene scene) {
SceneManager.getInstance().addScene(scene);
}
public static String generateRandomString() {
return new java.math.BigInteger(130, random).toString(32);
}
public static Inventory getInventory() {
return inventory;
}
public static void openInventory() {
inventory.openInventory();
}
public static void addInventoryItem(InventoryItem item) {
inventory.addItem(item);
}
public static void playMusic() {
SceneManager.getInstance().playMusic();
}
public static void pauseMusic() {
SceneManager.getInstance().pauseMusic();
}
public static boolean isRunning() {
return isRunning;
}
public static void setup() {
if(!isSet) {
ScriptManager.invokeMethod("scripts", "gameConfig", "setup");
isSet = true;
}
}
public static void start() {
if(!isSet) {
setup();
}
isRunning = true;
ScriptManager.invokeMethod("scripts", "gameConfig", "start");
}
public static void pause() {
isRunning = false;
ScriptManager.invokeMethod("scripts", "gameConfig", "pause");
}
}