コード例 #1
0
ファイル: GameScene.java プロジェクト: houledm/TowerDefense
  public void showRedScreen() {
    final Sprite redScreen =
        new Sprite(
            0.0f,
            0.0f,
            ResourceManager.getInstance().getRedScreen(),
            ResourceManager.getInstance().getVbom()) {
          @Override
          protected void preDraw(GLState pGLState, Camera pCamera) {
            super.preDraw(pGLState, pCamera);
            pGLState.enableDither();
          }
        };

    this.attachChild(redScreen);

    if (lives == 0) {
      displayLoseScreen();
    } else {

      this.registerUpdateHandler(
          new TimerHandler(
              0.25f,
              new ITimerCallback() {

                @Override
                public void onTimePassed(TimerHandler pTimerHandler) {
                  redScreen.detachSelf();
                  unregisterUpdateHandler(pTimerHandler);
                }
              }));
    }
  }
コード例 #2
0
 /**
  * Display a message
  *
  * @param title the message's title
  * @param msg the message itself
  */
 public void display(String title, String msg) {
   JOptionPane.showMessageDialog(
       mOwner,
       ResourceManager.getInstance().getString(msg),
       ResourceManager.getInstance().getString(title),
       JOptionPane.ERROR_MESSAGE);
 }
コード例 #3
0
 private void formatFileNode(FileNode pNode) {
   if (pNode.isTestcaseDir()) {
     if (pNode.isTestcaseCheckOk()) {
       Icon icon = ResourceManager.getInstance().getImageIcon("icons/tc16");
       setIcon(icon);
     } else {
       setIcon(ResourceManager.getInstance().getImageIcon("icons/tc16_nodata"));
       this.setToolTipText("no TestData.csv file found");
     }
   } else {
     setIcon(ResourceManager.getInstance().getImageIcon("icons/dir16"));
   }
 }
コード例 #4
0
ファイル: BackgroundLayer.java プロジェクト: MNiekel/Parsec
  public BackgroundLayer() {
    super();

    final Camera camera = ResourceManager.getInstance().camera;
    final float width = camera.getWidth();
    final float height = camera.getHeight();

    final float moonX = 2 * width / 3;
    final float moonY = height / 2;

    final GameObject moon =
        new GameObject(moonX, moonY, ResourceManager.getInstance().mMoonTextureRegion);

    this.attachChild(moon);
  }
コード例 #5
0
ファイル: GameScene.java プロジェクト: houledm/TowerDefense
  private void displayWinScreen() {
    camera.setZoomFactor(1.0f);
    camera.set(0, 0, mCamera.getWidth(), mCamera.getHeight());
    camera.setHUD(null);
    Sprite background =
        new Sprite(0.0f, 0.0f, ResourceManager.getInstance().getFireworksRegion(), vbom);
    this.attachChild(background);

    Text win = new Text(0, 0, ResourceManager.getInstance().getWhiteFont(), "You Win!", vbom);
    win.setPosition(camera.getWidth() / 2 - win.getWidthScaled() / 2, camera.getHeight() / 10);
    this.attachChild(win);

    toggleInGameMenu();
    disableBackButton = true;
  }
コード例 #6
0
 public static String getOrSetUsername(HttpServletRequest request, HttpServletResponse response)
     throws IOException {
   Principal principal = request.getUserPrincipal();
   String username = null;
   if (principal != null) {
     username = principal.getName();
   }
   if (username == null) {
     // no principal found
     try {
       for (Cookie cookie : request.getCookies()) {
         if (cookie.getName().equals("auid")) {
           username = cookie.getValue();
         }
       }
     } catch (Exception e) {
     }
   }
   if (username == null) {
     // no principal and no cookie found in request
     // check response first, maybe an enclosing jsp set it
     username = (String) request.getAttribute("auid");
   }
   if (username == null) {
     // we really don't have one,
     // let's create a new cookie
     username = ResourceManager.getInstance().getUserManager().generateAnonymousUserId();
     response.addCookie(new Cookie("auid", username));
     // add as a request attribute so chained servlets can get to it
     request.setAttribute("auid", username);
   }
   return username;
 }
コード例 #7
0
    public TextureRegion alloc() {
      if (allocIndex >= draws.size())
        draws.add(
            ResourceManager.getInstance(ResourceManager.class).createTextureRegion(textureName));

      return draws.get(allocIndex++);
    }
コード例 #8
0
  /**
   * Returns the corresponding {@link ResourceManager}.
   *
   * @return The corresponding {@code ResourceManager}
   */
  ResourceManager getResourceManager() {
    if (resourceManager == null) {
      resourceManager = ResourceManager.getInstance(this);
    }

    return resourceManager;
  }
