Exemple #1
0
  int obtainSource(boolean isMusic) {
    if (noDevice) return 0;
    for (int i = 0, n = idleSources.size; i < n; i++) {
      int sourceId = idleSources.get(i);
      int state = alGetSourcei(sourceId, AL_SOURCE_STATE);
      if (state != AL_PLAYING && state != AL_PAUSED) {
        if (isMusic) {
          idleSources.removeIndex(i);
        } else {
          if (sourceToSoundId.containsKey(sourceId)) {
            long soundId = sourceToSoundId.get(sourceId);
            sourceToSoundId.remove(sourceId);
            soundIdToSource.remove(soundId);
          }

          long soundId = nextSoundId++;
          sourceToSoundId.put(sourceId, soundId);
          soundIdToSource.put(soundId, sourceId);
        }
        alSourceStop(sourceId);
        alSourcei(sourceId, AL_BUFFER, 0);
        AL10.alSourcef(sourceId, AL10.AL_GAIN, 1);
        AL10.alSourcef(sourceId, AL10.AL_PITCH, 1);
        AL10.alSource3f(sourceId, AL10.AL_POSITION, 0, 0, 1f);
        return sourceId;
      }
    }
    return -1;
  }
Exemple #2
0
  public void init(float posX, float posY, int type, float angle) {
    this.type = type;

    float width = widths.get(type, 0.1f);
    float height = heights.get(type, 0.1f);

    bounds.set(posX - width / 2F, posY, width, height);
    position.set(posX - width / 2F, posY);
    velocity.set(0, speeds.get(type, 4f));
    velocity.setAngle(90f + angle);
    this.damage = damages.get(type, 2);
    alive = true;
    upgradeable = upgradeables.get(type);
  }
Exemple #3
0
  @Override
  public void onGamepadUpdated(int index) {
    Gamepad gamepad = Gamepad.getGamepad(index);
    GwtController controller = controllerMap.get(index);
    if (gamepad != null && controller != null) {
      // Determine what changed
      JsArrayNumber axes = gamepad.getAxes();
      JsArrayNumber buttons = gamepad.getButtons();
      synchronized (eventQueue) {
        for (int i = 0, j = axes.length(); i < j; i++) {
          float oldAxis = controller.getAxis(i);
          float newAxis = (float) axes.get(i);
          if (oldAxis != newAxis) {
            GwtControllerEvent event = eventPool.obtain();
            event.type = GwtControllerEvent.AXIS;
            event.controller = controller;
            event.code = i;
            event.amount = newAxis;
            eventQueue.add(event);
          }
        }
        for (int i = 0, j = buttons.length(); i < j; i++) {
          float oldButton = controller.getButtonAmount(i);
          float newButton = (float) buttons.get(i);
          if (oldButton != newButton) {
            if ((oldButton < 0.5f && newButton < 0.5f)
                || (oldButton >= 0.5f && newButton >= 0.5f)) {
              controller.buttons.put(i, newButton);
              continue;
            }

            GwtControllerEvent event = eventPool.obtain();
            event.type =
                newButton >= 0.5f ? GwtControllerEvent.BUTTON_DOWN : GwtControllerEvent.BUTTON_UP;
            event.controller = controller;
            event.code = i;
            event.amount = newButton;
            eventQueue.add(event);
          }
        }
      }
    }
  }
  public void addSquad(final Entity squad, final int index) {
    final SquadCommandCard squadCard = new SquadCommandCard(squad, index, skin);
    Source source =
        new Source(squadCard) {

          @Override
          public Payload dragStart(InputEvent event, float x, float y, int pointer) {
            Payload payload = new Payload();

            // payload.setDragActor(new Label("Test", skin));
            SquadCommandCard card = new SquadCommandCard(squad, index, skin);
            payload.setDragActor(card);
            // payload.setDragActor(squadTable);
            return payload;
          }
        };

    dragAndDrop.addSource(source);

    cardSlots.get(index).setCard(squadCard);
  }
 /**
  * Gets the {@link TiledMapTile} that has the given id.
  *
  * @param id the id of the {@link TiledMapTile} to retrieve.
  * @return tile matching id, null if it doesn't exist
  */
 public TiledMapTile getTile(int id) {
   return tiles.get(id);
 }
Exemple #6
0
 public long getSoundId(int sourceId) {
   if (!sourceToSoundId.containsKey(sourceId)) return -1;
   return sourceToSoundId.get(sourceId);
 }
 public void updateFormationPattern(int index, FormationPatternType pattern) {
   SquadCommandCard card = (SquadCommandCard) cardSlots.get(index).getCard();
   card.updateFormationPattern(pattern);
 }
 public void removeSquad(Entity squad, int index) {
   SquadCommandCard card = (SquadCommandCard) cardSlots.get(index).getCard();
   card.setSquad(null);
   card.setSelected(false);
 }
 public Entity setSelected(int index, boolean selected) {
   SquadCommandCard card = (SquadCommandCard) cardSlots.get(index).getCard();
   card.setSelected(selected);
   return card.getSquad();
 }
 public void updateSquadTable(int index) {
   SquadCommandCard card = (SquadCommandCard) cardSlots.get(index).getCard();
 }