Search in sources :

Example 6 with PartyMember

use of objects.Party.PartyMember in project ultimate-java by pantinor.

the class CombatScreen method keyUp.

@Override
public boolean keyUp(int keycode) {
    PartyMember ap = party.getActivePartyMember();
    Creature active = ap.combatCr;
    try {
        if (keycode == Keys.SPACE || ap.isDisabled()) {
            log("Pass");
        } else if (keycode == Keys.UP) {
            if (preMove(active, Direction.NORTH)) {
                active.currentY--;
                active.currentPos = getMapPixelCoords(active.currentX, active.currentY);
                checkTileAffects(ap, active.currentX, active.currentY);
            }
        } else if (keycode == Keys.DOWN) {
            if (preMove(active, Direction.SOUTH)) {
                active.currentY++;
                active.currentPos = getMapPixelCoords(active.currentX, active.currentY);
                checkTileAffects(ap, active.currentX, active.currentY);
            }
        } else if (keycode == Keys.RIGHT) {
            if (preMove(active, Direction.EAST)) {
                active.currentX++;
                active.currentPos = getMapPixelCoords(active.currentX, active.currentY);
                checkTileAffects(ap, active.currentX, active.currentY);
            }
        } else if (keycode == Keys.LEFT) {
            if (preMove(active, Direction.WEST)) {
                active.currentX--;
                active.currentPos = getMapPixelCoords(active.currentX, active.currentY);
                checkTileAffects(ap, active.currentX, active.currentY);
            }
        } else if (keycode == Keys.A) {
            log("Attack: ");
            Gdx.input.setInputProcessor(sip);
            sip.setinitialKeyCode(keycode, combatMap, active.currentX, active.currentY);
            return false;
        } else if (keycode == Keys.C) {
            log("Cast Spell (A-Z): ");
            Gdx.input.setInputProcessor(new SpellInputProcessor(this, context, stage, active.currentX, active.currentY, ap));
            return false;
        } else if (keycode == Keys.U) {
            Tile tile = combatMap.getTile(active.currentX, active.currentY);
            if (// altar
            tile.getIndex() == 74 || (party.getSaveGame().items & Item.RAGE_GOD.getLoc()) > 0 || (party.getSaveGame().items & Item.MASK_MINAX.getLoc()) > 0) {
                // altar or rage of god
                log("Use which item: ");
                log("");
                Gdx.input.setInputProcessor(sip);
                sip.setinitialKeyCode(keycode, combatMap, active.currentX, active.currentY);
                return false;
            } else {
                log("Nothing to use!");
            }
        } else if (keycode == Keys.R) {
            Gdx.input.setInputProcessor(new ReadyWearInputAdapter(ap, true));
            return false;
        } else if (keycode == Keys.W) {
            Gdx.input.setInputProcessor(new ReadyWearInputAdapter(ap, false));
            return false;
        } else if (keycode == Keys.G) {
            getChest(party.getActivePlayer(), active.currentX, active.currentY);
            return false;
        } else if (keycode == Keys.Z) {
            showZstats = showZstats + 1;
            if (showZstats >= STATS_PLAYER1 && showZstats <= STATS_PLAYER8) {
                if (showZstats > party.getMembers().size()) {
                    showZstats = STATS_WEAPONS;
                }
            }
            if (showZstats > STATS_SPELLS) {
                showZstats = STATS_NONE;
            }
            return false;
        }
        finishPlayerTurn();
    } catch (PartyDeathException e) {
        this.returnScreen.partyDeath();
    }
    return false;
}
Also used : Creature(objects.Creature) PartyMember(objects.Party.PartyMember) Tile(objects.Tile) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) PartyDeathException(util.PartyDeathException)

Example 7 with PartyMember

use of objects.Party.PartyMember in project ultimate-java by pantinor.

the class CombatScreen method finishPlayerTurn.

