// enter a world map square // - if there is a portal to a special location then use it // - else create the appropraite outdoor area map // public static void exitWorldMap(Map m, int tx, int ty) { Thing h = Game.hero(); // record movement time Time.logTime(Movement.moveCost(m, h, tx, ty)); Thing p = m.getFlaggedObject(tx, ty, "IsPortal"); if (p != null) { Portal.travel(p, h); } else { // put hero into a local area map Map nm = WorldMap.createArea(m, tx, ty); // phantom Portal p = Portal.create(); Thing t = nm.getEntrance(); Portal.setDestination(p, nm, t.x, t.y); // could build a portal here so we can return to exact location map // Don't think we really want this though // addThing(p,tx,ty); Portal.travel(p, h); } }
// create Outdoor Area for specified square // can drop hero strainght into this private static Map createArea(Map m, int tx, int ty) { Map newmap = Outdoors.create(m.getTile(tx, ty)); // link back to worldmap Portal.setDestination(newmap.getEntrance(), m, tx, ty); return newmap; }
private void _buildDestinations() { for (String portalName : _ini.keys("destinations")) { String destName = _ini.get("destinations", portalName); Portal portal = _portals.get(portalName); Space space = _spaces.get(destName); if (space == null) { System.out.println("error,there's nowhere to go"); System.exit(1); } else { portal.setDestination(space); } } }