private void handleBuildingCreation() { // handle building creation if (JCageConfigurator.currentSelectedBuilding != null && um.getBuildingToBuild() == null) { um.setBuildingToBuild( new BaseBuilding( en, gameProxy.getSaveName(), JCageConfigurator.currentSelectedBuilding, MainMid.getClientConfigurator().user)); um.getBuildingToBuild().setEnvironment(en); } }
public void run() { long k = 0; long paintTimer = 0; boolean setTime = true; boolean setTimePaint = true; finished = false; while (exec) { try { timer++; if (timer >= 20000) { timer = 0; } // if ((timer) % ucTimer == 0) { // boolean created = false; // int ir = Math.abs(Ground.rand.nextInt()) % 2 + 1; // for (int i = 0; i < ir; i++) { // created = created || handleInhabitantUnitCreation(timer); // } // if (!created) { // System.out.println("No units created"); // timer = ucTimer - 100; // } // } handleBuildingCreation(); handleUnitCreation(); um.moveAndFireUnits(timer); repaint(); setTime = true; // } Thread.sleep(refreshPeriod); } catch (InterruptedException ex1) { ex1.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } catch (Exception ex2) { ex2.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } } finished = true; }
protected void keyPressed(int keyCode) { switch (getGameAction(keyCode)) { case Canvas.UP: cm.moveUp(); repaint(); break; case Canvas.DOWN: cm.moveDown(); repaint(); break; case Canvas.LEFT: cm.moveLeft(); repaint(); break; case Canvas.RIGHT: cm.moveRight(); repaint(); break; case Canvas.FIRE: cm.clicked(this); repaint(); break; default: switch (keyCode) { case Canvas.KEY_NUM1: FormBuilding f1 = new FormBuilding("bil", this, true); MainMid.getClientConfigurator().display(f1); break; case Canvas.KEY_NUM2: cm.moveScreenUp(); repaint(); break; case Canvas.KEY_NUM3: cm.cancel(); break; case Canvas.KEY_NUM4: cm.moveScreenLeft(); repaint(); break; case Canvas.KEY_NUM5: um.getLastSelectedUnit().fire(); break; case Canvas.KEY_NUM6: cm.moveScreenRight(); repaint(); break; case Canvas.KEY_NUM7: FormResources f = new FormResources("res", this); MainMid.getClientConfigurator().display(f); break; case Canvas.KEY_NUM8: cm.moveScreenDown(); repaint(); break; case Canvas.KEY_NUM9: cm.delete(); break; case Canvas.KEY_NUM0: FormQuickLinks f2 = new FormQuickLinks("", this); MainMid.getClientConfigurator().display(f2); break; } } }