예제 #1
0
 /**
  * Update the graphical effects applied in case the character died.
  *
  * @param c the game container
  */
 private void updateDeadView(@Nonnull GameContainer c) {
   int hitPoints = World.getPlayer().getCharacter().getAttribute(CharacterAttribute.HitPoints);
   if (hitPoints == 0) {
     if (!deadViewEnabled) {
       try {
         GrayScaleEffect effect =
             c.getEngine().getAssets().getEffectManager().getGrayScaleEffect(true);
         gameScene.addEffect(effect);
         deadViewEnabled = true;
       } catch (EngineException e) {
         // error activating gray scale
       }
     }
   } else {
     if (deadViewEnabled) {
       try {
         GrayScaleEffect effect =
             c.getEngine().getAssets().getEffectManager().getGrayScaleEffect(true);
         gameScene.removeEffect(effect);
         deadViewEnabled = false;
       } catch (EngineException e) {
         // error activating gray scale
       }
     }
   }
 }
예제 #2
0
 /**
  * Update the graphical effect that shows the fog on the map.
  *
  * @param c the game container
  */
 private void updateFog(@Nonnull GameContainer c) {
   float fog = World.getWeather().getFog();
   if (fog > 0.f) {
     try {
       FogEffect effect = c.getEngine().getAssets().getEffectManager().getFogEffect(true);
       effect.setDensity(fog);
       if (!fogEnabled) {
         gameScene.addEffect(effect);
         fogEnabled = true;
       }
     } catch (EngineException e) {
       // error activating fog
     }
   } else if (fogEnabled) {
     try {
       FogEffect effect = c.getEngine().getAssets().getEffectManager().getFogEffect(true);
       gameScene.removeEffect(effect);
       fogEnabled = false;
     } catch (EngineException e) {
       // error activating fog
     }
   }
 }