Esempio 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);
 }
Esempio 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();
 }
Esempio 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
 }