Пример #1
0
 public final void addShields(int amount) {
   shields += amount;
   if (shields > 255) shields = 255;
   else if (shields > 50) {
     if (autoPilot.getStatus() == AutoPilot.SystemStatus.DAMAGED) {
       autoPilot.setStatus(AutoPilot.SystemStatus.OFF);
     }
   }
 }
Пример #2
0
 public final void damage(int amount) {
   shields -= amount;
   if (shields < 0) shields = 0;
   wasHit = true;
   if (shields < 50) {
     autoPilot.setStatus(AutoPilot.SystemStatus.DAMAGED);
   }
   ViewFrame.getInstance().setHealth(shields);
 }
Пример #3
0
  public void keyPressed(KeyEvent e) {
    int keyCode = e.getKeyCode();

    if (keyCode == KeyEvent.VK_P) {
      ViewFrame.getInstance().pause();
      return;
    } else if (keyCode == KeyEvent.VK_A) {

      SystemStatus status = autoPilot.getStatus();
      switch (status) {
        case ON:
          autoPilot.setStatus(AutoPilot.SystemStatus.OFF);
          boosting = firing = false;
          rotation = Rotation.NONE;
          break;
        case OFF:
          autoPilot.setStatus(AutoPilot.SystemStatus.ON);
          break;
        default:
          return;
      }
      return;
    }

    if (autoPilot.getStatus() == AutoPilot.SystemStatus.ON) {
      return;
    }

    switch (keyCode) {
      case KeyEvent.VK_UP:
        {
          if (!boosting) {
            setBoosting(true);
          }
          break;
        }
      case KeyEvent.VK_DOWN:
        {
          if (!breaking) {
            setBreaking(true);
          }
          break;
        }
      case KeyEvent.VK_LEFT:
        {
          setRotation(Player.Rotation.LEFT);
          break;
        }
      case KeyEvent.VK_RIGHT:
        {
          setRotation(Player.Rotation.RIGHT);
          break;
        }
      case KeyEvent.VK_D:
        {
          cycleTarget(true);
          break;
        }
      case KeyEvent.VK_Q:
        {
          cycleWeapon(-1);
          break;
        }
      case KeyEvent.VK_E:
        {
          cycleWeapon(1);
          break;
        }
      case KeyEvent.VK_SPACE:
        firing = true;
        break;
      case KeyEvent.VK_R:
        reload();
        break;
    }
  }