use of objects.Creature in project ultimate-java by pantinor.
the class DungeonScreen method enterRoom.
public void enterRoom(RoomLocater loc, Direction entryDir) {
if (loc == null) {
return;
}
Maps contextMap = Maps.get(dngMap.getId());
TiledMap tiledMap = new DungeonRoomTiledMapLoader(loc.room, entryDir, Ultima4.standardAtlas).load();
BaseMap baseMap = new BaseMap();
baseMap.setTiles(loc.room.tiles);
baseMap.setWidth(11);
baseMap.setHeight(11);
baseMap.setType(MapType.dungeon);
baseMap.setPortals(dngMap.getMap().getPortals(loc.x, loc.y, loc.z));
CombatScreen sc = new CombatScreen(this, context, contextMap, baseMap, tiledMap, null, Ultima4.creatures, Ultima4.standardAtlas);
if (loc.room.hasAltar) {
sc.log("The Altar Room of " + loc.room.altarRoomVirtue.toString());
}
MapLayer mLayer = tiledMap.getLayers().get("Monster Positions");
Iterator<MapObject> iter = mLayer.getObjects().iterator();
while (iter.hasNext()) {
MapObject obj = iter.next();
int tile = (Integer) obj.getProperties().get("tile");
int startX = (Integer) obj.getProperties().get("startX");
int startY = (Integer) obj.getProperties().get("startY");
if (tile == 0) {
continue;
}
Tile t = Ultima4.baseTileSet.getTileByIndex(tile);
Creature c = Ultima4.creatures.getInstance(CreatureType.get(t.getName()), Ultima4.standardAtlas);
c.currentX = startX;
c.currentY = startY;
c.currentPos = sc.getMapPixelCoords(startX, startY);
baseMap.addCreature(c);
}
mainGame.setScreen(sc);
}
use of objects.Creature in project ultimate-java by pantinor.
the class GameScreen method show.
@Override
public void show() {
Gdx.input.setInputProcessor(new InputMultiplexer(this, stage));
gameTimer.active = true;
// load save game if initializing
if (context == null) {
context = new Context();
SaveGame sg = new SaveGame();
try {
sg.read(PARTY_SAV_BASE_FILENAME);
} catch (Exception e) {
e.printStackTrace();
}
LordBritishConversation.saveGame = sg;
Party party = new Party(sg);
context.setParty(party);
context.loadJournalEntries();
// party.getMember(0).getPlayer().klass = ClassType.MAGE;
// party.getMember(0).getPlayer().xp = 899;
// party.getMember(0).getPlayer().hp = 999;
// party.getMember(0).getPlayer().hpMax = 999;
// party.getMember(0).getPlayer().intel = 99;
// party.getMember(0).getPlayer().mp = 999;
// sg.reagents = new int[]{90, 93, 94, 90, 90, 90, 90, 90};
// for (Spell sp : Spell.values()) {
// party.getSaveGame().mixtures[sp.ordinal()] = 99;
// }
// for (Virtue v : Virtue.values()) {
// sg.karma[v.ordinal()] = 0;
// }
//
// party.join(NpcDefaults.Geoffrey.name());
// party.join(NpcDefaults.Shamino.name());
// party.join(NpcDefaults.Katrina.name());
// party.join(NpcDefaults.Mariah.name());
// party.join(NpcDefaults.Dupre.name());
// party.join(NpcDefaults.Iolo.name());
// party.join(NpcDefaults.Julia.name());
// party.join(NpcDefaults.Jaana.name());
//
// sg.food = 30000;
// sg.gold = 999;
// sg.keys = 20;
// sg.gems = 15;
// sg.moves = 2800;
// sg.stones = 0xff;
// sg.runes = 0xff;
// sg.items = 0xff;
// sg.sextants = 1;
// party.getMember(0).getPlayer().status = StatusType.GOOD;
// party.getMember(0).getPlayer().weapon = WeaponType.MAGICAXE;
// party.getMember(0).getPlayer().armor = ArmorType.MYSTICROBE;
// for (int i = 1; i < 16; i++) {
// party.getSaveGame().weapons[i] = 2;
// }
// for (int i = 1; i < 8; i++) {
// party.getSaveGame().armor[i] = 2;
// }
// mainAvatar = shipAnim;
// sg.transport = 0x10;
// sg.items |= Constants.Item.IRON_ORE.getLoc();
// sg.items |= Constants.Item.RUNE_MOLD.getLoc();
// sg.items |= Constants.Item.BOOK.getLoc();
// load the surface world first
loadNextMap(Maps.WORLD, sg.x, sg.y);
// load the dungeon if save game starts in dungeon
if (Maps.get(sg.location) != Maps.WORLD) {
loadNextMap(Maps.get(sg.location), sg.x, sg.y, sg.x, sg.y, sg.dnglevel, Direction.getByValue(sg.orientation + 1), true);
// loadNextMap(Maps.ABYSS, 0, 0, 5, 5, 0, Direction.SOUTH, true);
// loadNextMap(Maps.DESTARD, 0, 0, 3, 5, 3, Direction.SOUTH, true);
// loadNextMap(Maps.DELVE_SORROWS, 0, 0, 3, 19, 1, Direction.EAST, true);
}
for (Virtue v : Virtue.values()) {
v.adjustProgress(sg.karma[v.ordinal()]);
}
party.setTransport(Ultima4.baseTileSet.getTileByIndex(sg.transport));
switch(sg.transport) {
case 31:
mainAvatar = avatarAnim;
break;
case 16:
case 17:
case 18:
case 19:
mainAvatar = shipAnim;
break;
case 20:
case 21:
mainAvatar = horseAnim;
break;
case 24:
mainAvatar = balloonAnim;
break;
}
if (sg.balloonfound == 1 && context.getTransportContext() != TransportContext.BALLOON) {
addBalloonActor(sg.balloonx, sg.balloony);
}
// load objects to surface stage
for (int i = 0; i < 24; i++) {
if (sg.objects_save_tileids[i] != 0 && sg.objects_save_x[i] != 0 && sg.objects_save_y[i] != 0) {
Tile t = Ultima4.baseTileSet.getTileByIndex(sg.objects_save_tileids[i] & 0xff);
Drawable d = new Drawable(Maps.WORLD.getMap(), sg.objects_save_x[i] & 0xff, sg.objects_save_y[i] & 0xff, t, Ultima4.standardAtlas);
Vector3 v = getMapPixelCoords(sg.objects_save_x[i] & 0xff, sg.objects_save_y[i] & 0xff);
d.setX(v.x);
d.setY(v.y);
mapObjectsStage.addActor(d);
}
}
// load monsters to surface map
for (int i = 0; i < 8; i++) {
if (sg.monster_save_tileids[i] != 0 && sg.monster_save_x[i] != 0 && sg.monster_save_y[i] != 0) {
Tile t = Ultima4.baseTileSet.getTileByIndex(sg.monster_save_tileids[i] & 0xff);
Creature cr = Ultima4.creatures.getInstance(CreatureType.get(t.getName()), Ultima4.standardAtlas);
cr.currentX = sg.monster_save_x[i] & 0xff;
cr.currentY = sg.monster_save_y[i] & 0xff;
cr.currentPos = getMapPixelCoords(cr.currentX, cr.currentY);
Maps.WORLD.getMap().addCreature(cr);
}
}
}
context.getParty().addObserver(this);
}
use of objects.Creature in project ultimate-java by pantinor.
the class GameScreen method board.
public void board(int x, int y) {
if (context.getTransportContext() != TransportContext.FOOT) {
log("Board: Can't!");
return;
}
Tile tile = null;
// check for ship
Drawable ship = null;
for (Actor a : mapObjectsStage.getActors()) {
if (a instanceof Drawable) {
Drawable d = (Drawable) a;
if (d.getTile().getName().equals("ship") && d.getCx() == x && d.getCy() == y) {
ship = d;
tile = d.getTile();
}
}
}
// check for horse
Creature horse = context.getCurrentMap().getCreatureAt(x, y);
if (horse != null && (horse.getTile() == CreatureType.horse)) {
tile = Ultima4.baseTileSet.getTileByName("horse");
}
// check for balloon
Drawable balloon = null;
for (Actor a : mapObjectsStage.getActors()) {
if (a instanceof Drawable) {
Drawable d = (Drawable) a;
if (d.getTile().getName().equals("balloon") && d.getCx() == x && d.getCy() == y) {
balloon = d;
tile = d.getTile();
}
}
}
if (tile == null) {
log("Board What?");
return;
}
if (tile.getRule().has(TileAttrib.ship)) {
log("Board Frigate!");
if (context.getLastShip() != ship) {
context.getParty().adjustShipHull(50);
}
context.setCurrentShip(ship);
ship.remove();
mainAvatar = shipAnim;
} else if (tile.getRule().has(TileAttrib.horse)) {
log("Mount Horse!");
context.getCurrentMap().removeCreature(horse);
mainAvatar = horseAnim;
} else if (tile.getRule().has(TileAttrib.balloon)) {
log("Board Balloon!");
balloon.remove();
mainAvatar = balloonAnim;
} else {
log("Board What?");
return;
}
context.getParty().setTransport(tile);
}
use of objects.Creature in project ultimate-java by pantinor.
the class GameScreen method checkBridgeTrolls.
private void checkBridgeTrolls(int x, int y) {
Tile bridge = context.getCurrentMap().getTile(x, y);
if (bridge == null || !bridge.getName().equals("bridge")) {
return;
}
if (rand.nextInt(8) != 0) {
return;
}
log("Bridge Trolls!");
Creature troll = Ultima4.creatures.getInstance(CreatureType.troll, Ultima4.standardAtlas);
troll.currentX = x;
troll.currentY = y;
troll.currentPos = getMapPixelCoords(x, y);
attackAt(bridge.getCombatMap(), troll);
}
use of objects.Creature in project ultimate-java by pantinor.
the class SecondaryInputProcessor method keyUp.
@Override
public boolean keyUp(int keycode) {
Direction dir = Direction.NORTH;
int x = currentX, y = currentY;
if (keycode == Keys.UP) {
dir = Direction.NORTH;
y = y - 1;
} else if (keycode == Keys.DOWN) {
dir = Direction.SOUTH;
y = y + 1;
} else if (keycode == Keys.LEFT) {
dir = Direction.WEST;
x = x - 1;
} else if (keycode == Keys.RIGHT) {
dir = Direction.EAST;
x = x + 1;
}
if (screen.scType == ScreenType.MAIN) {
Window dialog = null;
if (initialKeyCode == Keys.T) {
screen.logAppend(dir.toString());
Tile tile = bm.getTile(x, y);
if (tile.getRule() == TileRule.signs) {
// talking to vendor so get the vendor on other side of sign
switch(dir) {
case NORTH:
y = y - 1;
break;
case SOUTH:
y = y + 1;
break;
case EAST:
x = x + 1;
break;
case WEST:
x = x - 1;
break;
}
}
City city = bm.getCity();
if (city != null) {
Person p = city.getPersonAt(x, y);
if (p != null && (p.getConversation() != null || p.getRole() != null)) {
Gdx.input.setInputProcessor(stage);
if (p.getRole() != null && p.getRole().getInventoryType() != null && p.getRole().getInventoryType() == InventoryType.TINKER) {
dialog = new TinkerDialog(screen.context.getParty(), (GameScreen) screen, stage, Ultima4.skin).show();
} else {
dialog = new ConversationDialog(p, (GameScreen) screen, stage).show(stage);
}
} else {
screen.log("Funny, no response! ");
}
} else {
screen.log("Funny, no response! ");
}
} else if (initialKeyCode == Keys.O) {
screen.logAppend(dir.toString());
if (bm.openDoor(x, y)) {
screen.log("Opened!");
} else {
screen.log("Can't!");
}
} else if (initialKeyCode == Keys.J) {
screen.logAppend(dir.toString());
if (screen.context.getParty().getSaveGame().keys > 0 && bm.unlockDoor(x, y)) {
screen.log("Unlocked!");
screen.context.getParty().getSaveGame().keys--;
} else {
screen.log("Can't!");
}
} else if (initialKeyCode == Keys.R) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
Gdx.input.setInputProcessor(new ReadyWearInputAdapter(screen.context.getParty().getMember(keycode - 7 - 1), true));
return false;
}
} else if (initialKeyCode == Keys.W) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
Gdx.input.setInputProcessor(new ReadyWearInputAdapter(screen.context.getParty().getMember(keycode - 7 - 1), false));
return false;
}
} else if (initialKeyCode == Keys.G) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
GameScreen gameScreen = (GameScreen) screen;
gameScreen.getChest(keycode - 7 - 1, x, y);
}
} else if (initialKeyCode == Keys.A) {
screen.logAppend(dir.toString());
GameScreen gameScreen = (GameScreen) screen;
for (Creature c : bm.getCreatures()) {
if (c.currentX == x && c.currentY == y) {
Maps cm = screen.context.getCombatMap(c, bm, x, y, currentX, currentY);
gameScreen.attackAt(cm, c);
return false;
}
}
}
if (dialog == null) {
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
} else {
return false;
}
} else if (screen.scType == ScreenType.SHRINE) {
ShrineScreen shrineScreen = (ShrineScreen) screen;
if (keycode >= Keys.NUM_0 && keycode <= Keys.NUM_3) {
shrineScreen.meditate(keycode - 7);
} else {
screen.log("For how many Cycles (0-3)?");
return false;
}
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
return false;
} else if (screen.scType == ScreenType.COMBAT) {
CombatScreen combatScreen = (CombatScreen) screen;
if (initialKeyCode == Keys.A) {
screen.log("Attack > " + dir.toString());
PartyMember attacker = combatScreen.party.getActivePartyMember();
WeaponType wt = attacker.getPlayer().weapon;
if (rangeInputModeDirection != null) {
switch(rangeInputModeDirection) {
case NORTH:
y = y - 1;
break;
case SOUTH:
y = y + 1;
break;
case EAST:
x = x + 1;
break;
case WEST:
x = x - 1;
break;
}
if (keycode >= Keys.NUM_0 && keycode <= Keys.NUM_9) {
Sounds.play(Sound.PC_ATTACK);
Utils.animateAttack(stage, combatScreen, attacker, rangeInputModeDirection, x, y, keycode - 7);
} else {
screen.log("Invalid range!");
}
rangeInputModeDirection = null;
} else {
if (wt.getWeapon().getChoosedistance()) {
rangeInputModeDirection = dir;
screen.log("Throw Range:");
return false;
}
Sounds.play(Sound.PC_ATTACK);
int range = wt.getWeapon().getRange();
Utils.animateAttack(stage, combatScreen, attacker, dir, x, y, range);
}
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
return false;
} else if (initialKeyCode == Keys.U) {
if (keycode == Keys.ENTER) {
if (buffer.length() < 1) {
return false;
}
String useItem = buffer.toString();
screen.log(useItem);
if (useItem.startsWith("stone")) {
screen.log("There are holes for 4 stones.");
screen.log("What colors?");
screen.log("1: ");
buffer = new StringBuilder();
StoneColorsInputAdapter scia = new StoneColorsInputAdapter(combatScreen);
Gdx.input.setInputProcessor(scia);
} else if (useItem.startsWith("mask")) {
if (combatScreen.party.getSaveGame().moves - combatScreen.party.getSaveGame().lastmask >= 4) {
screen.log("Use Mask of Minax!");
PartyMember attacker = combatScreen.party.getActivePartyMember();
SpellUtil.useMaskOfMinax(combatScreen, attacker);
combatScreen.party.getSaveGame().lastmask = combatScreen.party.getSaveGame().moves;
} else {
screen.log("no effect!");
}
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
} else if (useItem.startsWith("rage")) {
if (combatScreen.party.getSaveGame().moves - combatScreen.party.getSaveGame().lastrage >= 6) {
screen.log("Use Rage of God!");
PartyMember attacker = combatScreen.party.getActivePartyMember();
SpellUtil.useRageOfGod(combatScreen, attacker);
combatScreen.party.getSaveGame().lastrage = combatScreen.party.getSaveGame().moves;
} else {
screen.log("no effect!");
}
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
} else {
screen.log("Not a usable item!");
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
combatScreen.finishPlayerTurn();
}
} else if (keycode == Keys.BACKSPACE) {
if (buffer.length() > 0) {
buffer.deleteCharAt(buffer.length() - 1);
screen.logDeleteLastChar();
}
} else if (keycode >= 29 && keycode <= 54) {
buffer.append(Keys.toString(keycode).toLowerCase());
screen.logAppend(Keys.toString(keycode).toLowerCase());
}
return false;
}
} else if (screen.scType == ScreenType.DUNGEON) {
DungeonScreen dngScreen = (DungeonScreen) screen;
if (initialKeyCode == Keys.S) {
switch(dngTile) {
case FOUNTAIN_PLAIN:
case FOUNTAIN_HEAL:
case FOUNTAIN_ACID:
case FOUNTAIN_CURE:
case FOUNTAIN_POISON:
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
dngScreen.dungeonDrinkFountain(dngTile, keycode - 7 - 1);
}
break;
case ORB:
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
dngScreen.dungeonTouchOrb(keycode - 7 - 1);
}
break;
default:
break;
}
} else if (initialKeyCode == Keys.G) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
dngScreen.getChest(keycode - 7 - 1, currentX, currentY);
}
} else if (initialKeyCode == Keys.R) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
Gdx.input.setInputProcessor(new ReadyWearInputAdapter(screen.context.getParty().getMember(keycode - 7 - 1), true));
return false;
}
} else if (initialKeyCode == Keys.W) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
Gdx.input.setInputProcessor(new ReadyWearInputAdapter(screen.context.getParty().getMember(keycode - 7 - 1), false));
return false;
}
}
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
} else if (screen.scType == ScreenType.TMXDUNGEON) {
StaticGeneratedDungeonScreen dngScreen = (StaticGeneratedDungeonScreen) screen;
if (initialKeyCode == Keys.S) {
switch(dngTile) {
case FOUNTAIN_PLAIN:
case FOUNTAIN_HEAL:
case FOUNTAIN_ACID:
case FOUNTAIN_CURE:
case FOUNTAIN_POISON:
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
dngScreen.dungeonDrinkFountain(dngTile, keycode - 7 - 1);
}
break;
case ORB:
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
dngScreen.dungeonTouchOrb(keycode - 7 - 1);
}
break;
default:
break;
}
} else if (initialKeyCode == Keys.G) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
dngScreen.getChest(keycode - 7 - 1, currentX, currentY);
}
} else if (initialKeyCode == Keys.R) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
Gdx.input.setInputProcessor(new ReadyWearInputAdapter(screen.context.getParty().getMember(keycode - 7 - 1), true));
return false;
}
} else if (initialKeyCode == Keys.W) {
if (keycode >= Keys.NUM_1 && keycode <= Keys.NUM_8) {
Gdx.input.setInputProcessor(new ReadyWearInputAdapter(screen.context.getParty().getMember(keycode - 7 - 1), false));
return false;
}
}
Gdx.input.setInputProcessor(new InputMultiplexer(screen, stage));
}
screen.finishTurn(currentX, currentY);
return false;
}
Aggregations