Exemplo n.º 1
0
  private void initTalk() {
    // TODO dodaæ celowanie!
    Player tmp = hg.ge.pl;

    for (Entity e : hg.ge.pl.getMap().entities) {
      if (e.getType().equals("Player")) continue;
      if (Utilities.distance(e.getX(), e.getY(), tmp.getX(), tmp.getY()) < 2) {
        if (e.isTalkable()) {
          Talk(e);
          break;
        }
      }
    }
  }
Exemplo n.º 2
0
  public void keyPressed(int key, char c) {

    if (gs.activePrompt != null) {
      gs.activePrompt.keyPressed(key, c);
      return;
    }

    if (key == ENTER_KEY) {

      Player tmp = hg.ge.pl;
      Map m = tmp.getMap();
      int x = tmp.getX();
      int y = tmp.getY();

      m.Enter(x, y, tmp);
    }

    if (key == SHOOT_KEY) {
      hg.targetctrl.initTargetting(new LineTargetter(hg));
    }
    if (key == SKILL_KEY && !hg.in.isKeyDown(Input.KEY_LSHIFT)) {
      gs.statechange = HellbentGame.SKILLSTATE;
      gs.moving = 0;
    }

    if (key == TALK_KEY) {
      initTalk();
    }

    if (key == PICKUP_KEY) {

      Player tmp = hg.ge.pl;
      Map m = tmp.getMap();
      Vector<Item> items = Utilities.getItemsAtCoord(m, tmp.getX(), tmp.getY());
      if (items.size() > 0) {
        tmp.setAction(new Pickup(tmp, items.get(0)));
        ((GameplayState) (gs)).inputACTION = 1;

      } else {
        tmp.addMessage("There is nothing here to pick up!");
      }
    }

    if (key == INVENTORY_KEY) {
      gs.statechange = HellbentGame.INVENTORYSTATE;
      gs.moving = 0;
    }

    if (key == SAVE_KEY) {
      if (hg.in.isKeyDown(Input.KEY_LSHIFT)) {
        try {
          gs.moving = 0;

          hg.svg.saveGame("saves/" + hg.ge.pl.getName() + ".svg");
          hg.ge.pl.addMessage("Game saved.");
        } catch (IOException e) {
          // TODO Auto-generated catch block
          System.out.println("DUPA");
        }
      }
    }

    if (key == N_1) {
      gs.moveflag = 1;
      gs.moving++;
    }
    if (key == N_2) {
      gs.moveflag = 2;
      gs.moving++;
    }
    if (key == N_3) {
      gs.moveflag = 3;
      gs.moving++;
    }
    if (key == N_4) {
      gs.moveflag = 4;
      gs.moving++;
    }
    if (key == N_5) {
      gs.moveflag = 5;
      gs.moving++;
    }
    if (key == N_6) {
      gs.moveflag = 6;
      gs.moving++;
    }
    if (key == N_7) {
      gs.moveflag = 7;
      gs.moving++;
    }
    if (key == N_8) {
      gs.moveflag = 8;
      gs.moving++;
    }
    if (key == N_9) {
      gs.moveflag = 9;
      gs.moving++;
    }

    {
    }
  }