怪物穿門的問題,其實改起來蠻容易的...
主要是isPassable少了對door的辨識...
L1V1Map.java
搜尋public boolean isPassable(int x, int y, int heading) {
==============原始=====================
if (heading == 0) {
tile2 = accessTile(x, y - 1);
}
else if (heading == 1) {
tile2 = accessTile(x + 1, y - 1);
}
else if (heading == 2) {
tile2 = accessTile(x + 1, y);
newX = x + 1;
newY = y;
}
else if (heading == 3) {
tile2 = accessTile(x + 1, y + 1);
newX = x + 1;
newY = y + 1;
}
else if (heading == 4) {
tile2 = accessTile(x, y + 1);
}
else if (heading == 5) {
tile2 = accessTile(x - 1, y + 1);
}
else if (heading == 6) {
tile2 = accessTile(x - 1, y);
}
else if (heading == 7) {
tile2 = accessTile(x - 1, y - 1);
}
else {
return false;
}
==============替換以下===================
int newX;
int newY;
if (heading == 0) {
tile2 = accessTile(x, y - 1);
newX = x;
newY = y - 1;
}
else if (heading == 1) {
tile2 = accessTile(x + 1, y - 1);
newX = x + 1;
newY = y - 1;
}
else if (heading == 2) {
tile2 = accessTile(x + 1, y);
newX = x + 1;
newY = y;
}
else if (heading == 3) {
tile2 = accessTile(x + 1, y + 1);
newX = x + 1;
newY = y + 1;
}
else if (heading == 4) {
tile2 = accessTile(x, y + 1);
newX = x;
newY = y + 1;
}
else if (heading == 5) {
tile2 = accessTile(x - 1, y + 1);
newX = x - 1;
newY = y + 1;
}
else if (heading == 6) {
tile2 = accessTile(x - 1, y);
newX = x - 1;
newY = y;
}
else if (heading == 7) {
tile2 = accessTile(x - 1, y - 1);
newX = x - 1;
newY = y - 1;
}
else {
return false;
}
if (isExistDoor(newX, newY)) {
return false;
}
==============完畢=====================