public void finishPlayerTurn() {
    // remove dead creatures
    Iterator<Creature> iter = combatMap.getCreatures().iterator();
    while (iter.hasNext()) {
        Creature c = iter.next();
        if (c.getDamageStatus() == CreatureStatus.DEAD) {
            iter.remove();
        }
    }
    boolean roundIsDone = party.isRoundDone() || combatMap.getCreatures().isEmpty();
    PartyMember next = party.getAndSetNextActivePlayer();
    if (next != null) {
        cursor.setVisible(true);
        Creature nextActivePlayer = next.combatCr;
        cursor.setPos(nextActivePlayer.currentPos);
    } else {
        cursor.setVisible(false);
    }
    if (roundIsDone) {
        finishTurn(0, 0);
    }
}
Also used : Creature(objects.Creature) PartyMember(objects.Party.PartyMember)

Example 8 with PartyMember

use of objects.Party.PartyMember in project ultimate-java by pantinor.

the class CombatScreen method rangedAttackAt.

private boolean rangedAttackAt(AttackVector target, Creature attacker) throws PartyDeathException {
    PartyMember defender = null;
    for (PartyMember p : party.getMembers()) {
        if (p.combatCr.currentX == target.x && p.combatCr.currentY == target.y) {
            defender = p;
            break;
        }
    }
    if (defender == null) {
        return false;
    }
    AttackResult res = Utils.attackHit(attacker, defender);
    TileEffect effect = TileEffect.NONE;
    Color col = Color.WHITE;
    if (attacker.rangedAttackIs("poison_field")) {
        effect = TileEffect.POISON;
        col = Color.GREEN;
    } else if (attacker.rangedAttackIs("magic_flash")) {
        col = Color.CYAN;
    } else if (attacker.rangedAttackIs("fire_field")) {
        effect = TileEffect.FIRE;
        col = Color.RED;
    } else if (attacker.rangedAttackIs("sleep_field")) {
        effect = TileEffect.SLEEP;
        col = Color.PURPLE;
    } else if (attacker.rangedAttackIs("energy_field")) {
        effect = TileEffect.ELECTRICITY;
        col = Color.BLUE;
    } else if (attacker.rangedAttackIs("rocks")) {
        col = Color.BROWN;
    }
    final ProjectileActor p = new ProjectileActor(this, col, attacker.currentX, attacker.currentY, res);
    Vector3 v = getMapPixelCoords(defender.combatCr.currentX, defender.combatCr.currentY);
    p.addAction(sequence(moveTo(v.x, v.y, .3f), new Action() {

        public boolean act(float delta) {
            switch(p.res) {
                case HIT:
                    p.resultTexture = Ultima4.hitTile;
                    Sounds.play(Sound.NPC_MAGIC_STRUCK);
                    wounded = true;
                    break;
                case MISS:
                    p.resultTexture = Ultima4.missTile;
                    Sounds.play(Sound.EVADE);
                    break;
            }
            return true;
        }
    }, fadeOut(.2f), removeActor(p)));
    stage.addActor(p);
    switch(effect) {
        case ELECTRICITY:
            Sounds.play(Sound.LIGHTNING);
            log("Electrified!");
            Utils.dealDamage(attacker, defender);
            break;
        case FIRE:
        case LAVA:
            Sounds.play(Sound.FIREBALL);
            log("Fiery Hit!");
            Utils.dealDamage(attacker, defender);
            break;
        case NONE:
            break;
        case POISON:
        case POISONFIELD:
            if (rand.nextInt(2) == 0 && defender.getPlayer().status != StatusType.POISONED) {
                Sounds.play(Sound.POISON_EFFECT);
                log("Poisoned!");
                defender.getPlayer().status = StatusType.POISONED;
            }
            break;
        case SLEEP:
            if (context.getAura().getType() == AuraType.NEGATE) {
                log("Sleep attack negated.");
            } else {
                log("Sleep!");
                Sounds.play(Sound.SLEEP);
                if (rand.nextInt(2) == 0 && !defender.isDisabled()) {
                    defender.putToSleep();
                }
            }
            break;
        default:
            break;
    }
    if (res == AttackResult.HIT) {
        Utils.dealDamage(attacker, defender);
    }
    return res == AttackResult.HIT;
}
Also used : Action(com.badlogic.gdx.scenes.scene2d.Action) SequenceAction(com.badlogic.gdx.scenes.scene2d.actions.SequenceAction) ProjectileActor(objects.ProjectileActor) PartyMember(objects.Party.PartyMember) Color(com.badlogic.gdx.graphics.Color) Vector3(com.badlogic.gdx.math.Vector3)

