コード例 #1
0
  public static void reallyDie(Object cause) {

    int length = Level.LENGTH;
    int[] map = Dungeon.level.map;
    boolean[] visited = Dungeon.level.visited;
    boolean[] discoverable = Level.discoverable;

    for (int i = 0; i < length; i++) {

      int terr = map[i];

      if (discoverable[i]) {

        visited[i] = true;
        if ((Terrain.flags[terr] & Terrain.SECRET) != 0) {
          Level.set(i, Terrain.discover(terr));
          GameScene.updateMap(i);
        }
      }
    }

    Bones.leave();

    Dungeon.observe();

    Dungeon.hero.belongings.identify();

    GameScene.gameOver();

    if (cause instanceof Hero.Doom) {
      ((Hero.Doom) cause).onDeath();
    }

    Dungeon.deleteGame(Dungeon.hero.heroClass, true);
  }
コード例 #2
0
  @Override
  public void onMotionComplete() {
    Dungeon.observe();
    search(false);

    super.onMotionComplete();
  }
コード例 #3
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));
    }
  }
コード例 #4
0
  @Override
  public boolean attack(Char enemy) {

    for (int i = 1; i < Ballistica.distance; i++) {

      int pos = Ballistica.trace[i];

      Char ch = Actor.findChar(pos);
      if (ch == null) {
        continue;
      }

      if (hit(this, ch, true)) {
        ch.damage(Random.NormalIntRange(14, 20), this);

        if (Dungeon.visible[pos]) {
          ch.getSprite().flash();
          CellEmitter.center(pos).burst(PurpleParticle.BURST, Random.IntRange(1, 2));
        }

        if (!ch.isAlive() && ch == Dungeon.hero) {
          Dungeon.fail(
              Utils.format(ResultDescriptions.MOB, Utils.indefinite(getName()), Dungeon.depth));
          GLog.n(TXT_DEATHGAZE_KILLED, getName());
        }
      } else {
        ch.getSprite().showStatus(CharSprite.NEUTRAL, ch.defenseVerb());
      }
    }

    return true;
  }
コード例 #5
0
ファイル: Amulet.java プロジェクト: RomanitoX/pixel-dungeon
 private void showAmuletScene(boolean showText) {
   try {
     Dungeon.saveAll();
     AmuletScene.noText = !showText;
     Game.switchScene(AmuletScene.class);
   } catch (IOException e) {
   }
 }
コード例 #6
0
ファイル: Shadows.java プロジェクト: RomanitoX/pixel-dungeon
 @Override
 public boolean attachTo(Char target) {
   if (super.attachTo(target)) {
     Sample.INSTANCE.play(Assets.SND_MELD);
     Dungeon.observe();
     return true;
   } else {
     return false;
   }
 }
コード例 #7
0
  public static void paint(Level level, Room room) {

    Integer traps[] = {
      Terrain.TOXIC_TRAP,
      Terrain.TOXIC_TRAP,
      Terrain.TOXIC_TRAP,
      Terrain.PARALYTIC_TRAP,
      Terrain.PARALYTIC_TRAP,
      !Dungeon.bossLevel(Dungeon.depth + 1) ? Terrain.CHASM : Terrain.SUMMONING_TRAP
    };
    fill(level, room, Terrain.WALL);
    fill(level, room, 1, Random.element(traps));

    Room.Door door = room.entrance();
    door.set(Room.Door.Type.REGULAR);

    int lastRow =
        level.map[room.left + 1 + (room.top + 1) * Level.WIDTH] == Terrain.CHASM
            ? Terrain.CHASM
            : Terrain.EMPTY;

    int x = -1;
    int y = -1;
    if (door.x == room.left) {
      x = room.right - 1;
      y = room.top + room.height() / 2;
      fill(level, x, room.top + 1, 1, room.height() - 1, lastRow);
    } else if (door.x == room.right) {
      x = room.left + 1;
      y = room.top + room.height() / 2;
      fill(level, x, room.top + 1, 1, room.height() - 1, lastRow);
    } else if (door.y == room.top) {
      x = room.left + room.width() / 2;
      y = room.bottom - 1;
      fill(level, room.left + 1, y, room.width() - 1, 1, lastRow);
    } else if (door.y == room.bottom) {
      x = room.left + room.width() / 2;
      y = room.top + 1;
      fill(level, room.left + 1, y, room.width() - 1, 1, lastRow);
    }

    int pos = x + y * Level.WIDTH;
    if (Random.Int(3) == 0) {
      if (lastRow == Terrain.CHASM) {
        set(level, pos, Terrain.EMPTY);
      }
      level.drop(prize(level), pos).type = Heap.Type.CHEST;
    } else {
      set(level, pos, Terrain.PEDESTAL);
      level.drop(prize(level), pos);
    }

    level.addItemToSpawn(new PotionOfLevitation());
  }
コード例 #8
0
 @Override
 public void onPause() {
   super.onPause();
   try {
     if (Dungeon.hero != null) {
       Dungeon.saveAll();
     }
   } catch (IOException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
コード例 #9
0
  private boolean 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.win(ResultDescriptions.WIN);
          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);
      }

      return false;

    } else if (getCloser(stairs)) {

      return true;

    } else {
      ready();
      return false;
    }
  }
コード例 #10
0
  private boolean actMove(HeroAction.Move action) {

    if (getCloser(action.dst)) {

      return true;

    } else {
      if (Dungeon.level.map[pos] == Terrain.SIGN) {
        GameScene.show(new WndMessage(Dungeon.tip()));
      }
      ready();
      return false;
    }
  }
コード例 #11
0
  private boolean getCloser(final int target) {

    if (rooted) {
      return false;
    }

    int step = -1;

    if (Level.adjacent(pos, target)) {

      if (Actor.findChar(target) == null) {
        if (Level.pit[target] && !flying && !Chasm.jumpConfirmed) {
          Chasm.heroJump(this);
          interrupt();
          return false;
        }
        if (Level.passable[target] || Level.avoid[target]) {
          step = target;
        }
      }

    } else {

      int len = Level.LENGTH;
      boolean[] p = Level.passable;
      boolean[] v = Dungeon.level.visited;
      boolean[] m = Dungeon.level.mapped;
      boolean[] passable = new boolean[len];
      for (int i = 0; i < len; i++) {
        passable[i] = p[i] && (v[i] || m[i]);
      }

      step = Dungeon.findPath(this, pos, target, passable, Level.fieldOfView);
    }

    if (step != -1) {

      int oldPos = pos;
      move(step);
      sprite.move(oldPos, pos);
      spend(1 / speed());

      return true;

    } else {

      return false;
    }
  }
コード例 #12
0
ファイル: Shadows.java プロジェクト: RomanitoX/pixel-dungeon
 @Override
 public void detach() {
   super.detach();
   Dungeon.observe();
 }