示例#1
0
 /** Refreshes to store all the nearby lifeforms */
 public void findNearbyLife() {
   nearbyLife = new ArrayList<Lifeform>();
   final Point location = summative.getLocation(this);
   assert (location != null);
   for (int x = -sight; x <= sight; x++) {
     for (int y = -sight; y <= sight; y++) {
       if (Math.abs(x) + Math.abs(y) <= sight) {
         if (summative.lifeGet(new Point(location.x + x, location.y + y)) != null) {
           nearbyLife.add(summative.lifeGet(new Point(location.x + x, location.y + y)));
         } else if (summative.grassGet(new Point(location.x + x, location.y + y)) != null) {
           nearbyLife.add(summative.grassGet(new Point(location.x + x, location.y + y)));
         }
       }
     }
   }
 }