Exemplo n.º 1
0
  // to change the current main scene
  public void setCurrentScene(Scene scene) {
    Log.i("GAME", "Scene : " + scene.getClass());

    if (mSceneType == SceneType.GAME) {
      mHUD.setVisible(true);
      mCamera.setZoomFactor(0.5f);
      if (!mMusicLoop.isPlaying()) mMusicLoop.play();
    } else {
      mHUD.setVisible(false);
      mCamera.setZoomFactor(1f);
    }

    mCurrentScene = scene;
    getEngine().setScene(mCurrentScene);
  }
  protected void showFirstWave() {
    if (this.rsRoundSystem.getStartRound() != 1) return;

    // @formatter:off
    this.sFirstWave =
        new Sprite(
            (EnvironmentVars.MAIN_CONTEXT.width() - HudRegions.region_wave_1[0].getWidth()) / 2f,
            (EnvironmentVars.MAIN_CONTEXT.height() - HudRegions.region_wave_1[0].getHeight()) / 2f,
            HudRegions.region_wave_1[0],
            EnvironmentVars.MAIN_CONTEXT.getVertexBufferObjectManager());
    this.sFirstWave.setScale(4f);

    this.sFirstWaveSub =
        new Sprite(
            (EnvironmentVars.MAIN_CONTEXT.width() - HudRegions.region_wave_1[1].getWidth()) / 2f,
            this.sFirstWave.getY() + this.sFirstWave.getHeightScaled() + 4f,
            HudRegions.region_wave_1[1],
            EnvironmentVars.MAIN_CONTEXT.getVertexBufferObjectManager()) {
          @Override
          public void dispose() {
            ResourceManager.btWave1.unload();
            super.dispose();
          }
        };
    this.sFirstWaveSub.setScale(1.5f);
    // @formatter:on

    final Music FIRST_WAVE_MUSIC = ResourceManager.mFirstWave;
    EnvironmentVars.MAIN_CONTEXT.registerSound(FIRST_WAVE_MUSIC);
    FIRST_WAVE_MUSIC.seekTo(0);
    FIRST_WAVE_MUSIC.play();

    SessionScene.HUD.attachChild(SessionScene.this.sFirstWave);
    SessionScene.HUD.attachChild(SessionScene.this.sFirstWaveSub);

    ResourceManager.btWave1.load();

    final DelayModifier DELAY_LIFETIME =
        new DelayModifier(3f) {
          @Override
          protected void onModifierFinished(IEntity pItem) {
            super.onModifierFinished(pItem);

            SessionScene.this.rsRoundSystem.start();
            final FlashUpdateHandler FLASH = new FlashUpdateHandler(0.05f, 2);

            FLASH.runOnSwitch(
                new Runnable() {
                  @Override
                  public void run() {
                    final boolean VISIBLE = SessionScene.this.sFirstWave.isVisible();
                    SessionScene.this.sFirstWave.setVisible(!VISIBLE);
                  }
                });

            FLASH.runOnFinish(
                new Runnable() {
                  @Override
                  public void run() {
                    SessionScene.this.unregisterUpdateHandler(FLASH);
                    SessionScene.this.sFirstWave.setVisible(true);

                    EntityUtils.animateEntity(
                        SessionScene.this.sFirstWave,
                        0.25f,
                        EntityUtils.ANIMATION_JUMP_OUT_MEDIUM_INTESTIVITY,
                        EaseLinear.getInstance(),
                        EntityUtils.getDetachDisposeListener());

                    EntityUtils.animateEntity(
                        SessionScene.this.sFirstWaveSub,
                        1f,
                        EntityUtils.ANIMATION_FADE_OUT,
                        EaseCubicInOut.getInstance(),
                        EntityUtils.getDetachDisposeListener());
                  }
                });
            SessionScene.this.registerUpdateHandler(FLASH);
          }
        };
    DELAY_LIFETIME.setAutoUnregisterWhenFinished(true);
    this.registerEntityModifier(DELAY_LIFETIME);

    EntityUtils.animateEntity(this.sFirstWave, 1f, EntityUtils.ANIMATION_FADE_IN);
    EntityUtils.animateEntity(this.sFirstWaveSub, 1f, EntityUtils.ANIMATION_FADE_IN);
  }