コード例 #1
0
 private void attackMoveSelected(int x, int y) {
   attackMoveClicked = false;
   GameSprite target = level.getSpriteAt(x, y);
   for (GameSprite sprite : selected) {
     if (target == null) sprite.goTo(x, y, true, shiftDown());
     else sprite.goTo(target, true, shiftDown());
   }
 }
コード例 #2
0
 private void rightMouseClick(int x, int y) {
   attackMoveClicked = false;
   GameSprite target = level.getSpriteAt(x, y);
   for (GameSprite sprite : selected) {
     if (sprite.onTeam(playerTeam)) {
       if (target == null) sprite.goTo(x, y, false, shiftDown());
       else sprite.goTo(target, false, shiftDown());
     }
   }
 }
コード例 #3
0
  private void handleInput() {
    if (input.clicked(0)) leftMouseClick(input.getX(), input.getY());
    else if (input.clicked(2)) rightMouseClick(input.getX(), input.getY());

    if (input.createdBox()) {
      ArrayList<GameSprite> boxedSprites = level.getSpritesAt(input.getDragBox());
      ArrayList<GameSprite> boxedFriendly = new ArrayList<GameSprite>();
      for (GameSprite sprite : boxedSprites) {
        if (sprite.onTeam(playerTeam)) boxedFriendly.add(sprite);
      }
      if (!boxedFriendly.isEmpty()) {
        selected = boxedFriendly;
      }
    }

    if (input.keyDown(KeyEvent.VK_A)) attackMoveClicked = true;
    if (input.keyDown(KeyEvent.VK_S)) stopSelected();

    if (input.keyDown(KeyEvent.VK_LEFT)) scrollLeft();
    if (input.keyDown(KeyEvent.VK_RIGHT)) scrollRight();
    if (input.keyDown(KeyEvent.VK_UP)) scrollUp();
    if (input.keyDown(KeyEvent.VK_DOWN)) scrollDown();
  }