use of objects.Portal in project ultimate-java by pantinor.
the class DungeonScreen method endCombat.
@Override
public void endCombat(boolean isWon, BaseMap combatMap, boolean wounded) {
mainGame.setScreen(this);
if (isWon) {
if (currentEncounter != null) {
log("Victory!");
context.getParty().adjustKarma(KarmaAction.KILLED_EVIL);
int x = (Math.round(currentPos.x) - 1);
int y = (Math.round(currentPos.z) - 1);
/* add a chest, if the creature leaves one */
if (!currentEncounter.getNochest() && dungeonTiles[currentLevel][x][y] == DungeonTile.NOTHING) {
ModelInstance instance = new ModelInstance(chestModel, x + .5f, 0, y + .5f);
instance.nodes.get(0).scale.set(.010f, .010f, .010f);
instance.calculateTransforms();
DungeonTileModelInstance in = new DungeonTileModelInstance(instance, DungeonTile.CHEST, currentLevel);
in.x = x;
in.y = y;
modelInstances.add(in);
dungeonTiles[currentLevel][x][y] = DungeonTile.CHEST;
}
}
} else {
if (combatMap.getType() == MapType.combat && context.getParty().didAnyoneFlee()) {
log("Battle is lost!");
// no flee penalty in dungeons
} else if (!context.getParty().isAnyoneAlive()) {
partyDeath();
}
}
if (currentEncounter != null) {
dngMap.getMap().removeCreature(currentEncounter);
currentEncounter = null;
}
// if exiting dungeon rooms, move out of the room with orientation to next coordinate
if (combatMap.getType() == MapType.dungeon) {
Direction exitDirection = context.getParty().getActivePartyMember().combatMapExitDirection;
if (exitDirection != null) {
currentDir = exitDirection;
int x = (Math.round(currentPos.x) - 1);
int y = (Math.round(currentPos.z) - 1);
// check for portal to another dungeon
for (Portal p : combatMap.getPortals()) {
if (p.getX() == x && p.getY() == y && p.getExitDirection() == exitDirection) {
Maps m = Maps.get(p.getDestmapid());
if (m == dngMap) {
break;
}
log("Entering " + m.getLabel() + "!");
DungeonScreen sc = new DungeonScreen(this.gameScreen, this.context, m);
sc.restoreSaveGameLocation(p.getStartx(), p.getStarty(), p.getStartlevel(), currentDir);
mainGame.setScreen(sc);
this.gameScreen.newMapPixelCoords = this.gameScreen.getMapPixelCoords(p.getRetroActiveDest().getX(), p.getRetroActiveDest().getY());
return;
}
}
if (exitDirection == Direction.EAST) {
x = x + 1;
if (x > 7) {
x = 0;
}
} else if (exitDirection == Direction.WEST) {
x = x - 1;
if (x < 0) {
x = 7;
}
} else if (exitDirection == Direction.NORTH) {
y = y - 1;
if (y < 0) {
y = 7;
}
} else if (exitDirection == Direction.SOUTH) {
y = y + 1;
if (y > 7) {
y = 0;
}
}
DungeonTile tile = dungeonTiles[currentLevel][x][y];
try {
if (tile != DungeonTile.WALL) {
currentPos = new Vector3(x + .5f, .5f, y + .5f);
camera.position.set(currentPos);
if (currentDir == Direction.EAST) {
camera.lookAt(currentPos.x + 1, currentPos.y, currentPos.z);
} else if (currentDir == Direction.WEST) {
camera.lookAt(currentPos.x - 1, currentPos.y, currentPos.z);
} else if (currentDir == Direction.NORTH) {
camera.lookAt(currentPos.x, currentPos.y, currentPos.z - 1);
} else if (currentDir == Direction.SOUTH) {
camera.lookAt(currentPos.x, currentPos.y, currentPos.z + 1);
}
checkTileAffects(tile, x, y);
moveMiniMapIcon();
}
} catch (PartyDeathException e) {
partyDeath();
}
if (tile.getValue() >= 208 && tile.getValue() <= 223) {
RoomLocater loc = null;
for (RoomLocater r : locaters) {
if (r.z == currentLevel && r.x == x && r.y == y) {
loc = r;
break;
}
}
enterRoom(loc, Direction.reverse(currentDir));
}
}
}
}
Aggregations