use of ultima.SpellInputProcessor in project ultimate-java by pantinor.
the class StaticGeneratedDungeonScreen method keyUp.
@Override
public boolean keyUp(int keycode) {
int x = (Math.round(currentPos.x) - 1);
int y = (Math.round(currentPos.z) - 1);
DungeonTile tile = dungeonTiles[currentLevel][x][y];
if (keycode == Keys.LEFT) {
if (currentDir == Direction.EAST) {
camera.lookAt(currentPos.x, currentPos.y, currentPos.z - 1);
currentDir = Direction.NORTH;
} else if (currentDir == Direction.WEST) {
camera.lookAt(currentPos.x, currentPos.y, currentPos.z + 1);
currentDir = Direction.SOUTH;
} else if (currentDir == Direction.NORTH) {
camera.lookAt(currentPos.x - 1, currentPos.y, currentPos.z);
currentDir = Direction.WEST;
} else if (currentDir == Direction.SOUTH) {
camera.lookAt(currentPos.x + 1, currentPos.y, currentPos.z);
currentDir = Direction.EAST;
}
setCreatureRotations();
return false;
} else if (keycode == Keys.RIGHT) {
if (currentDir == Direction.EAST) {
camera.lookAt(currentPos.x, currentPos.y, currentPos.z + 1);
currentDir = Direction.SOUTH;
} else if (currentDir == Direction.WEST) {
camera.lookAt(currentPos.x, currentPos.y, currentPos.z - 1);
currentDir = Direction.NORTH;
} else if (currentDir == Direction.NORTH) {
camera.lookAt(currentPos.x + 1, currentPos.y, currentPos.z);
currentDir = Direction.EAST;
} else if (currentDir == Direction.SOUTH) {
camera.lookAt(currentPos.x - 1, currentPos.y, currentPos.z);
currentDir = Direction.WEST;
}
setCreatureRotations();
return false;
} else if (keycode == Keys.UP) {
// forward
if (currentDir == Direction.EAST) {
x = x + 1;
} else if (currentDir == Direction.WEST) {
x = x - 1;
} else if (currentDir == Direction.NORTH) {
y = y - 1;
} else if (currentDir == Direction.SOUTH) {
y = y + 1;
}
tile = dungeonTiles[currentLevel][x][y];
if (tile != DungeonTile.WALL && tile != DungeonTile.FIELD_ENERGY) {
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);
}
try {
checkTileAffects(tile, x, y);
} catch (PartyDeathException e) {
partyDeath();
return false;
}
}
} else if (keycode == Keys.DOWN) {
// backwards
if (currentDir == Direction.EAST) {
x = x - 1;
} else if (currentDir == Direction.WEST) {
x = x + 1;
} else if (currentDir == Direction.NORTH) {
y = y + 1;
} else if (currentDir == Direction.SOUTH) {
y = y - 1;
}
tile = dungeonTiles[currentLevel][x][y];
if (tile != DungeonTile.WALL && tile != DungeonTile.FIELD_ENERGY) {
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);
}
try {
checkTileAffects(tile, x, y);
} catch (PartyDeathException e) {
partyDeath();
return false;
}
}
} else if (keycode == Keys.K) {
if (tile == DungeonTile.LADDER_UP || tile == DungeonTile.LADDER_UP_DOWN) {
currentLevel--;
if (currentLevel < 0) {
currentLevel = 0;
if (mainGame != null) {
mainGame.setScreen(gameScreen);
dispose();
}
}
}
return false;
} else if (keycode == Keys.D) {
if (tile == DungeonTile.LADDER_DOWN || tile == DungeonTile.LADDER_UP_DOWN) {
currentLevel++;
if (currentLevel > DUNGEON_MAP) {
currentLevel = DUNGEON_MAP;
}
}
return false;
} else if (keycode == Keys.N) {
log("New Order:");
log("exhange #:");
NewOrderInputAdapter noia = new NewOrderInputAdapter(this);
Gdx.input.setInputProcessor(noia);
return false;
} else if (keycode == Keys.C) {
log("Cast Spell: ");
log("Who casts (1-8): ");
Gdx.input.setInputProcessor(new SpellInputProcessor(this, context, stage, x, y, null));
} else if (keycode == Keys.I) {
isTorchOn = !isTorchOn;
} else if (keycode == Keys.G || keycode == Keys.R || keycode == Keys.W) {
log("Which party member?");
Gdx.input.setInputProcessor(sip);
sip.setinitialKeyCode(keycode, tile, x, y);
} else if (keycode == Keys.H) {
CombatScreen.holeUp(this.dngMap, x, y, this, context, Ultima4.creatures, Ultima4.standardAtlas, false);
return false;
} else if (keycode == Keys.V) {
} else if (keycode == Keys.M) {
mainGame.setScreen(new MixtureScreen(mainGame, this, Ultima4.skin, context.getParty()));
} else if (keycode == Keys.S) {
if (tile == DungeonTile.ALTAR) {
log("Search Altar");
ItemMapLabels l = dngMap.getMap().searchLocation(this, context.getParty(), x, y, currentLevel);
if (l != null) {
log("You found " + l.getDesc() + ".");
} else {
log("Nothing!");
}
} else {
if (tile.getValue() >= 144 && tile.getValue() <= 148) {
log("You find a Fountain. Who drinks?");
} else if (tile == DungeonTile.ORB) {
log("You find a Magical Orb...Who touches?");
} else {
log("Who searches?");
}
Gdx.input.setInputProcessor(sip);
sip.setinitialKeyCode(keycode, tile, x, y);
}
} else if (keycode == Keys.Q) {
context.saveGame(x, y, currentLevel, currentDir, dngMap);
log("Saved Game.");
return false;
} else if (keycode == Keys.Z) {
showZstats = showZstats + 1;
if (showZstats >= STATS_PLAYER1 && showZstats <= STATS_PLAYER8) {
if (showZstats > context.getParty().getMembers().size()) {
showZstats = STATS_WEAPONS;
}
}
if (showZstats > STATS_SPELLS) {
showZstats = STATS_NONE;
}
return false;
} else {
log("Pass");
}
finishTurn(x, y);
return false;
}
Aggregations