public boolean updateState(Landscape scape) {
    // this method has an added on season change every 1/4 minute

    // first 1/4 minute:
    if ((System.currentTimeMillis() / 15000) % 2 == 0) {
      if ((this.y > scape.getHeight() / 2)
          && (this.x > scape.getWidth() / 2)) { // if this is in the southeast ish
        if (quantity < MAX_QUANTITY) {
          quantity += 2; // grow by 2
        }
      } else { // else grow by 1 each time
        if (quantity < MAX_QUANTITY) {
          quantity++;
        }
      }
    }

    // second 1/4 minute:
    else if ((System.currentTimeMillis() / 15000) % 2 != 0) {
      if ((this.y < (scape.getHeight() / 2))
          && (this.x < scape.getWidth() / 2)) { // if this is in the northwest ish
        if (quantity < MAX_QUANTITY) {
          quantity += 2; // grows by 2
        }
      } else { // else grow by 1 each time
        if (quantity < MAX_QUANTITY) {
          quantity++;
        }
      }
    }

    // System.out.print(this.quantity+",");
    return true; // it can be assumed that this always returns true since peas never die
  }
Beispiel #2
0
 public int[][] method298(boolean bool, int i) {
   if (bool != false) aBoolean767 = true;
   anInt755++;
   if (anInt752 != anInt749) {
     if ((anInt752 ^ 0xffffffff) == -2) {
       aBoolean767 = i != anInt753;
       anInt753 = i;
       return anIntArrayArrayArray756[0];
     }
     Class37_Sub14 class37_sub14 = aClass37_Sub14Array748[i];
     if (aBoolean767 = class37_sub14 == null) {
       if (anInt759 < anInt752) {
         class37_sub14 = new Class37_Sub14(i, anInt759);
         anInt759++;
       } else {
         Class37_Sub14 class37_sub14_0_ = (Class37_Sub14) aClass58_766.method1157(bool);
         class37_sub14 = new Class37_Sub14(i, class37_sub14_0_.anInt2128);
         aClass37_Sub14Array748[class37_sub14_0_.anInt2125] = null;
         class37_sub14_0_.method322(false);
       }
       aClass37_Sub14Array748[i] = class37_sub14;
     }
     aClass58_766.method1150(9282, class37_sub14);
     return anIntArrayArrayArray756[class37_sub14.anInt2128];
   }
   aBoolean767 = aClass37_Sub14Array748[i] == null;
   aClass37_Sub14Array748[i] = Class37_Sub5.aClass37_Sub14_1871;
   return anIntArrayArrayArray756[i];
 }
 public void run() {
   long tileFactor = 0;
   switch (landscape.getTile(currentX, currentY).getType()) {
     case FORREST:
       tileFactor = 10000;
       break;
     case PLAIN:
       tileFactor = 5000;
       break;
     case MOUNTAIN:
       tileFactor = 15000;
       break;
   }
   boolean alive = true;
   while (alive) {
     try {
       Thread.sleep((long) (Math.random() * 10000) + tileFactor);
     } catch (InterruptedException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
     alive = landscape.getTile(currentX, currentY).isInhabited();
     if (alive) {
       landscape.spawnHuman(currentX, currentY);
     }
   }
 }
Beispiel #4
0
	public void updateState(Landscape land) {
		Random r = new Random();
		if (selection == 1) {
			int index = r.nextInt(land.getAgent(2).size())
			land.getAgent(2).get(index).addtoQueue(this);
			time = time + 1;
		} else if (selection == 2) {
  public static void main(String[] args) {
    Landscape scape = new Landscape(50, 50);
    Random r = new Random();
    Peas a = new Peas(1.2236, 4.48545);
    Peas b = new Peas(5.7212, 4.48545);
    Peas c = new Peas(8.6454, 4.48545);
    scape.addResource(c);
    scape.addResource(b);
    scape.addResource(a);

    LandscapeDisplay disp = new LandscapeDisplay(scape, 10);
  }
Beispiel #6
0
  /**
   * The main function opens a 3D rendering window, constructs a simple 3D scene, and starts a timer
   * task to generate an animation.
   *
   * @throws IOException
   */
  public static void main(String[] args) throws IOException {

    sceneManager = new SimpleSceneManager();

    Landscape landscape = new Landscape(7, 50, 20, 10, 5);
    // Set up the vertex data and integrate
    VertexData vLandscape = landscape.getVertexData();
    sLandscape = new Shape(vLandscape);
    sceneManager.addShape(sLandscape);

    // adjust the camera
    camera = sceneManager.getCamera();

    Vector3f centerOfProjection = new Vector3f(0, 0, 40);
    Vector3f lookAtPoint = new Vector3f(0, 0, 0);
    Vector3f upVector = new Vector3f(0, 1, 0);
    camera.setCameraMatrix(centerOfProjection, lookAtPoint, upVector);

    // adjust the frustum
    Frustum frustum = sceneManager.getFrustum();

    float nearPlane = 1;
    float farPlane = 100;
    float aspectRatio = 1;
    float vFieldOfView = 60;
    frustum.setFrustum(nearPlane, farPlane, aspectRatio, vFieldOfView);

    // Make a render panel. The init function of the renderPanel
    // (see above) will be called back for initialization.
    renderPanel = new SimpleRenderPanel();

    // Make the main window of this application and add the renderer to it
    // JFrame
    jframe = new JFrame("simple");
    jframe.setSize(750, 750);
    jframe.setLocationRelativeTo(null); // center of screen
    jframe.getContentPane().add(renderPanel.getCanvas()); // put the canvas into a JFrame window

    // Add a mouse listener
    SimpleMouseListener mouse = new SimpleMouseListener();
    renderPanel.getCanvas().addMouseListener(mouse); // change proposed in forum
    renderPanel.getCanvas().addMouseMotionListener(mouse);
    renderPanel.getCanvas().addKeyListener(new MyKeyListener());

    jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    jframe.setVisible(true); // show window
  }
  public boolean updateState(Landscape scape) {

    // method should check to see if the hunter has entered its room and eat them if they have:
    if (this.current == WumpusHunt.hunter.getCurrentRoom() && this.slain != true) {

      WumpusHunt.hunter.setAlive(false);
      scape.advance();
      this.slain = false;
      this.show = true; // revealed.
    }

    return true;
  }
Beispiel #8
0
 public void method301(int i) {
   anInt757++;
   if (i != 2) anInt749 = -5;
   for (int i_9_ = 0; (i_9_ ^ 0xffffffff) > (anInt752 ^ 0xffffffff); i_9_++) {
     anIntArrayArrayArray756[i_9_][0] = null;
     anIntArrayArrayArray756[i_9_][1] = null;
     anIntArrayArrayArray756[i_9_][2] = null;
     anIntArrayArrayArray756[i_9_] = null;
   }
   anIntArrayArrayArray756 = null;
   aClass37_Sub14Array748 = null;
   aClass58_766.method1154(64);
   aClass58_766 = null;
 }