-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFGameModManger.java
312 lines (244 loc) · 6.87 KB
/
FGameModManger.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
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
import greenfoot.*;
/**
* Write a description of class GameModManger here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class FGameModManger {
private static FGameModManger instance;
private FLoadGameState loadGameState = new FLoadGameState();
private Logger log = Logger.getInstance();
private FLoadFromAutoSave loadFromAutoSave;
private WGameModeOne gameModeOne;
private WGameModeTow gameModeTow;
private WStartWelt startWelt;
private WPauseWorld pauseWorld;
private WSaveSelct saveSelct;
private WLoding loding;
private WEndWorld endWorld;
int[] decimalArray;
private int level = 0;
private int points;
private int levelstat;
private int currentWorld;
int gamemode;
private boolean isRight;
private boolean GameModeTowisRight;
private String levelName;
private int decimal;
/**
* Constructor for objects of class GameModManger
*/
private FGameModManger() {
}
public void act() {
}
public static FGameModManger getInstance() {
if (instance == null) {
instance = new FGameModManger();
}
return instance;
}
public void gameInit() {
log.call("GameModManger", "setCurrentWorld(1); wird aufgerufen");
setCurrentWorld(2);
}
public void levelUp() {
if (getIsRight()) {
this.levelstat++;
} else {
this.levelstat++;
}
while (this.levelstat == 7) {
System.out.println("Level abgeschlossen" + levelstat);
Greenfoot.delay(1000);
setLevel(getLevel() + 1);
this.levelstat = 0;
startGame();
}
}
public void checkInputGameModeOne(int userInput, int row, int col) {
setIsRight(
gameModeOne.checkUserInputGameModeOne(userInput, row -1));
if (getIsRight()) {
setPoints(getPoints() + 5);
gameModeOne.removeAllObjectsInRow(row, col, Color.GREEN);
levelUp();
} else {
setPoints(getPoints() - 2);
}
System.out.println("isRight" + getIsRight());
}
public void rowCommplet() {
}
public void allRowComplett() {
setPoints(getPoints() + 8);
setLevel(getLevel() + 1);
levelstat = 0;
startGame();
}
private void startGame() {
if(Greenfoot.getRandomNumber(2) == 0){
setGameModeOne();
}else{
setGameModeTow();
}
}
public int getGameMode() {
return gamemode;
}
public void loadfromSave() {
setLevel(loadGameState.getLevel());
setPoints(loadGameState.getPoints());
System.out.println(getLevel());
System.out.println(getPoints());
startGame();
}
public void loadNewGame() {
setLevel(0);
setPoints(0);
startGame();
}
public void setCurrentWorld(int CurrentWorld) {
if (CurrentWorld == 1) {
log.call("setCurrentWorld", "setStartScreen() wird aufgerufen");
setLoadingScreen();
}
if (CurrentWorld == 2) {
setStartScreen();
}
if (CurrentWorld == 3) {
setSaveSelctScreen();
}
if (CurrentWorld == 4) {
setGameModeOne();
}
if (CurrentWorld == 5) {
setGameModeTow();
}
if (CurrentWorld == 6) {
setPauseScreen();
}
if (CurrentWorld == 7) {
setEndScreen();
}
}
public World getCurrentWorld() {
World returnWorld = null;
switch (currentWorld) {
case 1:
returnWorld = startWelt;
break;
case 2:
returnWorld = gameModeOne;
break;
case 3:
returnWorld = gameModeTow;
break;
case 4:
returnWorld = pauseWorld;
break;
case 5:
returnWorld = endWorld;
break;
case 6:
returnWorld = saveSelct;
break;
case 7:
returnWorld = loding;
break;
default:
break;
}
return returnWorld;
}
public int[] getdecimalArray() {
return decimalArray;
}
public void setDecimalArray(int[] decimalArray) {
this.decimalArray = decimalArray;
}
public boolean checkUserInputGameModeOne(int userInput, int rowIndex) {
if (rowIndex >= 0 && rowIndex < decimalArray.length) {
int correctDecimal = decimalArray[rowIndex];
return userInput == correctDecimal;
}
return false;
}
public void loadfromAutoSave() {
loadFromAutoSave = new FLoadFromAutoSave();
setLevel(loadFromAutoSave.getLevel());
setPoints(loadFromAutoSave.getPoints());
startGame();
}
public void autoSaveGame() {
log.call(levelName, levelName);
new FUpdateAutoSave(this.getLevel(), this.getPoints());
}
public void saveGame() {
// TODO: Implementierung fehlt
}
public void setLevelName(String levelName) {
this.levelName = levelName;
}
private void setLevel(int l) {
level = l;
}
private void setPoints(int p) {
points = p;
}
private void setIsRight(boolean isRight) {
this.isRight = isRight;
}
public void setGameModeTow() {
Greenfoot.setWorld(new WGameModeTow());
}
public void setGameModeOne() {
this.gameModeOne = new WGameModeOne();
Greenfoot.setWorld(this.gameModeOne);
}
public void setStartScreen() {
Greenfoot.setWorld(new WStartWelt());
}
public void setPauseScreen() {
Greenfoot.setWorld(new WPauseWorld());
}
public void setEndScreen() {
Greenfoot.setWorld(new WEndWorld());
}
public void setLoadingScreen() {
Greenfoot.setWorld(new WLoding());
}
public void setSaveSelctScreen() {
Greenfoot.setWorld(new WSaveSelct());
}
public void setGameModeTowisRight(boolean GameModeTowisRight) {
this.GameModeTowisRight = GameModeTowisRight;
}
public void setDecimal(int decimal) {
this.decimal = decimal;
}
public int getDecimal() {
return decimal;
}
public boolean getGameModeTowisRight() {
return GameModeTowisRight;
}
public GreenfootImage getImage(String path) {
GreenfootImage image = new GreenfootImage(path);
return image;
}
public String getLevelName() {
return levelName;
}
private boolean getIsRight() {
return isRight;
}
public int getPoints() {
return points;
}
public int getLevel() {
return level;
}
}