/** Add a texture. if texture exist, it will be overwrite. */
 public Texture addTexture(String id, Texture t) {
   if (t == null) {
     return null;
   }
   textureMap.put(id, t);
   return t;
 }
 /** Add a texture region */
 public TextureRegion addTextureRegion(String id, TextureRegion t) {
   if (t == null) {
     return null;
   }
   regionMap.put(id, t);
   return t;
 }
Exemple #3
0
 public void spawnReset() {
   setHp(getMaxHp());
   mAllSkills.clear();
   mBullets.clear();
   mUnitsHeap.clear();
   mUnitsHeap.add(this);
 }
 /** add a sound */
 public Sound addSound(String id, Sound sound) {
   if (sound == null) {
     return null;
   }
   soundMap.put(id, sound);
   return sound;
 }
 @Override
 /** Dispose all the resources. */
 public void dispose() {
   super.dispose();
   for (Texture t : textureMap.values()) {
     t.dispose();
   }
   textureMap.clear();
   regionMap.clear();
   for (BitmapFont f : fontMap.values()) {
     f.dispose();
   }
   for (Sound s : soundMap.values()) {
     s.dispose();
   }
 }
 public TextureRegion[] addAnimations(String id, TextureRegion[] regions) {
   if (regions == null) {
     return null;
   }
   animationFrames.put(id, regions);
   return regions;
 }
 /** add a bitmap font */
 public BitmapFont addBitmapFont(String id, BitmapFont font) {
   if (font == null) {
     return null;
   }
   fontMap.put(id, font);
   return font;
 }
 @Override
 public void reloadScene(String s) {
   loading = true;
   SpaceScene scene = scenes.get(s);
   scene.reset();
   scene.start();
   loading = false;
 }
 @Override
 public void resize(int width, int height) {
   Iterator<SpaceScene> appIter = scenes.values();
   while (appIter.hasNext()) {
     SpaceScene app = appIter.next();
     app.resize(width, height);
   }
 }
 @Override
 public void dispose() {
   Iterator<SpaceScene> appIter = scenes.values();
   while (appIter.hasNext()) {
     SpaceScene app = appIter.next();
     app.dispose();
   }
 }
 @Override
 public void switchScene(String s) {
   // if (currentApp != null)
   // {
   //	currentApp.pause();
   // }
   Gdx.app.log("switched scene to", s);
   currentApp = scenes.get(s);
   Gdx.input.setInputProcessor(currentApp.getInputProcessor());
 }
 @Override
 public void create() {
   Iterator<SpaceScene> appIter = scenes.values();
   while (appIter.hasNext()) {
     SpaceScene app = appIter.next();
     app.create();
   }
   reloadScene("main menu");
   switchScene("main menu");
 }
Exemple #13
0
  public void act(float delta) {
    mTime += delta;
    getAttackBounds().set(getX() - getWidth() / 2, getY(), getWidth(), getHeight());

    for (Iterator<SkillItem> it = mAllSkills.values().iterator(); it.hasNext(); ) {
      SkillItem skill = it.next();
      if (mTime >= skill.getCooldownFinish()) {
        skill.resetCooldown();
      }
      skill.getInfo().act(skill, delta);
    }

    mUnitsHeap.act(this);
  }
Exemple #14
0
  @Override
  public void draw(Batch batch, float parentAlpha) {
    ArrayMap<Texture, Integer> layers = new ArrayMap<Texture, Integer>();
    float[][] offsets = {
      {mHeight, 0},
      {290, 0},
      {130, 50},
      {100, 50},
      {100, -30}
    };

    layers.put(mSky, 16);
    layers.put(mFarGround, 14);
    layers.put(mMiddleGround, 12);
    layers.put(mNearGround, 10);
    layers.put(mGrass, 1);

    //        Gdx.app.log(TAG, "pos " + mPosition + " scale " + mScale);

    int i = 0;
    Iterator<ObjectMap.Entry<Texture, Integer>> iter = layers.iterator();

    while (iter.hasNext()) {
      ObjectMap.Entry<Texture, Integer> next = iter.next();

      float top = offsets[i][1];
      float pos = mPosition / 10000 * next.value;
      float delta = pos >= 0 ? -mWidth * (pos - (int) pos) : -mWidth - mWidth * (pos - (int) pos);

      batch.draw(next.key, delta - mWidth, top, mWidth, offsets[i][0]);

      batch.draw(next.key, delta, top, mWidth, offsets[i][0]);

      batch.draw(next.key, delta + mWidth, top, mWidth, offsets[i][0]);

      batch.draw(next.key, delta + mWidth * 2, top, mWidth, offsets[i][0]);

      if (i == 0) {
        batch.draw(next.key, delta - mWidth, -200, mWidth * 4, 200, 0, 1, 1, 0.99f);
      }

      i++;
    }
  }
 public AlienShooter() {
   scenes = new ArrayMap<String, SpaceScene>();
   scenes.put("game", new SpaceGame(this));
   scenes.put("main menu", new MainMenu(this));
   scenes.put("training", new TrainingMenu(this));
 }
Exemple #16
0
 public void remove() {
   index--;
   map.removeIndex(index);
 }
 /** Return the texture with this id. return ull if not exist. */
 public Texture getTexture(String id) {
   return textureMap.get(id);
 }
 /** get a sound */
 public Sound getSound(String id) {
   return soundMap.get(id);
 }
Exemple #19
0
 public void addSkillItem(SkillItem skill) {
   skill.setTower(this);
   skill.resetCooldown();
   mAllSkills.put(skill.getInfo(), skill);
   skill.getInfo().initTower(skill, this);
 }
 /** get a bitmap font */
 public BitmapFont getBitmapFont(String id) {
   return fontMap.get(id);
 }
Exemple #21
0
 public SkillItem getBulletSkill(AbstractSkillEntity workerClass) {
   return mAllSkills.get(workerClass);
 }
 /** Create a sprite using a texture region. If texture region do not exist, then return null. */
 public Sprite createSprite(String id) {
   TextureRegion region = regionMap.get(id);
   return region == null ? null : new Sprite(region);
 }
 /** Return the texture region of this id. return null if do not exist. */
 public TextureRegion getTextureRegion(String id) {
   return regionMap.get(id);
 }
  public BulletInfoManager() {
    mReader = new JsonReader();
    mLogics = new ArrayMap<Class<? extends AbstractLogic>, AbstractLogic>();

    mLoaders = new ArrayMap<String, AbstractLoader>();
    mLoaders.put("attack_damage", new AttackDamage());
    mLoaders.put("attack_distance", new AttackDistance());
    mLoaders.put("attack_time", new AttackTime());
    mLoaders.put("construction_time", new ConstructionTime());
    mLoaders.put("cost", new Cost());
    mLoaders.put("icon", new Icon());
    mLoaders.put("level_ups", new LevelUps());
    mLoaders.put("max_hp", new MaxHp());
    mLoaders.put("max_target_count", new MaxTargetCount());
    mLoaders.put("move_speed", new MoveSpeed());
    mLoaders.put("title", new Title());
    mLoaders.put("height", new Height());
  }
 public TextureRegion[] getAnimationFrames(String id) {
   return animationFrames.get(id);
 }