v0.5.0: fixed a number of edge-case issues with walls, fog, and wall blocking
This commit is contained in:
parent
d1f729500a
commit
003951ab00
|
@ -3,7 +3,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
classpath 'com.android.tools.build:gradle:2.2.3'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,13 +66,13 @@ public class DungeonWallsTilemap extends DungeonTilemap {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Dungeon.level.insideMap(pos) && DungeonTileSheet.wallStitcheable.contains(map[pos+mapWidth])) {
|
if (pos + mapWidth < size && DungeonTileSheet.wallStitcheable.contains(map[pos+mapWidth])) {
|
||||||
|
|
||||||
return DungeonTileSheet.stitchWallOverhangTile(
|
return DungeonTileSheet.stitchWallOverhangTile(
|
||||||
tile,
|
tile,
|
||||||
map[pos + 1 + mapWidth],
|
(pos+1) % mapWidth != 0 ? map[pos + 1 + mapWidth] : -1,
|
||||||
map[pos + mapWidth],
|
map[pos + mapWidth],
|
||||||
map[pos - 1 + mapWidth]
|
pos % mapWidth != 0 ? map[pos - 1 + mapWidth] : -1
|
||||||
);
|
);
|
||||||
|
|
||||||
} else if (Dungeon.level.insideMap(pos) && (map[pos+mapWidth] == Terrain.DOOR || map[pos+mapWidth] == Terrain.LOCKED_DOOR) ) {
|
} else if (Dungeon.level.insideMap(pos) && (map[pos+mapWidth] == Terrain.DOOR || map[pos+mapWidth] == Terrain.LOCKED_DOOR) ) {
|
||||||
|
|
|
@ -167,12 +167,17 @@ public class FogOfWar extends Image {
|
||||||
|
|
||||||
if (cell + mapWidth < mapLength){
|
if (cell + mapWidth < mapLength){
|
||||||
if (!DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell + mapWidth])
|
if (!DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell + mapWidth])
|
||||||
&& getColorIndexForCell(cell + mapWidth) > cellIndex) {
|
&& !DungeonTileSheet.doorTiles.contains(Dungeon.level.map[cell + mapWidth])){
|
||||||
cellIndex = getColorIndexForCell(cell + mapWidth);
|
if (getColorIndexForCell(cell + mapWidth) > cellIndex)
|
||||||
|
cellIndex = getColorIndexForCell(cell + mapWidth);
|
||||||
|
fillCell(j, i, FOG_COLORS[cellIndex][brightness]);
|
||||||
|
cell++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cell % mapWidth != 0){
|
if (cell % mapWidth != 0){
|
||||||
if (DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell - 1])){
|
if (DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell - 1])
|
||||||
|
|| DungeonTileSheet.doorTiles.contains(Dungeon.level.map[cell - 1])){
|
||||||
if (getColorIndexForCell(cell - 1 + mapWidth) > cellIndex)
|
if (getColorIndexForCell(cell - 1 + mapWidth) > cellIndex)
|
||||||
colorArray[0] = colorArray[2] = FOG_COLORS[getColorIndexForCell(cell - 1 + mapWidth)][brightness];
|
colorArray[0] = colorArray[2] = FOG_COLORS[getColorIndexForCell(cell - 1 + mapWidth)][brightness];
|
||||||
else
|
else
|
||||||
|
@ -188,7 +193,8 @@ public class FogOfWar extends Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cell+1) % mapWidth != 0){
|
if ((cell+1) % mapWidth != 0){
|
||||||
if (DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell + 1])){
|
if (DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell + 1])
|
||||||
|
|| DungeonTileSheet.doorTiles.contains(Dungeon.level.map[cell + 1])){
|
||||||
if (getColorIndexForCell(cell + 1 + mapWidth) > cellIndex)
|
if (getColorIndexForCell(cell + 1 + mapWidth) > cellIndex)
|
||||||
colorArray[1] = colorArray[3] = FOG_COLORS[getColorIndexForCell(cell + 1 + mapWidth)][brightness];
|
colorArray[1] = colorArray[3] = FOG_COLORS[getColorIndexForCell(cell + 1 + mapWidth)][brightness];
|
||||||
else
|
else
|
||||||
|
@ -218,6 +224,12 @@ public class FogOfWar extends Image {
|
||||||
}
|
}
|
||||||
|
|
||||||
fillCell(j, i, colorArray);
|
fillCell(j, i, colorArray);
|
||||||
|
} else if (DungeonTileSheet.doorTiles.contains(Dungeon.level.map[cell])) {
|
||||||
|
|
||||||
|
colorArray[0] = colorArray[1] = FOG_COLORS[getColorIndexForCell(cell)][brightness];
|
||||||
|
colorArray[2] = colorArray[3] = FOG_COLORS[getColorIndexForCell(cell + mapWidth)][brightness];
|
||||||
|
fillCell(j, i, colorArray);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fillCell(j, i, FOG_COLORS[getColorIndexForCell(cell)][brightness]);
|
fillCell(j, i, FOG_COLORS[getColorIndexForCell(cell)][brightness]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,20 +55,26 @@ public class WallBlockingTilemap extends Tilemap {
|
||||||
if (fogHidden(cell) && fogHidden(cell - mapWidth)){
|
if (fogHidden(cell) && fogHidden(cell - mapWidth)){
|
||||||
curr = BLOCK_NONE;
|
curr = BLOCK_NONE;
|
||||||
|
|
||||||
} else if (DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell])) {
|
} else if (wall(cell)) {
|
||||||
if (cell + mapWidth < Dungeon.level.map.length) {
|
if (cell + mapWidth < Dungeon.level.map.length) {
|
||||||
if (!DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell + mapWidth])) {
|
if (!wall(cell + mapWidth)) {
|
||||||
if (fogHidden(cell + mapWidth)) {
|
if (!fogHidden(cell + mapWidth)){
|
||||||
curr = BLOCK_ALL;
|
|
||||||
} else {
|
|
||||||
curr = BLOCK_NONE;
|
curr = BLOCK_NONE;
|
||||||
|
} else if ((cell + 1) % mapWidth != 0 && !fogHidden(cell + 1)
|
||||||
|
&& !door(cell + 1) && !(wall(cell + 1) && wall(cell + 1 + mapWidth))){
|
||||||
|
curr = BLOCK_NONE;
|
||||||
|
} else if (cell % mapWidth != 0 && !fogHidden(cell - 1)
|
||||||
|
&& !door(cell - 1) && !(wall(cell - 1) && wall(cell - 1 + mapWidth))){
|
||||||
|
curr = BLOCK_NONE;
|
||||||
|
} else {
|
||||||
|
curr = BLOCK_ALL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
curr = BLOCK_NONE;
|
curr = BLOCK_NONE;
|
||||||
|
|
||||||
if ((cell + 1) % mapWidth != 0) {
|
if ((cell + 1) % mapWidth != 0) {
|
||||||
|
|
||||||
if (!DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell + 1])){
|
if (!wall(cell + 1) && !door(cell + 1)){
|
||||||
if (fogHidden(cell + 1)) {
|
if (fogHidden(cell + 1)) {
|
||||||
curr += 1;
|
curr += 1;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +88,7 @@ public class WallBlockingTilemap extends Tilemap {
|
||||||
|
|
||||||
if (cell % mapWidth != 0) {
|
if (cell % mapWidth != 0) {
|
||||||
|
|
||||||
if (!DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell - 1])){
|
if (!wall(cell - 1) && !door(cell - 1)){
|
||||||
if (fogHidden(cell - 1)) {
|
if (fogHidden(cell - 1)) {
|
||||||
curr += 2;
|
curr += 2;
|
||||||
}
|
}
|
||||||
|
@ -120,7 +126,20 @@ public class WallBlockingTilemap extends Tilemap {
|
||||||
|
|
||||||
private boolean fogHidden(int cell){
|
private boolean fogHidden(int cell){
|
||||||
if (cell < 0 || cell >= Dungeon.level.length()) return false;
|
if (cell < 0 || cell >= Dungeon.level.length()) return false;
|
||||||
return (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell]);
|
if (wall(cell) && cell + mapWidth < Dungeon.level.length() && !wall(cell + mapWidth)){
|
||||||
|
return (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell])
|
||||||
|
|| (!Dungeon.level.visited[cell + mapWidth] && !Dungeon.level.mapped[cell + mapWidth]);
|
||||||
|
} else {
|
||||||
|
return (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean wall(int cell){
|
||||||
|
return DungeonTileSheet.wallStitcheable.contains(Dungeon.level.map[cell]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean door(int cell ) {
|
||||||
|
return DungeonTileSheet.doorTiles.contains(Dungeon.level.map[cell]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void updateArea(int x, int y, int w, int h) {
|
public synchronized void updateArea(int x, int y, int w, int h) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user