public void paint(Graphics g) { super.paint(g); if (Game.gameState == GameState.LOADING) { if (highlightedString == 0) { g.setColor(Color.RED); g.drawString("Start Game", 100, 80); g.setColor(Color.GREEN); g.drawString("Continue Game", 100, 100); g.drawString("Options", 100, 120); } else if (highlightedString == 1) { g.setColor(Color.GREEN); g.drawString("Start Game", 100, 80); g.setColor(Color.RED); g.drawString("Continue Game", 100, 100); g.setColor(Color.GREEN); g.drawString("Options", 100, 120); } else if (highlightedString == 2) { g.setColor(Color.GREEN); g.drawString("Start Game", 100, 80); g.setColor(Color.GREEN); g.drawString("Continue Game", 100, 100); g.setColor(Color.RED); g.drawString("Options", 100, 120); } } if (Game.gameState == GameState.PLAYING) { Graphics2D g2d = (Graphics2D) g; g2d.drawImage(player.getImage(), player.getX(), player.getY(), this); ArrayList ms = player.getMissiles(); g.drawString("Bug Count: " + Bug.bugArrayList.size(), 270, 30); g.drawString("Player Score: " + Mech.mechHashMap.get(0).getScore(), 270, 60); g.drawString("Player Lives: " + Mech.mechHashMap.get(0).getLives(), 270, 90); g.drawString("Weapon Selected: " + Mech.mechHashMap.get(0).weaponSelected, 270, 120); for (int i = 0; i < ms.size(); i++) { Missile m = (Missile) ms.get(i); g2d.drawImage(m.getImage(), m.getX(), m.getY(), this); } for (Bug bug : Bug.bugArrayList) { g2d.drawImage(bug.image, bug.x, bug.y, this); System.out.println("draw bug"); System.out.println("Bug Count;" + Bug.bugArrayList.size()); bug.move(); } } else if (Game.gameState == GameState.GAMEOVER) { g.drawString("GAME OVER!", 100, 100); } Toolkit.getDefaultToolkit().sync(); g.dispose(); }
public void actionPerformed(ActionEvent e) { if (Game.running) { if (player != null) { ArrayList ms = player.getMissiles(); for (int i = 0; i < ms.size(); i++) { Missile m = (Missile) ms.get(i); if (m.isVisible()) m.move(); else ms.remove(i); } player.move(); repaint(); } } else { tick.stop(); } }
public void Visit(Mech m) { // only the armor changes, so pass us off CurMech = m; ifMechLoadout l = CurMech.GetLoadout(); MechArmor a = CurMech.GetArmor(); // remove the old armor, if needed l.Remove(a); a.ResetPatchworkConfigs(); // set the armor type a.SetHD(); // place the armor a.Place(l); // check for and add any MechModifier if (a.GetMechModifier() != null) { CurMech.AddMechModifier(a.GetMechModifier()); } }
public void Visit(Mech m) throws Exception { CurMech = m; boolean CASEInstalled = false; boolean SChargerInstalled = false; Gyro g = CurMech.GetGyro(); ifMechLoadout l = CurMech.GetLoadout(); // see if we have CASE installed in the CT if (CurMech.HasCTCase()) { // remove it. We may not be able to replace it, but we'll try CASEInstalled = true; CurMech.RemoveCTCase(); } // see if we have a supercharger installed if (CurMech.GetLoadout().HasSupercharger()) { if (CurMech.GetLoadout().Find(CurMech.GetLoadout().GetSupercharger()) == LocationIndex.MECH_LOC_CT) { SChargerInstalled = true; try { CurMech.GetLoadout().SetSupercharger(false, -1, -1); } catch (Exception e) { // wow, a problem removing it. Log it for later. System.err.println(e.getMessage()); } } } // We have to remove the engine as well as mess with the gyro here m.GetEngine().Remove(l); // remove the gyro crits g.Remove(l); // change the gyro g.SetStandard(); // place the gyro if (!g.Place(l)) { throw new Exception("Standard Gyro cannot be allocated!"); } // now replace the engine criticals if (!m.GetEngine().Place(l)) { throw new Exception(m.GetEngine().LookupName() + " cannot be allocated!"); } // if we had CASE installed, try to replace it if (CASEInstalled) { // at this point, we don't care whether it happened or not since the // primary inhabitants of the CT are taken care of. try { CurMech.AddCTCase(); } catch (Exception e) { // unhandled at this time. write out a system error System.err.println(e.getMessage()); } } // try to reinstall the Supercharger if (SChargerInstalled) { try { CurMech.GetLoadout().SetSupercharger(true, LocationIndex.MECH_LOC_CT, -1); } catch (Exception e) { System.err.println(e.getMessage()); } } }