Exemplo n.º 1
0
 public boolean canMove() {
   Grid<Actor> gr = getGrid();
   if (gr == null) return false;
   Location loc = getLocation();
   Location next = loc.getAdjacentLocation(getDirection()).getAdjacentLocation(getDirection());
   if (!gr.isValid(next)) return false;
   Actor neighbor = gr.get(next);
   return (neighbor == null) || (neighbor instanceof Flower);
 }
Exemplo n.º 2
0
 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();
 }
Exemplo n.º 3
0
 public boolean canMove() {
   Grid<Actor> gr = getGrid();
   if (gr == null) return false;
   Location loc = getLocation();
   Location next = loc.getAdjacentLocation(getDirection());
   if (!gr.isValid(next)) return false;
   Actor neighbor = gr.get(next);
   return (neighbor == null)
       || (neighbor instanceof TallGrass)
       || (neighbor instanceof Green)
       || (neighbor instanceof Path)
       || (neighbor instanceof Cave43)
       || (neighbor instanceof Cave33);
   // not ok to move onto water or rocks
 }
Exemplo n.º 4
0
  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;
    }
  }
Exemplo n.º 5
0
 public void getOldActor(Grid gr, Location loc) {
   oldActor = (Actor) (gr.get(new Location(6, 10)));
 }