예제 #1
0
  protected void wandEffect(final int cell) {
    setKnown();

    QuickSlot.target(curItem, Actor.findChar(cell));

    if (curCharges > 0) {

      getCurUser().busy();

      fx(
          cell,
          new Callback() {
            @Override
            public void call() {
              onZap(cell);
              wandUsed();
            }
          });

      Invisibility.dispel(getCurUser());
    } else {

      getCurUser().spendAndNext(TIME_TO_ZAP);
      GLog.w(TXT_FIZZLES);
      levelKnown = true;

      if (Random.Int(5) == 0) {
        identify();
      }

      updateQuickslot();
    }
  }
  @Override
  public void selectKind(int kind) {
    this.kind = kind;
    JSONObject json = defMap.get(name);

    try {
      texture(json.getString("texture"));

      int width = json.getInt("width");

      TextureFilm film = new TextureFilm(texture, width, json.getInt("height"));

      bloodColor = json.optInt("bloodColor", 0xFFBB0000);
      levitating = json.optBoolean("levitating", false);
      framesInRow = texture.width / width;

      idle = readAnimation(json, "idle", film);
      run = readAnimation(json, "run", film);
      attack = readAnimation(json, "attack", film);
      die = readAnimation(json, "die", film);
      zap = attack.clone();

    } catch (Exception e) {
      GLog.w("Something bad happens when loading %s", name);
    }

    play(idle);
  }
예제 #3
0
  @Override
  public boolean doEquip(Hero hero) {

    if (hero.belongings.ring1 != null && hero.belongings.ring2 != null) {

      GLog.w(Game.getVar(R.string.Ring_Info1));
      return false;

    } else {

      if (hero.belongings.ring1 == null) {
        hero.belongings.ring1 = this;
      } else {
        hero.belongings.ring2 = this;
      }

      detach(hero.belongings.backpack);

      activate(hero);

      cursedKnown = true;
      if (cursed) {
        equipCursed(hero);
        GLog.n(String.format(Game.getVar(R.string.Ring_Info2), this));
      }

      hero.spendAndNext(Artifact.TIME_TO_EQUIP);
      return true;
    }
  }
예제 #4
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;
    }
  }
예제 #5
0
  public Item upgrade(boolean enchant) {
    if (enchantment != null) {
      if (!enchant && Random.Int(level) > 0) {
        GLog.w(TXT_INCOMPATIBLE);
        enchant(null);
      }
    } else {
      if (enchant) {
        enchant(Enchantment.random());
      }
    }

    return super.upgrade();
  }
예제 #6
0
  @Override
  public void execute(Hero hero, String action) {
    if (action.equals(AC_READ)) {

      if (hero.buff(Blindness.class) != null) {
        GLog.w(TXT_BLINDED);
      } else {
        curUser = hero;
        curItem = detach(hero.belongings.backpack);
        doRead();
      }

    } else {

      super.execute(hero, action);
    }
  }
예제 #7
0
  private void inscribeArmor(Armor armor) {

    detach(getCurUser().belongings.backpack);

    Class<? extends Armor.Glyph> oldGlyphClass =
        armor.glyph != null ? armor.glyph.getClass() : null;
    Armor.Glyph glyph = Armor.Glyph.random();
    while (glyph.getClass() == oldGlyphClass) {
      glyph = Armor.Glyph.random();
    }

    GLog.w(TXT_INSCRIBED, glyph.name(), armor.name());

    armor.inscribe(glyph);

    inscribeEffect();
  }
  @Override
  protected void onItemSelected(Item item) {

    ScrollOfRemoveCurse.uncurse(Dungeon.hero, item);

    if (item instanceof Weapon) {

      ((Weapon) item).enchant();

    } else {

      ((Armor) item).inscribe();
    }

    item.fix();

    curUser.sprite.emitter().start(Speck.factory(Speck.LIGHT), 0.1f, 5);
    Enchanting.show(curUser, item);
    GLog.w(TXT_GLOWS, item.name());
  }
예제 #9
0
  private boolean 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();
      }

      return false;

    } else if (getCloser(doorCell)) {

      return true;

    } else {
      ready();
      return false;
    }
  }
