public void act() { Grid<Actor> gr = getGrid(); Location location = new Location(6, 0); Location rightLoc = new Location(6, 19); if (oldActor instanceof Cave33) { if (getLocation().equals(new Location(3, 15))) { removeSelfFromGrid(); oldActor.putSelfInGrid(gr, new Location(3, 15)); oldActor = gr.get(new Location(11, 10)); putSelfInGrid(gr, new Location(11, 10)); directionSuffix = "down"; } else { if (getLocation().equals(new Location(10, 10))) { removeSelfFromGrid(); oldActor.putSelfInGrid(gr, new Location(10, 10)); oldActor = gr.get(new Location(4, 15)); putSelfInGrid(gr, new Location(4, 15)); directionSuffix = "down"; } } } if (getLocation().equals(location)) { if ((world2 == true) && (switched == false)) { ((PokemonGrid) gr).fillWorld1(); oldActor = gr.get(new Location(6, 19)); putSelfInGrid(gr, new Location(6, 19)); world2 = false; switched = true; } } else { if (getLocation().equals(rightLoc)) { if ((world2 == false) && (switched == false)) { ((PokemonGrid) gr).fillWorld2(); oldActor = gr.get(new Location(6, 0)); putSelfInGrid(gr, new Location(6, 0)); world2 = true; switched = true; } } else switched = false; } }
public void move() { Grid<Actor> gr = getGrid(); if (gr == null) return; Location loc = getLocation(); Location next = loc.getAdjacentLocation(getDirection()); if (gr.isValid(next)) { nextActor = gr.get(next); moveTo(next); if (oldActor != null) oldActor.putSelfInGrid(gr, loc); oldActor = nextActor; } else removeSelfFromGrid(); }