Example 9 with PartyMember

use of objects.Party.PartyMember in project ultimate-java by pantinor.

the class CombatScreen method getChest.

// for dungeon room chests only
public void getChest(int index, int x, int y) {
    try {
        Tile tile = combatMap.getTile(x, y);
        if (tile != null && tile.getIndex() == 60) {
            PartyMember pm = context.getParty().getMember(index);
            context.getChestTrapHandler(pm);
            log(String.format("The Chest Holds: %d Gold", context.getParty().getChestGold()));
            replaceTile("dungeon_floor", x, y);
        } else {
            log("Not Here!");
        }
    } catch (PartyDeathException e) {
        this.returnScreen.partyDeath();
    }
}
Also used : PartyMember(objects.Party.PartyMember) Tile(objects.Tile) StaticTiledMapTile(com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile) TiledMapTile(com.badlogic.gdx.maps.tiled.TiledMapTile) PartyDeathException(util.PartyDeathException)

Example 10 with PartyMember

use of objects.Party.PartyMember in project ultimate-java by pantinor.

the class DungeonScreen method dungeonTouchOrb.

public void dungeonTouchOrb(int index) {
    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;
    switch(dngMap) {
        case DECEIT:
            stats = STATSBONUS_INT;
            break;
        case DESPISE:
            stats = STATSBONUS_DEX;
            break;
        case DESTARD:
            stats = STATSBONUS_STR;
            break;
        case WRONG:
            stats = STATSBONUS_INT | STATSBONUS_DEX;
            break;
        case COVETOUS:
            stats = STATSBONUS_DEX | STATSBONUS_STR;
            break;
        case SHAME:
            stats = STATSBONUS_INT | STATSBONUS_STR;
            break;
        case HYTHLOTH:
            stats = STATSBONUS_INT | STATSBONUS_DEX | STATSBONUS_STR;
            break;
        default:
            break;
    }
    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);
    try {
        pm.applyDamage(damage, false);
    } catch (PartyDeathException pde) {
        partyDeath();
        return;
    }
    // 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;
}
Also used : PartyMember(objects.Party.PartyMember) DungeonTileModelInstance(util.DungeonTileModelInstance) PartyDeathException(util.PartyDeathException)

Aggregations

PartyMember (objects.Party.PartyMember)24 PartyDeathException (util.PartyDeathException)9 Creature (objects.Creature)5 Tile (objects.Tile)5 TiledMapTile (com.badlogic.gdx.maps.tiled.TiledMapTile)4 StaticTiledMapTile (com.badlogic.gdx.maps.tiled.tiles.StaticTiledMapTile)4 DungeonTileModelInstance (util.DungeonTileModelInstance)4 SequenceAction (com.badlogic.gdx.scenes.scene2d.actions.SequenceAction)3 Color (com.badlogic.gdx.graphics.Color)2 Vector3 (com.badlogic.gdx.math.Vector3)2 Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 Person (objects.Person)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 GlyphLayout (com.badlogic.gdx.graphics.g2d.GlyphLayout)1 TiledMap (com.badlogic.gdx.maps.tiled.TiledMap)1 Action (com.badlogic.gdx.scenes.scene2d.Action)1 Stage (com.badlogic.gdx.scenes.scene2d.Stage)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 TextField (com.badlogic.gdx.scenes.scene2d.ui.TextField)1 TextFieldListener (com.badlogic.gdx.scenes.scene2d.ui.TextField.TextFieldListener)1