Search in sources :

Example 16 with PartyMember

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

the class BaseMap method addToMask.

private int addToMask(Context context, Direction dir, int mask, Tile tile, int x, int y, Creature cr, int avatarX, int avatarY) {
    if (tile != null) {
        TileRule rule = tile.getRule();
        boolean canmove = false;
        if (rule != null) {
            if (cr != null) {
                if (cr.getSails() && rule.has(TileAttrib.sailable)) {
                    canmove = true;
                } else if (cr.getSails() && !rule.has(TileAttrib.unwalkable)) {
                    canmove = false;
                } else if (cr.getSwims() && rule.has(TileAttrib.swimmable)) {
                    canmove = true;
                } else if (cr.getSwims() && !rule.has(TileAttrib.unwalkable)) {
                    canmove = false;
                } else if (cr.getFlies() && !rule.has(TileAttrib.unflyable)) {
                    canmove = true;
                } else if (rule.has(TileAttrib.creatureunwalkable)) {
                    canmove = false;
                } else if (cr.getIncorporeal() || !rule.has(TileAttrib.unwalkable)) {
                    canmove = true;
                }
            } else {
                TransportContext tc = context.getTransportContext();
                if (tc == null || id != Maps.WORLD.getId() || tc == TransportContext.FOOT) {
                    if (!rule.has(TileAttrib.unwalkable) || rule == TileRule.ship || rule.has(TileAttrib.chest) || rule == TileRule.horse || rule == TileRule.balloon) {
                        canmove = true;
                    }
                } else if (tc == TransportContext.HORSE) {
                    if (!rule.has(TileAttrib.creatureunwalkable) && !rule.has(TileAttrib.unwalkable)) {
                        canmove = true;
                    } else {
                        canmove = false;
                    }
                } else if (tc == TransportContext.SHIP) {
                    if (rule.has(TileAttrib.sailable)) {
                        canmove = true;
                    } else {
                        canmove = false;
                    }
                } else if (tc == TransportContext.BALLOON) {
                    if (!rule.has(TileAttrib.unflyable)) {
                        canmove = true;
                    } else {
                        canmove = false;
                    }
                }
            }
        } else {
            canmove = false;
        }
        // NPCs cannot go thru the secret doors or walk where the avatar is
        if (cr != null) {
            if ((tile.getIndex() == 73 && !cr.getIncorporeal()) || (avatarX == x && avatarY == y && !cr.getCanMoveOntoAvatar())) {
                canmove = false;
            }
        }
        // see if another person is there
        if (city != null) {
            for (Person p : city.getPeople()) {
                if (p == null || p.isRemovedFromMap()) {
                    continue;
                }
                if (p.getX() == x && p.getY() == y) {
                    canmove = false;
                    break;
                }
            }
        }
        for (Creature cre : creatures) {
            if (cre.currentX == x && cre.currentY == y) {
                canmove = false;
                break;
            }
        }
        if (combatPlayers != null) {
            for (PartyMember p : combatPlayers) {
                if (p.combatCr == null || p.fled) {
                    continue;
                }
                if (p.combatCr.currentX == x && p.combatCr.currentY == y) {
                    canmove = false;
                    break;
                }
            }
        }
        if (rule == null || canmove || isDoorOpen(x, y)) {
            mask = Direction.addToMask(dir, mask);
        }
    } else {
        // so add this direction anyway so that monster flee operations work.
        if (cr != null && cr.getDamageStatus() == CreatureStatus.FLEEING) {
            mask = Direction.addToMask(dir, mask);
        }
    }
    return mask;
}
Also used : PartyMember(objects.Party.PartyMember)

Example 17 with PartyMember

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

the class LogDisplay method render.

public void render(Batch batch, Party party) {
    int food = party.getSaveGame().food / 100;
    font.setColor(food < 5 ? Color.RED : Color.WHITE);
    font.draw(batch, "Food  " + food, LOG_X + 8, 438);
    font.setColor(Color.WHITE);
    if (party.getContext().getTransportContext() == TransportContext.SHIP) {
        font.draw(batch, "Hull  " + party.getSaveGame().shiphull, LOG_X + 8 + 120, 438);
    } else {
        font.draw(batch, "Gold  " + party.getSaveGame().gold, LOG_X + 8 + 140, 438);
    }
    float y = Ultima4.SCREEN_HEIGHT - 48;
    for (int i = 0; i < party.getMembers().size(); i++) {
        PartyMember pm = party.getMember(i);
        String s = (i + 1) + " - " + pm.getPlayer().name;
        String d = pm.getPlayer().hp + "" + pm.getPlayer().status.getValue();
        font.setColor(i == party.getActivePlayer() ? new Color(.35f, .93f, 0.91f, 1) : Color.WHITE);
        if (pm.getPlayer().status == StatusType.POISONED) {
            font.setColor(Color.GREEN);
        }
        if (pm.getPlayer().status == StatusType.SLEEPING) {
            font.setColor(Color.YELLOW);
        }
        if (pm.getPlayer().status == StatusType.DEAD) {
            font.setColor(Color.GRAY);
        }
        font.draw(batch, s, LOG_X + 8, y);
        font.draw(batch, d, LOG_X + 8 + 110, y);
        y = y - 24;
    }
    font.setColor(Color.WHITE);
    y = 32;
    synchronized (logs) {
        ReverseListIterator iter = new ReverseListIterator(logs);
        while (iter.hasNext()) {
            String next = (String) iter.next();
            GlyphLayout layout = new GlyphLayout(font, next, Color.WHITE, LOG_AREA_WIDTH - 8, Align.left, true);
            y += layout.height + 10;
            if (y > LOG_AREA_TOP) {
                break;
            }
            font.draw(batch, layout, LOG_X + 8, y);
        }
    }
}
Also used : PartyMember(objects.Party.PartyMember) Color(com.badlogic.gdx.graphics.Color) GlyphLayout(com.badlogic.gdx.graphics.g2d.GlyphLayout) ReverseListIterator(org.apache.commons.collections.iterators.ReverseListIterator)

Example 18 with PartyMember

use of objects.Party.PartyMember 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 19 with PartyMember

use of objects.Party.PartyMember 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)

Example 20 with PartyMember

use of objects.Party.PartyMember 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;
}
Also used : Window(com.badlogic.gdx.scenes.scene2d.ui.Window) Creature(objects.Creature) PartyMember(objects.Party.PartyMember) Tile(objects.Tile) City(objects.City) StaticGeneratedDungeonScreen(generator.StaticGeneratedDungeonScreen) StaticGeneratedDungeonScreen(generator.StaticGeneratedDungeonScreen) InputMultiplexer(com.badlogic.gdx.InputMultiplexer) TinkerDialog(vendor.TinkerDialog) Person(objects.Person)

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