示例#1
0
  public static void trigger(int pos, Char ch) {
    Integer target = pos + Random.Int(-10, 10);

    if (Level.passable[target]) {
      int cell = Ballistica.cast(Dungeon.hero.pos, target, false, true);
      if (Actor.findChar(cell) != null && cell != Dungeon.hero.pos) {
        cell = Ballistica.trace[Ballistica.distance - 2];
      }

      final int dest = cell;
      Dungeon.hero.busy();
      Dungeon.hero.sprite.jump(
          Dungeon.hero.pos,
          cell,
          new Callback() {
            @Override
            public void call() {
              Dungeon.hero.move(dest);
              Dungeon.level.press(dest, Dungeon.hero);
              Dungeon.observe();

              Camera.main.shake(2, 0.5f);
              Buff.affect(Dungeon.hero, Cripple.class, Cripple.DURATION);
            }
          });
    }
  }
示例#2
0
  @Override
  public void execute(Hero hero, String action) {

    super.execute(hero, action);

    if (action.equals(AC_EAT)) {

      switch (Random.Int(5)) {
        case 0:
          GLog.i("You see your hands turn invisible!");
          Buff.affect(hero, Invisibility.class, Invisibility.DURATION);
          break;
        case 1:
          GLog.i("You feel your skin hardens!");
          Buff.affect(hero, Barkskin.class).level(hero.HT / 4);
          break;
        case 2:
          GLog.i("Refreshing!");
          Buff.detach(hero, Poison.class);
          Buff.detach(hero, Cripple.class);
          Buff.detach(hero, Weakness.class);
          Buff.detach(hero, Bleeding.class);
          break;
        case 3:
          GLog.i("You feel better!");
          if (hero.HP < hero.HT) {
            hero.HP = Math.min(hero.HP + hero.HT / 4, hero.HT);
            hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), 1);
          }
          break;
      }
    }
  }
示例#3
0
  @Override
  public int proc(Armor armor, Char attacker, Char defender, int damage) {

    int level = Math.max(0, armor.level);

    if (Random.Int(level / 2 + 6) >= 5) {

      ArrayList<Integer> respawnPoints = new ArrayList<Integer>();

      for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
        int p = defender.pos + Level.NEIGHBOURS8[i];
        if (Actor.findChar(p) == null && (Level.passable[p] || Level.avoid[p])) {
          respawnPoints.add(p);
        }
      }

      if (respawnPoints.size() > 0) {
        MirrorImage mob = new MirrorImage();
        mob.duplicate((Hero) defender);
        GameScene.add(mob);

        defender.damage(Random.IntRange(1, defender.HT / 6), this);
        checkOwner(defender);
      }
    }

    return damage;
  }
示例#4
0
  @Override
  public int proc(Armor armor, Char attacker, Char defender, int damage) {

    int level = Math.max(0, armor.level);

    if (Random.Int(4) == 0) {

      Buff.prolong(defender, Roots.class, 5 - level / 5);
      Buff.affect(defender, Earthroot.Armor.class).level(5 * (level + 1));
      CellEmitter.bottom(defender.pos).start(EarthParticle.FACTORY, 0.05f, 8);
      Camera.main.shake(1, 0.4f);
    }

    return damage;
  }
示例#5
0
  @Override
  public int proc(Armor armor, Char attacker, Char defender, int damage) {

    int level = Math.max(0, armor.level);

    if (Level.adjacent(attacker.pos, defender.pos) && Random.Int(level + 6) >= 5) {

      Buff.prolong(attacker, Frost.class, Frost.duration(attacker) * Random.Float(1f, 1.5f));
      CellEmitter.get(attacker.pos).start(SnowParticle.FACTORY, 0.2f, 6);

      Buff.affect(defender, Burning.class).reignite(defender);
      defender.sprite.emitter().burst(FlameParticle.FACTORY, 5);
    }

    return damage;
  }
示例#6
0
  @Override
  protected void decorate() {
    for (int i = WIDTH; i < LENGTH; i++) {
      if (map[i] == Terrain.MOUNTAIN_W && map[i + 50] == Terrain.MOUNTAIN_S) {
        map[i + 50] = Terrain.MOUNTAIN_CORNER_SW;
      }
    }

    for (int i = WIDTH; i < LENGTH - WIDTH; i++) {
      if (map[i] == Terrain.MOUNTAIN_N
          && map[i + 1] == Terrain.MOUNTAIN_E
          && map[i + 51] == Terrain.MOUNTAIN_E) {
        map[i + 1] = Terrain.MOUNTAIN_CORNER_NE;
      }
    }

    for (int i = WIDTH; i < LENGTH - WIDTH; i++) {
      if (map[i] == Terrain.MOUNTAIN_N && map[i + 50] == Terrain.MOUNTAIN_W) {
        map[i] = Terrain.MOUNTAIN_CORNER_NW;
      }
    }

    for (int i = WIDTH; i < LENGTH - WIDTH; i++) {
      if (map[i] == Terrain.MOUNTAIN_S && map[i + 1] == Terrain.MOUNTAIN_W) {
        map[i + 1] = Terrain.MOUNTAIN_ELBOW_NE;
      }
    }

    for (int i = WIDTH; i < LENGTH - WIDTH; i++) {
      if (map[i] == Terrain.MOUNTAIN_S && map[i + 50] == Terrain.MOUNTAIN_E) {
        map[i] = Terrain.MOUNTAIN_ELBOW_NW;
      }
    }

    for (int i = WIDTH; i < LENGTH - WIDTH; i++) {
      if (map[i - 1] == Terrain.MOUNTAIN_N
          && map[i - 50] == Terrain.MOUNTAIN_W
          && map[i] == Terrain.EMPTY) {
        map[i] = Terrain.MOUNTAIN_ELBOW_SE;
      }
    }

    for (int i = WIDTH; i < LENGTH - WIDTH; i++) {
      if (map[i] == Terrain.MOUNTAIN_E
          && map[i - 50] == Terrain.MOUNTAIN_E
          && map[i + 1] == Terrain.MOUNTAIN_N) {
        map[i] = Terrain.MOUNTAIN_ELBOW_SW;
      }
    }

    for (int i = WIDTH; i < LENGTH; i++) {
      if (map[i] == Terrain.MOUNTAIN_E
          && map[i - 1] == Terrain.MOUNTAIN_S
          && map[i - 50] == Terrain.MOUNTAIN_E) {
        map[i] = Terrain.MOUNTAIN_CORNER_SE;
      }
    }

    for (int i = WIDTH + 1; i < LENGTH - WIDTH; i++) {
      if (map[i] == Terrain.EMPTY) {
        int n = 0;
        if (map[i + 1] == Terrain.EMPTY) {
          n++;
        }
        if (map[i - 1] == Terrain.EMPTY) {
          n++;
        }
        if (map[i + WIDTH] == Terrain.EMPTY) {
          n++;
        }
        if (map[i - WIDTH] == Terrain.EMPTY) {
          n++;
        }
        if (Random.Int(35) <= n) {
          map[i] = Terrain.PEDESTAL;
        }
      }
    }
  }