Exemplo n.º 1
0
 public static void buildingDamaged(float x, float y, float gain) {
   int bash = Util.random(0, NUM_BASHES - 1);
   float pitch = (float) Math.random() / 20.0f;
   Game.allocateSound(
       instance.bashDistantBuffer[bash], Worm.calcGain(x, y) * gain, 1.0f - pitch, Game.class);
   Game.allocateSound(
       instance.bashBuffer[bash], Worm.calcGain(x, y) * gain, 1.0f - pitch, Game.class);
 }
Exemplo n.º 2
0
 public static void buildingDestroyed(float x, float y, float gain) {
   int bash = Util.random(0, NUM_BUILDING_DESTROYED - 1);
   Game.allocateSound(
       instance.buildingDestroyedDistantBuffer[bash],
       Worm.calcGain(x, y) * gain,
       1.0f,
       Game.class);
   Game.allocateSound(
       instance.buildingDestroyedBuffer[bash], Worm.calcGain(x, y) * gain, 1.0f, Game.class);
 }
Exemplo n.º 3
0
 public static SoundEffect medalAwarded() {
   return Game.allocateSound(instance.medalAwardedBuffer);
 }
Exemplo n.º 4
0
 public static SoundEffect baseDestructionImminent() {
   return Game.allocateSound(instance.baseDestructionImminentBuffer);
 }
Exemplo n.º 5
0
 public static void baseAttacked() {
   Game.allocateSound(instance.baseAttackedBuffer);
 }
Exemplo n.º 6
0
 public static void factoryShutdown() {
   Game.allocateSound(instance.factoryShutdownBuffer);
 }
Exemplo n.º 7
0
 public static void insufficientFunds() {
   Game.allocateSound(instance.insufficientFundsBuffer);
 }
Exemplo n.º 8
0
 public static SoundEffect smartbomb() {
   return Game.allocateSound(instance.smartbombBuffer);
 }
Exemplo n.º 9
0
 public static void pickup() {
   Game.allocateSound(instance.pickupBuffer);
 }
Exemplo n.º 10
0
 public static void noAmmo() {
   Game.allocateSound(instance.noAmmoBuffer);
 }
Exemplo n.º 11
0
 public static void reloaded() {
   Game.allocateSound(instance.reloadedBuffer);
 }
Exemplo n.º 12
0
 public static void crystalSpawned(float x, float y) {
   Game.allocateSound(instance.crystalSpawnedBuffer, Worm.calcLoudGain(x, y), 1.0f, Game.class);
 }
Exemplo n.º 13
0
 public static void blastMineReady(float x, float y) {
   Game.allocateSound(instance.blastMineReadyBuffer, Worm.calcGain(x, y), 1.0f, Game.class);
 }
Exemplo n.º 14
0
 public static void ricochet(float x, float y, float gain) {
   int ric = Util.random(0, NUM_RICOCHETS - 1);
   Game.allocateSound(instance.ricochetBuffer[ric], Worm.calcGain(x, y) * gain, 1.0f, Game.class);
 }
Exemplo n.º 15
0
 public static SoundEffect achievementUnlocked() {
   return Game.allocateSound(instance.achievementUnlockedBuffer);
 }
Exemplo n.º 16
0
 public static void repair(float x, float y) {
   Game.allocateSound(instance.repairBuffer, Worm.calcGain(x, y), 1.0f, Game.class);
 }
Exemplo n.º 17
0
 public static SoundEffect newRank() {
   return Game.allocateSound(instance.newRankBuffer);
 }
Exemplo n.º 18
0
 public static void cantBuild() {
   Game.allocateSound(instance.cantBuildBuffer);
 }
Exemplo n.º 19
0
 public static void build() {
   Game.allocateSound(instance.buildBuffer);
 }
Exemplo n.º 20
0
  /*
   * (non-Javadoc)
   * @see net.puppygames.applet.Tickable#update()
   */
  @Override
  public final void update() {
    calculateScreenPosition();

    if (sprite != null) {

      // Firstly, if we're significantly offscreen, hide all the sprites.
      if (getScreenX() < -48.0f
          || getScreenX() >= Game.getWidth() + 48
          || getScreenY() < -48.0f - getZ()
          || getScreenY() >= Game.getHeight() + 48 + getZ()) {
        for (Sprite element : sprite) {
          element.setVisible(false);
        }
        doUpdate();
        return;
      } else {
        for (Sprite element : sprite) {
          element.setVisible(visible);
        }
      }

      boolean searchForChildOffsets = false;

      for (Sprite element : sprite) {

        element.setLocation(screenX, screenY, 0);
        if (element.getLayer() > Layers.SHADOW) {
          element.setFlash(flash);
        }

        // shall we bother checking anims for childOffset stuff?
        if (element.isDoChildOffset()) {
          searchForChildOffsets = true;
        }
      }

      if (searchForChildOffsets) {

        float xOffset = 0;
        float yOffset = 0;
        yOffsetTotal = 0;
        xOffsetTotal = 0;

        for (int i = 0; i < sprite.length; i++) {

          boolean doOffset = false;

          // check for offset
          if (sprite[i].getChildXOffset() != 0) {

            xOffset = sprite[i].getChildXOffset();
            xOffset *= FPMath.floatValue(sprite[0].getXScale());
            if (isMirrored() && xOffset != 0) {

              // chaz hack! - if we've got any <offset anim commands they'd need to be mirrored too
              // so for now will disable mirroring of childOffset if <offset x=""/> present
              if (sprite[i].getOffset(null).x == 0) {
                xOffset = -xOffset;
              }
            }

            xOffsetTotal += xOffset;
            doOffset = true;
          }
          if (sprite[i].getChildYOffset() != 0) {

            yOffset = sprite[i].getChildYOffset();
            yOffset *= FPMath.floatValue(sprite[0].getYScale());
            yOffsetTotal += yOffset;
            doOffset = true;
          }

          // if we've found an offset apply this to any sprites after where we found the offset

          if (doOffset) {
            for (int j = i + 1; j < sprite.length; j++) {
              if (sprite[j].isDoChildOffset()) {
                sprite[j].setLocation(screenX + xOffsetTotal, screenY + yOffsetTotal, 0);
                sprite[j].setYSortOffset(
                    -yOffsetTotal
                        - j); // the '-j' is chaz hack! budge layers YSortOffset a tad to force
                // render ok
              }
            }
          }
        }
      }

      LayersFeature currentAppearance = getCurrentAppearance();
      float cx = getMapX() + getCollisionX();
      float cy = getMapY() + getCollisionY();
      if (currentAppearance != null
          && (GameScreen.isDiddlerOpen()
              || hackyTick > 0
              || cx != oldX
              || cy != oldY
              || currentAppearance != oldAppearance)) {
        currentAppearance.updateColors(sprite, cx, cy);
        if (hackyTick > 0) {
          hackyTick--;
        }
      }
      oldX = cx;
      oldY = cy;
      oldAppearance = currentAppearance;
    }

    doUpdate();
  }