Ejemplo n.º 1
0
  public void link(Char ch) {
    this.ch = ch;
    ch.setSprite(this);

    place(ch.getPos());
    turnTo(ch.getPos(), Random.Int(Dungeon.level.getLength()));

    ch.updateSpriteState();
  }
Ejemplo n.º 2
0
  @Override
  public void onOperateComplete() {

    if (curAction instanceof HeroAction.Unlock) {

      if (theKey != null) {
        theKey.detach(belongings.backpack);
        theKey = null;
      }

      int doorCell = ((HeroAction.Unlock) curAction).dst;
      int door = Dungeon.level.map[doorCell];

      Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT);
      GameScene.updateMap(doorCell);

    } else if (curAction instanceof HeroAction.OpenChest) {

      if (theKey != null) {
        theKey.detach(belongings.backpack);
        theKey = null;
      }

      Heap heap = Dungeon.level.heaps.get(((HeroAction.OpenChest) curAction).dst);
      if (heap.type == Type.SKELETON) {
        Sample.INSTANCE.play(Assets.SND_BONES);
      }
      heap.open(this);
    }
    curAction = null;

    super.onOperateComplete();
  }
Ejemplo n.º 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));
    }
  }
Ejemplo n.º 4
0
 public void bloodBurstA(PointF from, int damage) {
   if (getVisible()) {
     PointF c = center();
     int n = (int) Math.min(9 * Math.sqrt((double) damage / ch.ht()), 9);
     Splash.at(c, PointF.angle(from, c), 3.1415926f / 2, blood(), n);
   }
 }
Ejemplo n.º 5
0
  @Override
  public void onMotionComplete() {
    Dungeon.observe();
    search(false);

    super.onMotionComplete();
  }
Ejemplo n.º 6
0
  private void hit(Char ch, int damage) {

    if (damage < 1) {
      return;
    }

    affected.add(ch);
    ch.damage(
        Level.water[ch.pos] && !ch.flying ? (int) (damage * 2) : damage, LightningTrap.LIGHTNING);

    ch.sprite.centerEmitter().burst(SparkParticle.FACTORY, 3);
    ch.sprite.flash();

    points[nPoints++] = ch.pos;

    HashSet<Char> ns = new HashSet<Char>();
    for (int i = 0; i < Level.NEIGHBOURS8.length; i++) {
      Char n = Actor.findChar(ch.pos + Level.NEIGHBOURS8[i]);
      if (n != null && !affected.contains(n)) {
        ns.add(n);
      }
    }

    if (ns.size() > 0) {
      hit(Random.element(ns), Random.Int(damage / 2, damage));
    }
  }
Ejemplo n.º 7
0
 @Override
 public void spend(float time) {
   int hasteLevel = 0;
   for (Buff buff : buffs(RingOfHaste.Haste.class)) {
     hasteLevel += ((RingOfHaste.Haste) buff).level;
   }
   super.spend(hasteLevel == 0 ? time : (float) (time * Math.pow(1.1, -hasteLevel)));
 };
Ejemplo n.º 8
0
  @Override
  public void damage(int dmg, Object src) {
    restoreHealth = false;
    super.damage(dmg, src);

    if (subClass == HeroSubClass.BERSERKER && 0 < HP && HP <= HT * Fury.LEVEL) {
      Buff.affect(this, Fury.class);
    }
  }
Ejemplo n.º 9
0
  @Override
  public void remove(Buff buff) {
    super.remove(buff);

    if (buff instanceof Light) {
      sprite.remove(CharSprite.State.ILLUMINATED);
    }

    BuffIndicator.refreshHero();
  }
Ejemplo n.º 10
0
 @Override
 public boolean attachTo(Char target) {
   if (super.attachTo(target)) {
     target.flying = true;
     Roots.detach(target, Roots.class);
     return true;
   } else {
     return false;
   }
 }
Ejemplo n.º 11
0
  public void activate(Char ch) {

    if (ch instanceof Hero && ((Hero) ch).subClass == HeroSubClass.WARDEN) {
      Buff.affect(ch, Barkskin.class).level(ch.ht() / 3);
    }

    effect(pos, ch);

    wither();
  }
Ejemplo n.º 12
0
  public void showMindControl() {
    if (emo instanceof EmoIcon.Controlled) {

    } else {
      removeEmo();

      if (ch != null && ch.isAlive()) {
        emo = new EmoIcon.Controlled(this);
      }
    }
  }
Ejemplo n.º 13
0
  public void effect(int pos, Char ch) {
    if (ch instanceof Hero) {
      Hero hero = (Hero) ch;
      ScrollOfTeleportation.teleportHero(hero);
      hero.spendAndNext(1);
      hero.curAction = null;

    } else if (ch instanceof Mob) {

      int newPos = Dungeon.level.randomRespawnCell();
      if (newPos != -1) {
        ch.setPos(newPos);
        ch.getSprite().place(ch.getPos());
        ch.getSprite().setVisible(Dungeon.visible[pos]);
      }
    }

    if (Dungeon.visible[pos]) {
      CellEmitter.get(pos).start(Speck.factory(Speck.LIGHT), 0.2f, 3);
    }
  }
Ejemplo n.º 14
0
  @Override
  public void onAttackComplete() {

    AttackIndicator.target(enemy);

    attack(enemy);
    curAction = null;

    Invisibility.dispel();

    super.onAttackComplete();
  }
