use of com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Belongings method restoreFromBundle.
public void restoreFromBundle(Bundle bundle) {
// moving keys to Notes, for pre-0.6.1 saves
if (bundle.contains("ironKeys")) {
int[] ironKeys = bundle.getIntArray("ironKeys");
for (int i = 0; i < ironKeys.length; i++) {
if (ironKeys[i] > 0) {
Notes.add((Key) new IronKey(i).quantity(ironKeys[i]));
}
}
}
if (bundle.contains("specialKeys")) {
int[] specialKeys = bundle.getIntArray("specialKeys");
for (int i = 0; i < specialKeys.length; i++) {
if (specialKeys[i] > 0) {
if (i % 5 == 0) {
Notes.add((Key) new SkeletonKey(i).quantity(specialKeys[i]));
} else {
Notes.add((Key) new GoldenKey(i).quantity(specialKeys[i]));
}
}
}
}
backpack.clear();
backpack.restoreFromBundle(bundle);
weapon = (KindOfWeapon) bundle.get(WEAPON);
if (weapon != null) {
weapon.activate(owner);
}
armor = (Armor) bundle.get(ARMOR);
if (armor != null) {
armor.activate(owner);
}
misc1 = (KindofMisc) bundle.get(MISC1);
if (misc1 != null) {
misc1.activate(owner);
}
misc2 = (KindofMisc) bundle.get(MISC2);
if (misc2 != null) {
misc2.activate(owner);
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method actUnlock.
private boolean actUnlock(HeroAction.Unlock action) {
int doorCell = action.dst;
if (Dungeon.level.adjacent(pos, doorCell)) {
boolean hasKey = false;
int door = Dungeon.level.map[doorCell];
if (door == Terrain.LOCKED_DOOR && Notes.keyCount(new IronKey(Dungeon.depth)) > 0) {
hasKey = true;
} else if (door == Terrain.LOCKED_EXIT && Notes.keyCount(new SkeletonKey(Dungeon.depth)) > 0) {
hasKey = true;
}
if (hasKey) {
spend(Key.TIME_TO_UNLOCK);
sprite.operate(doorCell);
Sample.INSTANCE.play(Assets.SND_UNLOCK);
} else {
GLog.w(Messages.get(this, "locked_door"));
ready();
}
return false;
} else if (getCloser(doorCell)) {
return true;
} else {
ready();
return false;
}
}
use of com.shatteredpixel.shatteredpixeldungeon.items.keys.IronKey in project shattered-pixel-dungeon-gdx by 00-Evan.
the class Hero method onOperateComplete.
@Override
public void onOperateComplete() {
if (curAction instanceof HeroAction.Unlock) {
int doorCell = ((HeroAction.Unlock) curAction).dst;
int door = Dungeon.level.map[doorCell];
if (door == Terrain.LOCKED_DOOR) {
Notes.remove(new IronKey(Dungeon.depth));
Level.set(doorCell, Terrain.DOOR);
} else {
Notes.remove(new SkeletonKey(Dungeon.depth));
Level.set(doorCell, Terrain.UNLOCKED_EXIT);
}
GameScene.updateKeyDisplay();
Level.set(doorCell, door == Terrain.LOCKED_DOOR ? Terrain.DOOR : Terrain.UNLOCKED_EXIT);
GameScene.updateMap(doorCell);
} else if (curAction instanceof HeroAction.OpenChest) {
Heap heap = Dungeon.level.heaps.get(((HeroAction.OpenChest) curAction).dst);
if (heap.type == Type.SKELETON || heap.type == Type.REMAINS) {
Sample.INSTANCE.play(Assets.SND_BONES);
} else if (heap.type == Type.LOCKED_CHEST) {
Notes.remove(new GoldenKey(Dungeon.depth));
} else if (heap.type == Type.CRYSTAL_CHEST) {
Notes.remove(new CrystalKey(Dungeon.depth));
}
GameScene.updateKeyDisplay();
heap.open(this);
}
curAction = null;
super.onOperateComplete();
}
Aggregations