Пример #1
0
 /** 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;
 }
Пример #2
0
 /** Add a texture region */
 public TextureRegion addTextureRegion(String id, TextureRegion t) {
   if (t == null) {
     return null;
   }
   regionMap.put(id, t);
   return t;
 }
Пример #3
0
 public void spawnReset() {
   setHp(getMaxHp());
   mAllSkills.clear();
   mBullets.clear();
   mUnitsHeap.clear();
   mUnitsHeap.add(this);
 }
Пример #4
0
 /** add a sound */
 public Sound addSound(String id, Sound sound) {
   if (sound == null) {
     return null;
   }
   soundMap.put(id, sound);
   return sound;
 }
Пример #5
0
 @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();
   }
 }
Пример #6
0
 public TextureRegion[] addAnimations(String id, TextureRegion[] regions) {
   if (regions == null) {
     return null;
   }
   animationFrames.put(id, regions);
   return regions;
 }
Пример #7
0
 /** add a bitmap font */
 public BitmapFont addBitmapFont(String id, BitmapFont font) {
   if (font == null) {
     return null;
   }
   fontMap.put(id, font);
   return font;
 }
Пример #8
0
 @Override
 public void reloadScene(String s) {
   loading = true;
   SpaceScene scene = scenes.get(s);
   scene.reset();
   scene.start();
   loading = false;
 }
Пример #9
0
 @Override
 public void resize(int width, int height) {
   Iterator<SpaceScene> appIter = scenes.values();
   while (appIter.hasNext()) {
     SpaceScene app = appIter.next();
     app.resize(width, height);
   }
 }
Пример #10
0
 @Override
 public void dispose() {
   Iterator<SpaceScene> appIter = scenes.values();
   while (appIter.hasNext()) {
     SpaceScene app = appIter.next();
     app.dispose();
   }
 }
Пример #11
0
 @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());
 }
Пример #12
0
 @Override
 public void create() {
   Iterator<SpaceScene> appIter = scenes.values();
   while (appIter.hasNext()) {
     SpaceScene app = appIter.next();
     app.create();
   }
   reloadScene("main menu");
   switchScene("main menu");
 }
Пример #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);
  }
Пример #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++;
    }
  }
Пример #15
0
 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));
 }
Пример #16
0
 public void remove() {
   index--;
   map.removeIndex(index);
 }
Пример #17
0
 /** Return the texture with this id. return ull if not exist. */
 public Texture getTexture(String id) {
   return textureMap.get(id);
 }
Пример #18
0
 /** get a sound */
 public Sound getSound(String id) {
   return soundMap.get(id);
 }
Пример #19
0
 public void addSkillItem(SkillItem skill) {
   skill.setTower(this);
   skill.resetCooldown();
   mAllSkills.put(skill.getInfo(), skill);
   skill.getInfo().initTower(skill, this);
 }
Пример #20
0
 /** get a bitmap font */
 public BitmapFont getBitmapFont(String id) {
   return fontMap.get(id);
 }
Пример #21
0
 public SkillItem getBulletSkill(AbstractSkillEntity workerClass) {
   return mAllSkills.get(workerClass);
 }
Пример #22
0
 /** 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);
 }
Пример #23
0
 /** Return the texture region of this id. return null if do not exist. */
 public TextureRegion getTextureRegion(String id) {
   return regionMap.get(id);
 }
Пример #24
0
  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());
  }
Пример #25
0
 public TextureRegion[] getAnimationFrames(String id) {
   return animationFrames.get(id);
 }