Ejemplo n.º 15
0
  public void showStatus(int color, String text, Object... args) {
    if (getVisible()) {
      if (args.length > 0) {
        text = Utils.format(text, args);
      }

      if (ModdingMode.getClassicTextRenderingMode()) {
        if (ch != null) {
          FloatingText.show(x + width * 0.5f, y, ch.getPos(), text, color);
        } else {
          FloatingText.show(x + width * 0.5f, y, text, color);
        }
      } else {
        if (ch != null) {
          SystemFloatingText.show(x + width * 0.5f, y, ch.getPos(), text, color);
        } else {
          SystemFloatingText.show(x + width * 0.5f, y, text, color);
        }
      }
    }
  }
Ejemplo n.º 16
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;
  }
Ejemplo n.º 17
0
  @Override
  public void move(int step) {
    super.move(step);

    if (!flying) {

      if (Level.water[pos]) {
        Sample.INSTANCE.play(Assets.SND_WATER, 1, 1, Random.Float(0.8f, 1.25f));
      } else {
        Sample.INSTANCE.play(Assets.SND_STEP);
      }
      Dungeon.level.press(pos, this);
    }
  }
Ejemplo n.º 18
0
  @Override
  public void onComplete(Animation anim) {

    if (animCallback != null) {
      animCallback.call();
      animCallback = null;
    } else {

      if (anim == attack) {

        idle();
        ch.onAttackComplete();

      } else if (anim == zap) {
        idle();
        ch.onZapComplete();

      } else if (anim == operate) {

        idle();
        ch.onOperateComplete();
      }
    }
  }
Ejemplo n.º 19
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.º 20
0
  public void move(int from, int to) {
    play(run);

    motion = new PosTweener(this, worldToCamera(to), MOVE_INTERVAL);
    motion.listener = this;
    getParent().add(motion);

    isMoving = true;

    turnTo(from, to);

    if (getVisible() && Dungeon.level.water[from] && !ch.flying) {
      GameScene.ripple(from);
    }

    ch.onMotionComplete();
  }
Ejemplo n.º 21
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);
  }
Ejemplo n.º 22
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();
  }
Ejemplo n.º 23
0
  @Override
  public int defenseProc(Char enemy, int damage) {

    RingOfThorns.Thorns thorns = buff(RingOfThorns.Thorns.class);
    if (thorns != null) {
      int dmg = Random.IntRange(0, damage);
      if (dmg > 0) {
        enemy.damage(dmg, thorns);
      }
    }

    Earthroot.Armor armor = buff(Earthroot.Armor.class);
    if (armor != null) {
      damage = armor.absorb(damage);
    }

    if (belongings.armor != null) {
      damage = belongings.armor.proc(enemy, this, damage);
    }

    return damage;
  }
Ejemplo n.º 24
0
  public static int findPath(Char ch, int from, int to, boolean pass[], boolean[] visible) {

    if (Level.adjacent(from, to)) {
      return Actor.findChar(to) == null && (pass[to] || Level.avoid[to]) ? to : -1;
    }

    if (ch.flying || ch.buff(Amok.class) != null) {
      BArray.or(pass, Level.avoid, passable);
    } else {
      System.arraycopy(pass, 0, passable, 0, Level.LENGTH);
    }

    for (Actor actor : Actor.all()) {
      if (actor instanceof Char) {
        int pos = ((Char) actor).pos;
        if (visible[pos]) {
          passable[pos] = false;
        }
      }
    }

    return PathFinder.getStep(from, to, passable);
  }
Ejemplo n.º 25
0
  private boolean actAttack(HeroAction.Attack action) {

    enemy = action.target;

    if (Level.adjacent(pos, enemy.pos) && enemy.isAlive() && !pacified) {

      spend(attackDelay());
      sprite.attack(enemy.pos);

      return false;

    } else {

      if (Level.fieldOfView[enemy.pos] && getCloser(enemy.pos)) {

        return true;

      } else {
        ready();
        return false;
      }
    }
  }
Ejemplo n.º 26
0
  @Override
  protected void layout() {
    clear();

    SparseArray<Image> newIcons = new SparseArray<Image>();

    for (Buff buff : ch.buffs()) {
      int icon = buff.icon();
      if (icon != NONE) {
        Image img = new Image(texture);
        img.frame(film.get(icon));
        img.x = x + members.size() * (SIZE + 2);
        img.y = y;
        add(img);

        newIcons.put(icon, img);
      }
    }

    for (Integer key : icons.keyArray()) {
      if (newIcons.get(key) == null) {
        Image icon = icons.get(key);
        icon.origin.set(SIZE / 2);
        add(icon);
        add(
            new AlphaTweener(icon, 0, 0.6f) {
              @Override
              protected void updateValues(float progress) {
                super.updateValues(progress);
                image.scale.set(1 + 5 * progress);
              };
            });
      }
    }

    icons = newIcons;
  }
Ejemplo n.º 27
0
 protected void fx(int cell, Callback callback) {
   MagicMissile.blueLight(wandUser.getSprite().getParent(), wandUser.getPos(), cell, callback);
   Sample.INSTANCE.play(Assets.SND_ZAP);
 }
Ejemplo n.º 28
0
 public void zap(int cell) {
   turnTo(ch.getPos(), cell);
   play(zap);
 }
Ejemplo n.º 29
0
 public void operate(int cell) {
   turnTo(ch.getPos(), cell);
   play(operate);
 }
Ejemplo n.º 30
0
 public void attack(int cell, Callback callback) {
   animCallback = callback;
   turnTo(ch.getPos(), cell);
   play(attack);
 }