Ejemplo n.º 1
0
  private void actUnlock(HeroAction.Unlock action) {
    int doorCell = action.dst;
    if (Level.adjacent(pos, doorCell)) {

      theKey = null;
      int door = Dungeon.level.map[doorCell];

      if (door == Terrain.LOCKED_DOOR) {

        theKey = belongings.getKey(IronKey.class, Dungeon.depth);

      } else if (door == Terrain.LOCKED_EXIT) {

        theKey = belongings.getKey(SkeletonKey.class, Dungeon.depth);
      }

      if (theKey != null) {

        spend(Key.TIME_TO_UNLOCK);
        sprite.operate(doorCell);

        Sample.INSTANCE.play(Assets.SND_UNLOCK);

      } else {
        GLog.w(TXT_LOCKED_DOOR);
        ready();
      }

    } else if (getCloser(doorCell)) {

    } else {
      ready();
    }
  }
Ejemplo n.º 2
0
  public boolean shoot(Char enemy, Weapon wep) {

    // Ugly...
    usingRanged = true;

    KindOfWeapon curWep = belongings.weapon;
    belongings.weapon = wep;

    boolean result = attack(enemy);

    belongings.weapon = curWep;
    usingRanged = false;

    return result;
  }
Ejemplo n.º 3
0
  private void actAscend(HeroAction.Ascend action) {
    int stairs = action.dst;
    if (pos == stairs && pos == Dungeon.level.entrance) {

      if (Dungeon.depth == 1) {

        if (belongings.getItem(Amulet.class) == null) {
          GameScene.show(new WndMessage(TXT_LEAVE));
          ready();
        } else {
          Dungeon.deleteGame(Dungeon.hero.heroClass, true);
          Game.switchScene(SurfaceScene.class);
        }

      } else {

        curAction = null;

        Hunger hunger = buff(Hunger.class);
        if (hunger != null && !hunger.isStarving()) {
          hunger.satisfy(-Hunger.STARVING / 10);
        }

        InterlevelScene.mode = InterlevelScene.Mode.ASCEND;
        Game.switchScene(InterlevelScene.class);
      }

    } else if (getCloser(stairs)) {

    } else {
      ready();
    }
  }
Ejemplo n.º 4
0
  @Override
  public void die(Object cause) {

    curAction = null;

    DewVial.autoDrink(this);
    if (isAlive()) {
      new Flare(8, 32).color(0xFFFF66, true).show(sprite, 2f);
      return;
    }

    Actor.fixTime();
    super.die(cause);

    Ankh ankh = (Ankh) belongings.getItem(Ankh.class);
    if (ankh == null) {

      reallyDie(cause);

    } else {

      Dungeon.deleteGame(Dungeon.hero.heroClass, false);
      GameScene.show(new WndResurrect(ankh, cause));
    }
  }
Ejemplo n.º 5
0
  public void resurrect(int resetLevel) {

    HP = HT;
    Dungeon.gold = 0;
    exp = 0;

    belongings.resurrect(resetLevel);

    live();
  }
Ejemplo n.º 6
0
  private boolean actOpenChest(HeroAction.OpenChest action) {
    int dst = action.dst;
    if (Level.adjacent(pos, dst) || pos == dst) {

      Heap heap = Dungeon.level.heaps.get(dst);
      if (heap != null
          && (heap.type == Type.CHEST
              || heap.type == Type.TOMB
              || heap.type == Type.SKELETON
              || heap.type == Type.LOCKED_CHEST
              || heap.type == Type.CRYSTAL_CHEST)) {

        theKey = null;

        if (heap.type == Type.LOCKED_CHEST || heap.type == Type.CRYSTAL_CHEST) {

          theKey = belongings.getKey(GoldenKey.class, Dungeon.depth);

          if (theKey == null) {
            GLog.w(TXT_LOCKED_CHEST);
            ready();
            return false;
          }
        }

        switch (heap.type) {
          case TOMB:
            Sample.INSTANCE.play(Assets.SND_TOMB);
            Camera.main.shake(1, 0.5f);
            break;
          case SKELETON:
            break;
          default:
            Sample.INSTANCE.play(Assets.SND_UNLOCK);
        }

        spend(Key.TIME_TO_UNLOCK);
        sprite.operate(dst);

      } else {
        ready();
      }

      return false;

    } else if (getCloser(dst)) {

      return true;

    } else {
      ready();
      return false;
    }
  }
Ejemplo n.º 7
0
  @Override
  public void storeInBundle(Bundle bundle) {
    super.storeInBundle(bundle);

    heroClass.storeInBundle(bundle);
    subClass.storeInBundle(bundle);

    bundle.put(ATTACK, attackSkill);
    bundle.put(DEFENSE, defenseSkill);

    bundle.put(STRENGTH, STR);

    bundle.put(LEVEL, lvl);
    bundle.put(EXPERIENCE, exp);

    belongings.storeInBundle(bundle);
  }
Ejemplo n.º 8
0
  @Override
  public void restoreFromBundle(Bundle bundle) {
    super.restoreFromBundle(bundle);

    heroClass = HeroClass.restoreInBundle(bundle);
    subClass = HeroSubClass.restoreInBundle(bundle);

    attackSkill = bundle.getInt(ATTACK);
    defenseSkill = bundle.getInt(DEFENSE);

    STR = bundle.getInt(STRENGTH);
    updateAwareness();

    lvl = bundle.getInt(LEVEL);
    exp = bundle.getInt(EXPERIENCE);

    belongings.restoreFromBundle(bundle);
  }