Search in sources :

Example 1 with StaticGeneratedDungeonScreen

use of generator.StaticGeneratedDungeonScreen in project ultimate-java by pantinor.

the class GameScreen method loadNextMap.

public void loadNextMap(Maps m, int x, int y, int dngx, int dngy, int dngLevel, Direction orientation, boolean restoreSG) {
    log("Entering " + m.getLabel() + "!");
    BaseMap baseMap = m.getMap();
    if (baseMap.getType() == MapType.dungeon) {
        if (m != Maps.DELVE_SORROWS) {
            DungeonScreen sc = new DungeonScreen(this, context, m);
            if (restoreSG) {
                sc.restoreSaveGameLocation(dngx, dngy, dngLevel, orientation);
            }
            mainGame.setScreen(sc);
        } else {
            StaticGeneratedDungeonScreen sc = new StaticGeneratedDungeonScreen(this, context, m);
            if (restoreSG) {
                sc.restoreSaveGameLocation(dngx, dngy, dngLevel, orientation);
            }
            mainGame.setScreen(sc);
        }
    } else if (baseMap.getType() == MapType.shrine) {
        map = new UltimaTiledMapLoader(m, Ultima4.standardAtlas, baseMap.getWidth(), baseMap.getHeight(), tilePixelWidth, tilePixelHeight).load();
        context.setCurrentTiledMap(map);
        Virtue virtue = Virtue.get(baseMap.getId() - 25);
        ShrineScreen sc = new ShrineScreen(this, context.getParty(), virtue, map, Ultima4.standardAtlas, Ultima4.standardAtlas);
        mainGame.setScreen(sc);
    } else {
        context.setCurrentMap(baseMap);
        baseMap.removeJoinedPartyMemberFromPeopleList(context.getParty());
        map = new UltimaTiledMapLoader(m, Ultima4.standardAtlas, m.getMap().getWidth(), m.getMap().getHeight(), tilePixelWidth, tilePixelHeight).load();
        context.setCurrentTiledMap(map);
        if (renderer != null) {
            renderer.dispose();
        }
        renderer = new UltimaMapRenderer(context, Ultima4.standardAtlas, baseMap, map, 1f);
        mapBatch = renderer.getBatch();
        MapProperties prop = map.getProperties();
        mapPixelHeight = prop.get("height", Integer.class) * tilePixelHeight;
        baseMap.initObjects(this, Ultima4.standardAtlas, Ultima4.standardAtlas);
        renderer.getFOV().calculateFOV(baseMap.getShadownMap(), x, y, 17f);
        newMapPixelCoords = getMapPixelCoords(x, y);
    }
    if (Ultima4.playMusic) {
        if (Ultima4.music != null) {
            Ultima4.music.stop();
        }
        Sound snd = Sound.valueOf(baseMap.getMusic());
        Ultima4.music = Sounds.play(snd, Ultima4.musicVolume);
    }
}
Also used : UltimaTiledMapLoader(util.UltimaTiledMapLoader) UltimaMapRenderer(util.UltimaMapRenderer) MapProperties(com.badlogic.gdx.maps.MapProperties) StaticGeneratedDungeonScreen(generator.StaticGeneratedDungeonScreen) BaseMap(objects.BaseMap) StaticGeneratedDungeonScreen(generator.StaticGeneratedDungeonScreen)

Example 2 with StaticGeneratedDungeonScreen

use of generator.StaticGeneratedDungeonScreen 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

StaticGeneratedDungeonScreen (generator.StaticGeneratedDungeonScreen)2 InputMultiplexer (com.badlogic.gdx.InputMultiplexer)1 MapProperties (com.badlogic.gdx.maps.MapProperties)1 Window (com.badlogic.gdx.scenes.scene2d.ui.Window)1 BaseMap (objects.BaseMap)1 City (objects.City)1 Creature (objects.Creature)1 PartyMember (objects.Party.PartyMember)1 Person (objects.Person)1 Tile (objects.Tile)1 UltimaMapRenderer (util.UltimaMapRenderer)1 UltimaTiledMapLoader (util.UltimaTiledMapLoader)1 TinkerDialog (vendor.TinkerDialog)1