-
Notifications
You must be signed in to change notification settings - Fork 0
/
GameDriver.java
118 lines (86 loc) · 2.92 KB
/
GameDriver.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
package adventuregame;
import java.util.ArrayList;
import java.util.Scanner;
public class GameDriver {
private Player player;
private static boolean yesNoFlag;
private boolean waitingForBuilding;
Building cachedBuilding;
// private boolean inputTextFlag;
private char[][] charGrid;
public GameDriver() {
yesNoFlag = false;
// inputTextFlag = false;
player = new Player();
loadMaps();
refresh();
}
/**
* Possibly a constructor for loading in a saved game?
*
* @param in
* the textfile for use for loading in a game.
*/
public GameDriver(Scanner in) {
// pass
}
/**
* Makes all of the maps and sets them up
*
*/
public void loadMaps() {
MapObject t1 = new MapObject('T', "town", true, 1, 1);
ArrayList<MapObject> m33 = new ArrayList<>();
m33.add(t1);
LocalMap map33 = new LocalMap("33", m33);
MapObject t2 = new MapObject('T', "town", false, 0, 0);
ArrayList<MapObject> m23 = new ArrayList<>();
m23.add(t2);
LocalMap map23 = new LocalMap("23", m23);
map33.addObjectAt(player.getX(), player.getY(), player);
}
public void refresh() {
charGrid = player.getMap().getCharGrid();
}
public char[][] getCharGrid() {
return charGrid;
}
public Player getPlayer() {
return player;
}
public static boolean getYesNo() {
return yesNoFlag;
}
/**
* Changes the yes/no flag
*/
public void toggleYesNo(boolean yesNo) {
yesNoFlag = yesNo;
}
public void bufferBuilding(Building building) {
}
public void checkSurroundings() {
MapObject[][] mapGrid = player.getMap().getMapObjectGrid();
int arrayLength = mapGrid[0].length;
for (int i = 0; i < arrayLength; i++) {
for (int j = 0; j < arrayLength; j++) {
if (mapGrid[i][j] != null &&
!(mapGrid[i][j].equals(player)) &&
player.withinProximity(i, j)) {
/**
* Check what kind of object the found one is.
*/
if (mapGrid[i][j].getClass() == NPC.class) {
NPC castedNPC = (NPC) mapGrid[i][j];
castedNPC.interactions();
} else if (mapGrid[i][j].getClass() == Building.class) {
waitingForBuilding = true;
cachedBuilding = (Building) mapGrid[i][j];
if (GameDriver.getYesNo()) {
}
}
}
}
}
}
}