Search in sources :

Example 6 with PartyDeathException

use of util.PartyDeathException in project ultimate-java by pantinor.

the class StaticGeneratedDungeonScreen method getChest.

public void getChest(int index, int x, int y) {
    try {
        DungeonTileModelInstance chest = null;
        for (DungeonTileModelInstance dmi : modelInstances) {
            if (dmi.getTile() == DungeonTile.CHEST) {
                if (dmi.x == x && dmi.y == y && dmi.getLevel() == currentLevel) {
                    chest = dmi;
                    break;
                }
            }
        }
        if (chest != null) {
            PartyMember pm = context.getParty().getMember(index);
            context.getChestTrapHandler(pm);
            log(String.format("The Chest Holds: %d Gold", context.getParty().getChestGold()));
            // remove chest model instance
            modelInstances.remove(chest);
            dungeonTiles[currentLevel][x][y] = DungeonTile.NOTHING;
        } else {
            log("Not Here!");
        }
    } catch (PartyDeathException e) {
        partyDeath();
    }
}
Also used : DungeonTileModelInstance(util.DungeonTileModelInstance) PartyMember(objects.Party.PartyMember) PartyDeathException(util.PartyDeathException)

Example 7 with PartyDeathException

use of util.PartyDeathException in project ultimate-java by pantinor.

the class StaticGeneratedDungeonScreen method dungeonTouchOrb.

public void dungeonTouchOrb(int index) {
    try {
        if (index >= context.getParty().getMembers().size()) {
            return;
        }
        PartyMember pm = context.getParty().getMember(index);
        int x = (Math.round(currentPos.x) - 1);
        int y = (Math.round(currentPos.z) - 1);
        int stats = 0;
        int damage = 0;
        if (dngMap == Maps.DELVE_SORROWS) {
            if (currentLevel == 1) {
                stats = STATSBONUS_INT | STATSBONUS_DEX;
            } else {
                stats = STATSBONUS_INT | STATSBONUS_DEX | STATSBONUS_STR;
            }
        } else {
            stats = STATSBONUS_STR;
        }
        if ((stats & STATSBONUS_STR) > 0) {
            log("Strength + 5");
            int n = Utils.adjustValueMax(pm.getPlayer().str, 5, 50);
            pm.getPlayer().str = n;
            damage += 200;
        }
        if ((stats & STATSBONUS_DEX) > 0) {
            log("Dexterity + 5");
            int n = Utils.adjustValueMax(pm.getPlayer().dex, 5, 50);
            pm.getPlayer().dex = n;
            damage += 200;
        }
        if ((stats & STATSBONUS_INT) > 0) {
            log("Intelligence + 5");
            int n = Utils.adjustValueMax(pm.getPlayer().intel, 5, 50);
            pm.getPlayer().intel = n;
            damage += 200;
        }
        Sounds.play(Sound.LIGHTNING);
        pm.applyDamage(damage, false);
        // remove orb model instance
        DungeonTileModelInstance orb = null;
        for (DungeonTileModelInstance dmi : modelInstances) {
            if (dmi.getTile() == DungeonTile.ORB) {
                if (dmi.x == x && dmi.y == y && dmi.getLevel() == currentLevel) {
                    orb = dmi;
                    break;
                }
            }
        }
        modelInstances.remove(orb);
        dungeonTiles[currentLevel][x][y] = DungeonTile.NOTHING;
    } catch (PartyDeathException pde) {
        partyDeath();
    }
}
Also used : PartyMember(objects.Party.PartyMember) DungeonTileModelInstance(util.DungeonTileModelInstance) PartyDeathException(util.PartyDeathException)

Example 8 with PartyDeathException

use of util.PartyDeathException in project ultimate-java by pantinor.

the class DungeonScreen method getChest.

public void getChest(int index, int x, int y) {
    try {
        DungeonTileModelInstance chest = null;
        for (DungeonTileModelInstance dmi : modelInstances) {
            if (dmi.getTile() == DungeonTile.CHEST) {
                if (dmi.x == x && dmi.y == y && dmi.getLevel() == currentLevel) {
                    chest = dmi;
                    break;
                }
            }
        }
        if (chest != null) {
            PartyMember pm = context.getParty().getMember(index);
            context.getChestTrapHandler(pm);
            log(String.format("The Chest Holds: %d Gold", context.getParty().getChestGold()));
            // remove chest model instance
            modelInstances.remove(chest);
            dungeonTiles[currentLevel][x][y] = DungeonTile.NOTHING;
        } else {
            log("Not Here!");
        }
    } catch (PartyDeathException e) {
        partyDeath();
    }
}
Also used : DungeonTileModelInstance(util.DungeonTileModelInstance) PartyMember(objects.Party.PartyMember) PartyDeathException(util.PartyDeathException)

Example 9 with PartyDeathException

use of util.PartyDeathException 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));
            }
        }
    }
}
Also used : DungeonTileModelInstance(util.DungeonTileModelInstance) ModelInstance(com.badlogic.gdx.graphics.g3d.ModelInstance) DungeonTileModelInstance(util.DungeonTileModelInstance) Portal(objects.Portal) Vector3(com.badlogic.gdx.math.Vector3) PartyDeathException(util.PartyDeathException)

Example 10 with PartyDeathException

use of util.PartyDeathException in project ultimate-java by pantinor.

the class DungeonScreen method dungeonDrinkFountain.

public void dungeonDrinkFountain(DungeonTile type, int index) {
    try {
        if (index >= context.getParty().getMembers().size()) {
            return;
        }
        PartyMember pm = context.getParty().getMember(index);
        switch(type) {
            case FOUNTAIN_PLAIN:
                log("Hmmm--No Effect!");
                break;
            case FOUNTAIN_HEAL:
                if (pm.heal(HealType.FULLHEAL)) {
                    Sounds.play(Sound.HEALING);
                    log("Ahh-Refreshing!");
                } else {
                    log("Hmmm--No Effect!");
                }
                break;
            case FOUNTAIN_ACID:
                pm.applyDamage(100, false);
                Sounds.play(Sound.DAMAGE_EFFECT);
                log("Bleck--Nasty!");
                break;
            case FOUNTAIN_CURE:
                if (pm.heal(HealType.CURE)) {
                    Sounds.play(Sound.HEALING);
                    log("Hmmm--Delicious!");
                } else {
                    log("Hmmm--No Effect!");
                }
                break;
            case FOUNTAIN_POISON:
                if (pm.getPlayer().status != StatusType.POISONED) {
                    Sounds.play(Sound.DAMAGE_EFFECT);
                    pm.applyEffect(TileEffect.POISON);
                    pm.applyDamage(100, false);
                    log("Argh-Choke-Gasp!");
                } else {
                    log("Hmm--No Effect!");
                }
                break;
        }
    } catch (PartyDeathException pde) {
        partyDeath();
    }
}
Also used : PartyMember(objects.Party.PartyMember) PartyDeathException(util.PartyDeathException)

Aggregations

PartyDeathException (util.PartyDeathException)12 PartyMember (objects.Party.PartyMember)9 DungeonTileModelInstance (util.DungeonTileModelInstance)5 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)3 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)3 Tile (objects.Tile)3 Vector3 (com.badlogic.gdx.math.Vector3)2 Creature (objects.Creature)2 ModelInstance (com.badlogic.gdx.graphics.g3d.ModelInstance)1 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)1 Drawable (objects.Drawable)1 Portal (objects.Portal)1 MixtureScreen (ultima.MixtureScreen)1 SpellInputProcessor (ultima.SpellInputProcessor)1