コード例 #9
0
  public Lvl3Boss(ITextureRegion pTextureRegion) {
    super(
        (float) (0 + (int) (Math.random() * ((1024 - 0) + 1))),
        (float) (0 + (int) (Math.random() * ((640 - 0) + 1))),
        pTextureRegion,
        ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    // super(200,200,
    // pTextureRegion,ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    sprite = this;
    // enemyPhysics = PhysicsFactory.createBoxBody(GameLevel.getInstance().mPhysicsWorld, sprite,
    // BodyType.StaticBody, enemyFixtureDef);;
    fromX = sprite.getX();
    fromY = sprite.getY();
    // Handle rotation of every sprite

    // sprite.setRotation(MathUtils.radToDeg(rotationAngle));

    // GameLevel.getInstance().bulletTimerHandler = bossBulletTimerHandler;

    setUpBoss();
    GameLevel.getInstance().attachChild(sprite);

    // sprite = new
    // TODO Auto-generated constructor stub
  }
コード例 #10
0
ファイル: SplashScene.java プロジェクト: mgoulet/Game1
  public SplashScene(MainActivity activityReference) {
    super();

    this.activityReference = activityReference;

    mainSplashTextLabel =
        new Text(
            160,
            230,
            ResourceManager.getInstance().splashBitmapFont,
            "SPLASH SCREEN.",
            new TextOptions(HorizontalAlign.CENTER),
            ResourceManager.getInstance().getActivityReference().getVertexBufferObjectManager());

    this.setBackground(new Background(0.0f, 0.0f, 0.0f));
  }
コード例 #11
0
 public BaseScene() {
   resourceManager = ResourceManager.getInstance();
   engine = resourceManager.engine;
   vertexBufferObjectManager = engine.getVertexBufferObjectManager();
   camera = resourceManager.camera;
   activity = resourceManager.activity;
   createScene();
 }
コード例 #12
0
 /**
  * Add the contents of a custom langpack (if exist) to the previos loaded comman langpack. If not
  * exist, trace an info and do nothing more.
  *
  * @param idata install data to be used
  */
 protected void addCustomLangpack(AutomatedInstallData idata) {
   // We try to load and add a custom langpack.
   try {
     idata.langpack.add(ResourceManager.getInstance().getInputStream(LANG_FILE_NAME));
   } catch (Throwable exception) {
     Debug.trace("No custom langpack available.");
     return;
   }
   Debug.trace("Custom langpack for " + idata.localeISO3 + " available.");
 }
コード例 #13
0
ファイル: TowerTile.java プロジェクト: houledm/TowerDefense
 public static void initializeMap() {
   ResourceManager resourceManager = ResourceManager.getInstance();
   HashMap<BaseTextureRegion, Class<?>> aMap = new HashMap<BaseTextureRegion, Class<?>>();
   aMap.put(resourceManager.getTurretTowerRegion(), TurretTower.class);
   aMap.put(resourceManager.getDartTowerRegion(), DartTower.class);
   aMap.put(resourceManager.getFlameTowerRegion(), FlameTower.class);
   aMap.put(resourceManager.getIceTowerRegion(), IceTower.class);
   aMap.put(resourceManager.getSpikeTowerRegion(), SpikeTower.class);
   towerMap = aMap;
 }
コード例 #14
0
ファイル: GameScene.java プロジェクト: houledm/TowerDefense
  private void displayLoseScreen() {
    camera.setZoomFactor(1.0f);
    camera.set(0, 0, mCamera.getWidth(), mCamera.getHeight());
    camera.setHUD(null);

    Text lose = new Text(0, 0, ResourceManager.getInstance().getWhiteFont(), "You Lose", vbom);
    lose.setPosition(camera.getWidth() / 2 - lose.getWidthScaled() / 2, camera.getHeight() / 10);
    this.attachChild(lose);

    toggleInGameMenu();
    disableBackButton = true;
  }
コード例 #15
0
ファイル: Scenario.java プロジェクト: alu0100777758/ludum
 /**
  * Pinta el escenario.
  *
  * @param g
  */
 public void paint(Graphics g) {
   getWorld().paint(g);
   if (isPaused()) {
     ScreenManager sm = ScreenManager.getInstance();
     g.drawImage(
         ResourceManager.getInstance().getBufferedImage(PAUSE_TEXTURE),
         0,
         0,
         (int) (sm.getWindWidth() * sm.getRate_x()),
         (int) (sm.getWindHeight() * sm.getRate_y()),
         null);
   }
 }
コード例 #16
0
  public static void initStatic() {
    tipsActiveList = new ArrayList<TipsBillborad>();
    tipsFreeList = new ArrayList<TipsBillborad>();
    font = ResourceManager.getInstance(ResourceManager.class).getFont((int) (Settings.UNIT * 0.6f));
    spriteBatch = new SpriteBatch();
    textureMap.clear();

    Driver.getInstance(Driver.class)
        .addListener(
            new DriverListenerBaseImpl() {
              private static final long serialVersionUID = 2939432378098238642L;

              @Override
              public void update(float deltaTime) {
                updateTips(deltaTime);
              }

              @Override
              public void dispose() {
                spriteBatch.dispose();
                tipsActiveList.clear();
                tipsFreeList.clear();
              }
            });

    Renderer.getInstance(Renderer.class)
        .addListener(
            new RendererListener() {
              private static final long serialVersionUID = -3659126136217212295L;

              @Override
              public void renderEnded() {
                renderTips();
              }

              @Override
              public void renderBegined() {}

              @Override
              public void emptyTapped() {
                // TODO Auto-generated method stub

              }
            });
  }
コード例 #17
0
ファイル: AnswerSprite.java プロジェクト: nothingnew/bym
  public AnswerSprite(
      float pX,
      float pY,
      ITextureRegion pTextureRegion,
      IAnimationListener pCorrectAnimationListener,
      IAnimationListener pWrongAnimationListener,
      VertexBufferObjectManager pVertexBufferObject) {

    super(pX, pY, ResourceManager.getInstance().mGameTextureRegionBackground, pVertexBufferObject);

    checked = false;
    correct = false;
    correctAnimationListener = pCorrectAnimationListener;
    wrongAnimationListener = pWrongAnimationListener;

    imageSprite = new Sprite(getWidth() / 2, getHeight() / 2, pTextureRegion, pVertexBufferObject);

    attachChild(imageSprite);
  }
コード例 #18
0
ファイル: Bullet.java プロジェクト: houledm/TowerDefense
public class Bullet extends Sprite {

  public float speed;
  private static VertexBufferObjectManager vbom = ResourceManager.getInstance().getVbom();

  public Bullet(TextureRegion region, float speed) {
    super(0, 0, region, vbom);
    this.speed = speed;
  }

  public void destroy() {
    TowerDefenseActivity.getSharedInstance()
        .runOnUpdateThread(
            new Runnable() {
              @Override
              public void run() {
                clearEntityModifiers();
                detachSelf();
              }
            });
  }
}
コード例 #19
0
ファイル: Scenario.java プロジェクト: alu0100777758/ludum
 /** Actualiza el estado del escenario. */
 public void update() {
   if (!isPaused()) {
     getPhysicEngine().update();
     /** Verifica si alguien tiene que morir. */
     for (int i = 0; i < getStaticMap().size(); i++)
       if (((Physical_passive) getStaticMap().get(i)).hasToDie()) getStaticMap().remove(i);
     if (getPlayer_one().hasToDie()) {
       setEnded(true);
       setRedWins(true);
       DefaultModeScoring.addWinningScore(getPlayer_two());
     }
     if (getPlayer_two().hasToDie()) {
       setEnded(true);
       setBlueWins(true);
       DefaultModeScoring.addWinningScore(getPlayer_one());
     }
     if (isEnded()) {
       AudioManager.stopAll();
       AudioManager.startAudio(
           dieSounds[ResourceManager.getInstance().getRandGen().nextInt(dieSounds.length)]);
       GameLoop.stepTimer.stop();
     }
   }
 }
コード例 #20
0
ファイル: VmsMonitoring.java プロジェクト: nirs/ovirt-engine
 protected ResourceManager getResourceManager() {
   return ResourceManager.getInstance();
 }
コード例 #21
0
  @Override
  protected void ExecuteVdsIdCommand() {

    if (_vdsManager != null) {

      final DestroyVmVDSCommandParameters parameters = getParameters();
      ResourceManager.getInstance().RemoveAsyncRunningVm(parameters.getVmId());

      final VM curVm = DbFacade.getInstance().getVmDao().get(parameters.getVmId());
      curVm.setInterfaces(
          DbFacade.getInstance().getVmNetworkInterfaceDao().getAllForVm(curVm.getId()));

      DestroyVDSCommand<DestroyVmVDSCommandParameters> vdsBrokerCommand =
          new DestroyVDSCommand<DestroyVmVDSCommandParameters>(parameters);
      vdsBrokerCommand.Execute();
      if (vdsBrokerCommand.getVDSReturnValue().getSucceeded()) {
        if (curVm.getstatus() == VMStatus.Down) {
          getVDSReturnValue().setReturnValue(VMStatus.Down);
        }

        // Updating the DB
        ResourceManager.getInstance()
            .InternalSetVmStatus(
                curVm, parameters.getGracefully() ? VMStatus.PoweringDown : VMStatus.Down);

        TransactionSupport.executeInNewTransaction(
            new TransactionMethod<Void>() {
              @Override
              public Void runInTransaction() {

                try {
                  curVm.guestLogoutTimeTreatmentAfterDestroy();
                  // SaveVmDynamicToDBThreaded(curVm);
                  DbFacade.getInstance().getVmDynamicDao().update(curVm.getDynamicData());
                  DbFacade.getInstance().getVmStatisticsDao().update(curVm.getStatisticsData());
                  List<VmNetworkInterface> interfaces = curVm.getInterfaces();
                  if (interfaces != null && interfaces.size() > 0) {
                    for (VmNetworkInterface ifc : interfaces) {
                      VmNetworkStatistics stats = ifc.getStatistics();
                      DbFacade.getInstance().getVmNetworkStatisticsDao().update(stats);
                    }
                  }
                } catch (RepositoryException ex) {
                  log.errorFormat(
                      "VDS::destroy Failed to update vds status in database,  vds = {1} : {2}, error = {3}",
                      getVds().getId(), getVds().getvds_name(), ex.getMessage());
                  log.error("Exception: ", ex);
                  throw ex;
                }

                getVds().setmem_commited(getVds().getmem_commited() - curVm.getvm_mem_size_mb());
                getVds().setmem_commited(getVds().getmem_commited() - getVds().getguest_overhead());
                getVds().setvms_cores_count(getVds().getvms_cores_count() - curVm.getnum_of_cpus());
                _vdsManager.UpdateDynamicData(getVds().getDynamicData());
                return null;
              }
            });

        // if using stop then call to ProcessOnVmStop because
        // will not be called from UpdateRunTimeInfo
        if (!parameters.getGracefully()) {
          onVmStop(curVm);
        }

        getVDSReturnValue().setReturnValue(curVm.getstatus());
      } else if (vdsBrokerCommand.getVDSReturnValue().getExceptionObject() != null) {
        log.errorFormat(
            "VDS::destroy Failed destroying vm '{0}' in vds = {1} : {2}, error = {3}",
            parameters.getVmId(),
            getVds().getId(),
            getVds().getvds_name(),
            vdsBrokerCommand.getVDSReturnValue().getExceptionString());
        getVDSReturnValue().setSucceeded(false);
        getVDSReturnValue()
            .setExceptionString(vdsBrokerCommand.getVDSReturnValue().getExceptionString());
        getVDSReturnValue()
            .setExceptionObject(vdsBrokerCommand.getVDSReturnValue().getExceptionObject());
        getVDSReturnValue().setVdsError(vdsBrokerCommand.getVDSReturnValue().getVdsError());
      }
    } else {
      getVDSReturnValue().setSucceeded(false);
    }
  }
コード例 #22
0
 /**
  * Add a log message to the JTextArea corresponding to the given message key
  *
  * @param messageKey
  */
 public void printKey(String messageKey) {
   println(ResourceManager.getInstance().getString(messageKey));
 }
コード例 #23
0
ファイル: LangManager.java プロジェクト: rsezille/phantomedge
  /**
   * Load the specified language from the languages directory
   *
   * @param languageCode - The language code ("en", "fr", "es"...)
   */
  @SuppressWarnings("unchecked")
  public void loadLanguage(String languageCode) {
    if (languageCode != null && !"".equals(languageCode)) {
      currentStrings.clear();
      currentDialogs.clear();

      Yaml yaml = new Yaml();
      java.util.Map<String, Object> resultMap = null;

      // Strings
      try {
        InputStream ios =
            new FileInputStream(new File(Constants.PATH_LANGUAGES + languageCode + "/strings.dat"));
        resultMap = (java.util.Map<String, Object>) yaml.load(ios);
        ios.close();
      } catch (Exception e) {
        Logger.err(
            "Error during opening "
                + Constants.PATH_LANGUAGES
                + languageCode
                + "/strings.dat file: "
                + e,
            LangManager.class.getSimpleName());
      }

      if (resultMap == null) {
        Logger.warn(
            Constants.PATH_LANGUAGES + languageCode + "/strings.dat is empty",
            LangManager.class.getSimpleName());
      } else if (!resultMap.containsKey("strings")) {
        Logger.warn(
            "Main key 'strings' not found in "
                + Constants.PATH_LANGUAGES
                + languageCode
                + "/strings.dat",
            LangManager.class.getSimpleName());
      } else {
        for (LinkedHashMap<String, Object> string :
            (ArrayList<LinkedHashMap<String, Object>>) resultMap.get("strings")) {
          if (Constants.DEFAULT_LANGUAGE.equals(languageCode)) {
            defaultStrings.put((String) string.get("id"), (String) string.get("text"));
          } else {
            currentStrings.put((String) string.get("id"), (String) string.get("text"));
          }
        }
      }

      // Dialogs
      try {
        InputStream ios =
            new FileInputStream(new File(Constants.PATH_LANGUAGES + languageCode + "/dialogs.dat"));
        resultMap = (java.util.Map<String, Object>) yaml.load(ios);
        ios.close();
      } catch (Exception e) {
        Logger.err(
            "Error during opening "
                + Constants.PATH_LANGUAGES
                + languageCode
                + "/dialogs.dat file: "
                + e,
            ResourceManager.class.getSimpleName());
      }

      if (resultMap == null) {
        Logger.warn(
            Constants.PATH_LANGUAGES + languageCode + "/dialogs.dat is empty",
            LangManager.class.getSimpleName());
      } else if (!resultMap.containsKey("dialogs")) {
        Logger.warn(
            "Main key 'dialogs' not found in "
                + Constants.PATH_LANGUAGES
                + languageCode
                + "/dialogs.dat",
            LangManager.class.getSimpleName());
      } else {
        for (LinkedHashMap<String, Object> string :
            (ArrayList<LinkedHashMap<String, Object>>) resultMap.get("dialogs")) {
          if (Constants.DEFAULT_LANGUAGE.equals(languageCode)) {
            defaultDialogs.put((String) string.get("id"), (String) string.get("text"));
          } else {
            currentDialogs.put((String) string.get("id"), (String) string.get("text"));
          }
        }
      }

      // Images
      if (!Constants.DEFAULT_LANGUAGE.equals(languageCode)) {
        ResourceManager.getInstance().loadLanguageImages(languageCode);
      }
    } else {
      Logger.info("Trying to load an empty language code.", LangManager.class.getSimpleName());
    }
  }
コード例 #24
0
  private void setUpBoss() {
    // beenHit = false;
    sprite.setVisible(true);
    sprite.setIgnoreUpdate(false);
    sprite.setColor(1, 1, 1);
    sprite.setCullingEnabled(true);
    // GameLevel.getInstance().attachChild(sprite);
    bulletPool = new Lvl3BossLaserPool(8);
    // PLAYER LASER SETUP
    // Create new laser
    Log.v("", "calls for a Boss laser");

    Log.v("Boss1", sprite.getX() + " " + sprite.getY());

    moveBoss1 = new MoveModifier(duration, fromX, fromY, toX, toY);

    sprite.registerEntityModifier(moveBoss1);

    // SETUP ENEMY LASER
    ResourceManager.getInstance()
        .engine
        .registerUpdateHandler(
            bossBulletTimerHandler =
                new TimerHandler(
                    3f,
                    new ITimerCallback() {

                      @Override
                      public void onTimePassed(TimerHandler pTimerHandler) {
                        // TODO Auto-generated method stub
                        bossBulletTimerHandler.setTimerSeconds(1f);
                        bossBulletTimerHandler.reset();
                        // Log.v("", "time runs every second");
                        if (GameLevel.getInstance().BossReady) {
                          // Log.v(""," Enemy recycledOrNot? " + recycleBullet);
                          if (recycleBullet == true) {

                            if (bulletPool.getAvailableItemCount() > 0) {
                              bullet =
                                  bulletPool.obtainPoolItem(
                                      sprite.getX(), sprite.getY(), sprite.getRotation(), sprite);
                              // Log.v(""," After get a new bullet on scene " + recycleBullet);
                              // GameLevel.getInstance().EnemyLaser = bullet;
                              bulletLifeEnd = false;
                              explodeAnimation = false;
                              recycleBullet = false;
                              Log.v("", "BULLET CREATED FOR BOSS 3 !");
                            }

                          } else {
                            // bulletPool.recyclePoolItem((Lvl3BossLaser)bullet);

                            ResourceManager.getInstance()
                                .engine
                                .runOnUpdateThread(
                                    new Runnable() {
                                      @Override
                                      public void run() {

                                        if (bullet != null) {
                                          // bullet.detachSelf();
                                          Log.v("", "BULLET RECYCLED FOR BOSS 3 !");
                                          // bulletLifeEnd = true;
                                          // Log.v("","Removes bullet from scene");
                                          recycleBullet = true;
                                          // Log.v(""," After detach bullet from Scene? " +
                                          // recycleBullet);
                                        }
                                      }
                                    });
                          }
                        }
                      }
                    }));
    // END SETUP ENEMY LASER
    // setup timer handler for boss bullets so they can be cleared by the GameLevel.
    setTimerHandler(bossBulletTimerHandler);
    bossBulletTimerHandler = getTimerHandler();
  }
コード例 #25
0
  private boolean readSpec() {
    InputStream input;
    try {
      input = ResourceManager.getInstance().getInputStream(SPEC_RESOURCE_NAME);
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }

    StdXMLParser parser = new StdXMLParser();
    parser.setBuilder(new StdXMLBuilder());
    parser.setValidator(new NonValidator());

    try {
      parser.setReader(new StdXMLReader(input));

      this.spec = (XMLElement) parser.parse();
    } catch (Exception e) {
      System.out.println("Error parsing XML specification for compilation.");
      e.printStackTrace();
      return false;
    }

    if (!this.spec.hasChildren()) return false;

    this.compilerArgumentsList = new ArrayList();
    this.compilerList = new ArrayList();

    // read <global> information
    XMLElement global = this.spec.getFirstChildNamed("global");

    // use some default values if no <global> section found
    if (global != null) {

      // get list of compilers
      this.compilerSpec = global.getFirstChildNamed("compiler");

      if (this.compilerSpec != null) {
        readChoices(this.compilerSpec, this.compilerList);
      }

      this.compilerArgumentsSpec = global.getFirstChildNamed("arguments");

      if (this.compilerArgumentsSpec != null) {
        // basicly perform sanity check
        readChoices(this.compilerArgumentsSpec, this.compilerArgumentsList);
      }
    }

    // supply default values if no useful ones where found
    if (this.compilerList.size() == 0) {
      this.compilerList.add("javac");
      this.compilerList.add("jikes");
    }

    if (this.compilerArgumentsList.size() == 0) {
      this.compilerArgumentsList.add("-O -g:none");
      this.compilerArgumentsList.add("-O");
      this.compilerArgumentsList.add("-g");
      this.compilerArgumentsList.add("");
    }

    return true;
  }
コード例 #26
0
ファイル: VmsMonitoring.java プロジェクト: nirs/ovirt-engine
  private void afterVMsRefreshTreatment() {
    Collection<Guid> movedToDownVms = new ArrayList<>();
    List<Guid> succeededToRunVms = new ArrayList<>();

    // now loop over the result and act
    for (VmAnalyzer vmAnalyzer : vmAnalyzers) {

      // rerun all vms from rerun list
      if (vmAnalyzer.isRerun()) {
        log.error(
            "Rerun VM '{}'. Called from VDS '{}'",
            vmAnalyzer.getDbVm().getId(),
            vdsManager.getVdsName());
        ResourceManager.getInstance()
            .rerunFailedCommand(vmAnalyzer.getDbVm().getId(), vdsManager.getVdsId());
      }

      if (vmAnalyzer.isSuccededToRun()) {
        vdsManager.succeededToRunVm(vmAnalyzer.getDbVm().getId());
        succeededToRunVms.add(vmAnalyzer.getDbVm().getId());
      }

      // Refrain from auto-start HA VM during its re-run attempts.
      if (vmAnalyzer.isAutoVmToRun() && !vmAnalyzer.isRerun()) {
        autoVmsToRun.add(vmAnalyzer.getDbVm().getId());
      }

      // process all vms that their ip changed.
      if (vmAnalyzer.isClientIpChanged()) {
        final VmDynamic vmDynamic = vmAnalyzer.getVdsmVm().getVmDynamic();
        getVdsEventListener().processOnClientIpChange(vmDynamic.getId(), vmDynamic.getClientIp());
      }

      // process all vms that powering up.
      if (vmAnalyzer.isPoweringUp()) {
        getVdsEventListener().processOnVmPoweringUp(vmAnalyzer.getVdsmVm().getVmDynamic().getId());
      }

      if (vmAnalyzer.isMovedToDown()) {
        movedToDownVms.add(vmAnalyzer.getDbVm().getId());
      }

      if (vmAnalyzer.isRemoveFromAsync()) {
        ResourceManager.getInstance().removeAsyncRunningVm(vmAnalyzer.getDbVm().getId());
      }

      if (vmAnalyzer.isHostedEngineUnmanaged()) {
        // @since 3.6 - we take existing HE VM and reimport it
        importHostedEngineVM(
            getVmInfo(
                Collections.singletonList(
                    vmAnalyzer.getVdsmVm().getVmDynamic().getId().toString()))[0]);
      }
    }

    getVdsEventListener().updateSlaPolicies(succeededToRunVms, vdsManager.getVdsId());

    // run all vms that crashed that marked with auto startup
    getVdsEventListener().runFailedAutoStartVMs(autoVmsToRun);

    // process all vms that went down
    getVdsEventListener().processOnVmStop(movedToDownVms, vdsManager.getVdsId());

    getVdsEventListener()
        .refreshHostIfAnyVmHasHostDevices(succeededToRunVms, vdsManager.getVdsId());
  }
コード例 #27
0
  @Override
  public void onLoadScene() {
    // Load the menu resources
    ResourceManager.loadMenuResources();

    // Create the background
    BackgroundSprite =
        new Sprite(
            ResourceManager.getInstance().cameraWidth / 2f,
            ResourceManager.getInstance().cameraHeight / 2f,
            ResourceManager.menuBackgroundTextureRegion,
            ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    BackgroundSprite.setScaleX(ResourceManager.getInstance().cameraWidth);
    BackgroundSprite.setScaleY(ResourceManager.getInstance().cameraHeight / 480f);
    BackgroundSprite.setZIndex(-5000);
    this.attachChild(BackgroundSprite);

    // Create clouds that move from one side of the screen to the other, and repeat.
    CloudSprites = new Sprite[20];
    for (Sprite curCloudSprite : CloudSprites) {
      curCloudSprite =
          new Sprite(
              MathUtils.random(
                  -(this.getWidth() * this.getScaleX()) / 2,
                  ResourceManager.getInstance().cameraWidth
                      + (this.getWidth() * this.getScaleX()) / 2),
              MathUtils.random(
                  -(this.getHeight() * this.getScaleY()) / 2,
                  ResourceManager.getInstance().cameraHeight
                      + (this.getHeight() * this.getScaleY()) / 2),
              ResourceManager.cloudTextureRegion,
              ResourceManager.getInstance().engine.getVertexBufferObjectManager()) {
            private float XSpeed = MathUtils.random(0.2f, 2f);
            private boolean initialized = false;

            @Override
            protected void onManagedUpdate(final float pSecondsElapsed) {
              super.onManagedUpdate(pSecondsElapsed);
              if (!initialized) {
                initialized = true;
                this.setScale(XSpeed / 2);
                this.setZIndex(-4000 + Math.round(XSpeed * 1000f));
                MainMenu.getInstance().sortChildren();
              }
              if (this.getX() < -(this.getWidth() * this.getScaleX()) / 2) {
                XSpeed = MathUtils.random(0.2f, 2f);
                this.setScale(XSpeed / 2);
                this.setPosition(
                    ResourceManager.getInstance().cameraWidth
                        + (this.getWidth() * this.getScaleX()) / 2,
                    MathUtils.random(
                        -(this.getHeight() * this.getScaleY()) / 2,
                        ResourceManager.getInstance().cameraHeight
                            + (this.getHeight() * this.getScaleY()) / 2));

                this.setZIndex(-4000 + Math.round(XSpeed * 1000f));
                MainMenu.getInstance().sortChildren();
              }
              this.setPosition(this.getX() - (XSpeed * (pSecondsElapsed / 0.016666f)), this.getY());
            }
          };
      this.attachChild(curCloudSprite);
    }

    // Create a Play button. Notice that the Game scenes, unlike menus, are not referred to in a
    // static way.
    PlayButton =
        new ButtonSprite(
            (ResourceManager.getInstance().cameraWidth
                    - ResourceManager.buttonTiledTextureRegion.getTextureRegion(0).getWidth())
                / 2f,
            (ResourceManager.getInstance().cameraHeight
                    - ResourceManager.buttonTiledTextureRegion.getTextureRegion(0).getHeight())
                * (1f / 3f),
            ResourceManager.buttonTiledTextureRegion.getTextureRegion(0),
            ResourceManager.buttonTiledTextureRegion.getTextureRegion(1),
            ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    PlayButtonText =
        new Text(
            0,
            0,
            ResourceManager.fontDefault32Bold,
            "PLAY",
            ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    PlayButtonText.setPosition((PlayButton.getWidth()) / 2, (PlayButton.getHeight()) / 2);
    PlayButton.attachChild(PlayButtonText);
    this.attachChild(PlayButton);
    PlayButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(
              ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            // Create a new GameLevel and show it using the SceneManager. And play a click.
            SceneManager.getInstance().showScene(new GameLevel());
            ResourceManager.clickSound.play();
          }
        });
    this.registerTouchArea(PlayButton);

    // Create an Option button. Notice that the SceneManager is being told to not pause the scene
    // while the OptionsLayer is open.
    OptionsButton =
        new ButtonSprite(
            PlayButton.getX() + PlayButton.getWidth(),
            PlayButton.getY(),
            ResourceManager.buttonTiledTextureRegion.getTextureRegion(0),
            ResourceManager.buttonTiledTextureRegion.getTextureRegion(1),
            ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    OptionsButtonText =
        new Text(
            0,
            0,
            ResourceManager.fontDefault32Bold,
            "OPTIONS",
            ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    OptionsButtonText.setPosition((OptionsButton.getWidth()) / 2, (OptionsButton.getHeight()) / 2);
    OptionsButton.attachChild(OptionsButtonText);
    this.attachChild(OptionsButton);
    OptionsButton.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(
              ButtonSprite pButtonSprite, float pTouchAreaLocalX, float pTouchAreaLocalY) {
            // Show the OptionsLayer and play a click.
            SceneManager.getInstance().showOptionsLayer(false);
            ResourceManager.clickSound.play();
          }
        });
    this.registerTouchArea(OptionsButton);

    // Create a title
    TitleText =
        new Text(
            0,
            0,
            ResourceManager.fontDefault72Bold,
            "HAPPY BIRDS",
            ResourceManager.getInstance().engine.getVertexBufferObjectManager());
    TitleText.setPosition(
        (ResourceManager.getInstance().cameraWidth) / 2,
        (ResourceManager.getInstance().cameraHeight * 2) / 3f);
    TitleText.setColor(0.153f, 0.290f, 0.455f);
    this.attachChild(TitleText);
  }
コード例 #28
0
ファイル: VmsMonitoring.java プロジェクト: nirs/ovirt-engine
 protected IVdsEventListener getVdsEventListener() {
   return ResourceManager.getInstance().getEventListener();
 }
コード例 #29
0
ファイル: GameScene.java プロジェクト: houledm/TowerDefense
 @Override
 public void disposeScene() {
   camera.setHUD(null);
   ResourceManager.getInstance().unloadGameScene();
 }
コード例 #30
0
ファイル: GameScene.java プロジェクト: houledm/TowerDefense
  // ***********************************************************
  // CONSTRUCTOR
  // ***********************************************************
  public GameScene(MapType type) {
    instance = this;

    gameMap = new GameMap(type);

    // Zoom-Camera configuration
    this.setOnAreaTouchTraversalFrontToBack();
    this.mScrollDetector = new SurfaceScrollDetector(this);

    activity = TowerDefenseActivity.getSharedInstance();
    resourceManager = ResourceManager.getInstance();

    if (MultiTouch.isSupported(activity)) {
      this.mPinchZoomDetector = new PinchZoomDetector(this);
    } else {
      this.mPinchZoomDetector = null;
    }

    this.setOnSceneTouchListener(this);
    this.setOnSceneTouchListenerBindingOnActionDownEnabled(true);

    fingerOnSceneCount = 0;
    zooming = false;

    String map = "";

    if (type == MapType.DESERT) map = "tmx/new_desert_path.tmx";
    else if (type == MapType.GRASS) map = "tmx/grass_path.tmx";
    else if (type == MapType.TUNDRA) map = "tmx/tundra_path.tmx";

    try {
      final TMXLoader tmxLoader =
          new TMXLoader(
              activity.getAssets(),
              activity.getEngine().getTextureManager(),
              TextureOptions.BILINEAR_PREMULTIPLYALPHA,
              activity.getVertexBufferObjectManager(),
              new ITMXTilePropertiesListener() {
                @Override
                public void onTMXTileWithPropertiesCreated(
                    final TMXTiledMap pTMXTiledMap,
                    final TMXLayer pTMXLayer,
                    final TMXTile pTMXTile,
                    final TMXProperties<TMXTileProperty> pTMXTileProperties) {}
              });
      this.mTMXTiledMap = tmxLoader.loadFromAsset(map);
    } catch (final TMXLoadException e) {
      Debug.e(e);
    }

    gameMap.setMap(mTMXTiledMap);

    tmxLayer = this.mTMXTiledMap.getTMXLayers().get(0);
    tmxLayer.setIgnoreUpdate(true);
    this.attachChild(tmxLayer);

    mCamera = activity.getCamera();
    this.mCamera.setBounds(
        0, (mCamera.getHeight() - tmxLayer.getHeight()), tmxLayer.getWidth(), tmxLayer.getHeight());
    this.mCamera.setBoundsEnabled(true);

    float camera_width = activity.getCamera().getWidth();
    float camera_height = activity.getCamera().getHeight();
    if (camera_width / tmxLayer.getHeight() >= camera_height / tmxLayer.getWidth())
      maxZoom = camera_width / (tmxLayer.getHeight() * 2);
    else maxZoom = camera_height / (tmxLayer.getWidth() * 2);

    // 2-dimensional array of tiles
    TMXTile[][] tiles = tmxLayer.getTMXTiles();

    startTile = null;
    endTile = null;
    outer:
    for (int i = 0; i < tiles.length; i++) {
      for (int j = 0; j < tiles[0].length; j++) {

        int[] start = gameMap.getStartTile();
        int[] end = gameMap.getEndTile();

        if (i == start[0] && j == start[1]) {
          startTile = tiles[i][j];
        } else if (i == end[0] && j == end[1]) {
          endTile = tiles[i][j];
          break outer;
        }
      }
    }

    money = 60;
    lives = 20;

    // Initializes the HUD
    panel = new BottomPanel(mCamera, gameMap);
    this.attachChild(panel);

    TowerTile.initializeMap();

    TowerTile turretTile = new TowerTile(resourceManager.getTurretTowerRegion());
    panel.placeTowerAccess(turretTile, 1);

    TowerTile iceTile = new TowerTile(resourceManager.getIceTowerRegion());
    panel.placeTowerAccess(iceTile, 2);

    TowerTile dartTile = new TowerTile(resourceManager.getDartTowerRegion());
    panel.placeTowerAccess(dartTile, 3);

    TowerTile spikeTile = new TowerTile(resourceManager.getSpikeTowerRegion());
    panel.placeTowerAccess(spikeTile, 4);

    TowerTile flameTile = new TowerTile(resourceManager.getFlameTowerRegion());
    panel.placeTowerAccess(flameTile, 5);

    startButton =
        new AnimatedSprite(
            0.0f,
            0.0f,
            resourceManager.getStartButtonRegion(),
            activity.getVertexBufferObjectManager()) {
          @Override
          public boolean onAreaTouched(
              TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY) {

            if (readyToPressAgain) {
              startCurrentWave();

              readyToPressAgain = false;
              this.registerUpdateHandler(
                  new TimerHandler(
                      1.0f,
                      new ITimerCallback() {

                        @Override
                        public void onTimePassed(TimerHandler pTimerHandler) {
                          readyToPressAgain = true;
                          unregisterUpdateHandler(pTimerHandler);
                        }
                      }));
            }

            panel.detachTowerTextDescription();

            return true;
          }
        };

    startButton.setScale(0.473372781f);
    panel.placeStartButton(startButton);

    // Getting texture regions for submenu items
    SubMenuManager.getDeleteRegion(resourceManager.getDeleteOptionRegion());
    SubMenuManager.getUpgradeRegion(resourceManager.getUpgradeOptionRegion());
    SubMenuManager.getReticalRegion(resourceManager.getTowerSightRegion());

    // Initializing tower array
    towers = new ArrayList<ITower>();

    downCoords = new Vector2();

    blockedTileList = new ArrayList<TMXTile>();

    aStarHelper = new AStarPathHelper(mTMXTiledMap, endTile);
    waveGenerator = new WaveHelper();
    waveCount = 0;
    deadEnemies = 0;

    waveFinished = true;
    initializedNewWave = false;

    // Sets up paths/move modifiers of enemies in the first wave
    initializeNextWave();

    FlameTower.initialize(resourceManager.getFlameParticleRegion());

    Log.i(
        "Info",
        "Dead Enemies: "
            + deadEnemies
            + " Finished Enemies: "
            + aStarHelper.getNumberOfEnemiesFinished()
            + " Current Wave Length: "
            + currentWave.getEnemies().size());

    speedFactor = 0.5f;
    readyToPressAgain = true;

    // collisionDetect = new TimerHandler((float)0.0125/speedFactor, true, new ITimerCallback() {

    collisionDetect =
        new TimerHandler(
            0.025f,
            true,
            new ITimerCallback() {

              @Override
              public void onTimePassed(TimerHandler pTimerHandler) {
                collisionDetect();
              }
            });

    enemyQueues =
        new TimerHandler(
            0.3f,
            true,
            new ITimerCallback() {
              @Override
              public void onTimePassed(TimerHandler pTimerHandler) {
                addEnemiesToTowerQueues();
              }
            });

    disableBackButton = false;
  }