예제 #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);
 }
예제 #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);
 }
예제 #3
0
 public static SoundEffect medalAwarded() {
   return Game.allocateSound(instance.medalAwardedBuffer);
 }
예제 #4
0
 public static SoundEffect baseDestructionImminent() {
   return Game.allocateSound(instance.baseDestructionImminentBuffer);
 }
예제 #5
0
 public static void baseAttacked() {
   Game.allocateSound(instance.baseAttackedBuffer);
 }
예제 #6
0
 public static void factoryShutdown() {
   Game.allocateSound(instance.factoryShutdownBuffer);
 }
예제 #7
0
 public static void insufficientFunds() {
   Game.allocateSound(instance.insufficientFundsBuffer);
 }
예제 #8
0
 public static SoundEffect smartbomb() {
   return Game.allocateSound(instance.smartbombBuffer);
 }
예제 #9
0
 public static void pickup() {
   Game.allocateSound(instance.pickupBuffer);
 }
예제 #10
0
 public static void noAmmo() {
   Game.allocateSound(instance.noAmmoBuffer);
 }
예제 #11
0
 public static void reloaded() {
   Game.allocateSound(instance.reloadedBuffer);
 }
예제 #12
0
 public static void crystalSpawned(float x, float y) {
   Game.allocateSound(instance.crystalSpawnedBuffer, Worm.calcLoudGain(x, y), 1.0f, Game.class);
 }
예제 #13
0
 public static void blastMineReady(float x, float y) {
   Game.allocateSound(instance.blastMineReadyBuffer, Worm.calcGain(x, y), 1.0f, Game.class);
 }
예제 #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);
 }
예제 #15
0
 public static SoundEffect achievementUnlocked() {
   return Game.allocateSound(instance.achievementUnlockedBuffer);
 }
예제 #16
0
 public static void repair(float x, float y) {
   Game.allocateSound(instance.repairBuffer, Worm.calcGain(x, y), 1.0f, Game.class);
 }
예제 #17
0
 public static SoundEffect newRank() {
   return Game.allocateSound(instance.newRankBuffer);
 }
예제 #18
0
 public static void cantBuild() {
   Game.allocateSound(instance.cantBuildBuffer);
 }
예제 #19
0
 public static void build() {
   Game.allocateSound(instance.buildBuffer);
 }
예제 #20
0
파일: Entity.java 프로젝트: kmeaw/ultraworm
  /*
   * (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();
  }