예제 #10
0
  public boolean search(boolean intentional) {

    boolean smthFound = false;

    int positive = 0;
    int negative = 0;
    for (Buff buff : buffs(RingOfDetection.Detection.class)) {
      int bonus = ((RingOfDetection.Detection) buff).level;
      if (bonus > positive) {
        positive = bonus;
      } else if (bonus < 0) {
        negative += bonus;
      }
    }
    int distance = 1 + positive + negative;

    float level = intentional ? (2 * awareness - awareness * awareness) : awareness;
    if (distance <= 0) {
      level /= 2 - distance;
      distance = 1;
    }

    int cx = pos % Level.WIDTH;
    int cy = pos / Level.WIDTH;
    int ax = cx - distance;
    if (ax < 0) {
      ax = 0;
    }
    int bx = cx + distance;
    if (bx >= Level.WIDTH) {
      bx = Level.WIDTH - 1;
    }
    int ay = cy - distance;
    if (ay < 0) {
      ay = 0;
    }
    int by = cy + distance;
    if (by >= Level.HEIGHT) {
      by = Level.HEIGHT - 1;
    }

    for (int y = ay; y <= by; y++) {
      for (int x = ax, p = ax + y * Level.WIDTH; x <= bx; x++, p++) {

        if (Dungeon.visible[p]) {

          if (intentional) {
            sprite.parent.addToBack(new CheckedCell(p));
          }

          if (Level.secret[p] && (intentional || Random.Float() < level)) {

            int oldValue = Dungeon.level.map[p];

            GameScene.discoverTile(p, oldValue);

            Level.set(p, Terrain.discover(oldValue));

            GameScene.updateMap(p);

            ScrollOfMagicMapping.discover(p);

            smthFound = true;
          }
        }
      }
    }

    if (intentional) {
      sprite.showStatus(CharSprite.DEFAULT, TXT_SEARCH);
      sprite.operate(pos);
      if (smthFound) {
        spendAndNext(Random.Float() < level ? TIME_TO_SEARCH : TIME_TO_SEARCH * 2);
      } else {
        spendAndNext(TIME_TO_SEARCH);
      }
    }

    if (smthFound) {
      GLog.w(TXT_NOTICED_SMTH);
      Sample.INSTANCE.play(Assets.SND_SECRET);
      interrupt();
    }

    return smthFound;
  }
예제 #11
0
  @Override
  public void add(Buff buff) {
    super.add(buff);

    if (sprite != null) {
      if (buff instanceof Burning) {
        GLog.w("You catch fire!");
        interrupt();
      } else if (buff instanceof Paralysis) {
        GLog.w("You are paralysed!");
        interrupt();
      } else if (buff instanceof Poison) {
        GLog.w("You are poisoned!");
        interrupt();
      } else if (buff instanceof Ooze) {
        GLog.w("Caustic ooze eats your flesh. Wash away it!");
      } else if (buff instanceof Roots) {
        GLog.w("You can't move!");
      } else if (buff instanceof Weakness) {
        GLog.w("You feel weakened!");
      } else if (buff instanceof Blindness) {
        GLog.w("You are blinded!");
      } else if (buff instanceof Fury) {
        GLog.w("You become furious!");
        sprite.showStatus(CharSprite.POSITIVE, "furious");
      } else if (buff instanceof Charm) {
        GLog.w("You are charmed!");
      } else if (buff instanceof Cripple) {
        GLog.w("You are crippled!");
      } else if (buff instanceof Bleeding) {
        GLog.w("You are bleeding!");
      } else if (buff instanceof Vertigo) {
        GLog.w("Everything is spinning around you!");
        interrupt();
      } else if (buff instanceof Light) {
        sprite.add(CharSprite.State.ILLUMINATED);
      }
    }

    BuffIndicator.refreshHero();
  }
예제 #12
0
 @Override
 protected void apply(Hero hero) {
   GLog.w(TXT_NO_SMELL);
   Buff.prolong(hero, GasesImmunity.class, GasesImmunity.DURATION);
   setKnown();
 }