v3.3.0: implemented basic inventory storage/retrieval for the new quest
This commit is contained in:
@@ -69,6 +69,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.PrisonLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.SewerBossLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.SewerLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.VaultLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.special.SpecialRoom;
|
||||
@@ -360,6 +361,12 @@ public class Dungeon {
|
||||
case 14:
|
||||
level = new MiningLevel();
|
||||
break;
|
||||
case 16:
|
||||
case 17:
|
||||
case 18:
|
||||
case 19:
|
||||
level = new VaultLevel();
|
||||
break;
|
||||
default:
|
||||
level = new DeadEndLevel();
|
||||
}
|
||||
|
||||
@@ -184,9 +184,11 @@ public class Belongings implements Iterable<Item> {
|
||||
bundle.put( RING, ring );
|
||||
bundle.put( SECOND_WEP, secondWep );
|
||||
}
|
||||
|
||||
public static boolean bundleRestoring = false;
|
||||
|
||||
public void restoreFromBundle( Bundle bundle ) {
|
||||
|
||||
bundleRestoring = true;
|
||||
backpack.clear();
|
||||
backpack.restoreFromBundle( bundle );
|
||||
|
||||
@@ -207,6 +209,18 @@ public class Belongings implements Iterable<Item> {
|
||||
|
||||
secondWep = (KindOfWeapon) bundle.get(SECOND_WEP);
|
||||
if (secondWep() != null) secondWep().activate(owner);
|
||||
|
||||
bundleRestoring = false;
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
//TODO probably more needed here, what about buffs from these items? e.g. chargers
|
||||
backpack.clear();
|
||||
weapon = secondWep = null;
|
||||
armor = null;
|
||||
artifact = null;
|
||||
misc = null;
|
||||
ring = null;
|
||||
}
|
||||
|
||||
public static void preview( GamesInProgress.Info info, Bundle bundle ) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Blindness;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Degrade;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Belongings;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
@@ -612,8 +613,8 @@ public class Item implements Bundlable {
|
||||
|
||||
cursed = bundle.getBoolean( CURSED );
|
||||
|
||||
//only want to populate slot on first load.
|
||||
if (Dungeon.hero == null) {
|
||||
//only want to populate slots when restoring belongings
|
||||
if (Belongings.bundleRestoring) {
|
||||
if (bundle.contains(QUICKSLOT)) {
|
||||
Dungeon.quickslot.setSlot(bundle.getInt(QUICKSLOT), this);
|
||||
}
|
||||
|
||||
@@ -30,8 +30,10 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.VaultLevel;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.InterlevelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.QuickSlotButton;
|
||||
import com.watabou.noosa.Game;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -65,6 +67,8 @@ public class EscapeCrystal extends Item {
|
||||
|
||||
Sample.INSTANCE.play(Assets.Sounds.TELEPORT);
|
||||
|
||||
restoreHeroBelongings(hero);
|
||||
|
||||
Level.beforeTransition();
|
||||
InterlevelScene.curTransition = new LevelTransition(Dungeon.level,
|
||||
hero.pos,
|
||||
@@ -82,6 +86,46 @@ public class EscapeCrystal extends Item {
|
||||
|
||||
}
|
||||
|
||||
public static String BELONGINGS = "belongings";
|
||||
public static String QUICKSLOTS = "quickslots";
|
||||
public static String GOLD = "gold";
|
||||
public static String ENERGY = "energy";
|
||||
|
||||
public void storeHeroBelongings( Hero hero ){
|
||||
storedItems = new Bundle();
|
||||
|
||||
Bundle belongings = new Bundle();
|
||||
hero.belongings.storeInBundle(belongings);
|
||||
storedItems.put(BELONGINGS, belongings);
|
||||
|
||||
Bundle quickslots = new Bundle();
|
||||
Dungeon.quickslot.storePlaceholders(quickslots);
|
||||
storedItems.put(QUICKSLOTS, quickslots);
|
||||
|
||||
storedItems.put(GOLD, Dungeon.gold);
|
||||
storedItems.put(ENERGY, Dungeon.energy);
|
||||
|
||||
Dungeon.quickslot.reset();
|
||||
QuickSlotButton.reset();
|
||||
Dungeon.gold = Dungeon.energy = 0;
|
||||
hero.belongings.clear();
|
||||
}
|
||||
|
||||
public void restoreHeroBelongings( Hero hero ){
|
||||
hero.belongings.clear();
|
||||
|
||||
Dungeon.quickslot.reset();
|
||||
Dungeon.quickslot.restorePlaceholders(storedItems.getBundle(QUICKSLOTS));
|
||||
QuickSlotButton.reset();
|
||||
|
||||
Dungeon.hero.belongings.restoreFromBundle(storedItems.getBundle(BELONGINGS));
|
||||
|
||||
Dungeon.gold = storedItems.getInt(GOLD);
|
||||
Dungeon.energy = storedItems.getInt(ENERGY);
|
||||
|
||||
storedItems = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpgradable() {
|
||||
return false;
|
||||
@@ -92,4 +136,19 @@ public class EscapeCrystal extends Item {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Bundle storedItems;
|
||||
|
||||
public static String STORED_ITEMS = "stored_items";
|
||||
|
||||
@Override
|
||||
public void storeInBundle(Bundle bundle) {
|
||||
super.storeInBundle(bundle);
|
||||
bundle.put(STORED_ITEMS, storedItems);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreFromBundle(Bundle bundle) {
|
||||
super.restoreFromBundle(bundle);
|
||||
storedItems = bundle.getBundle(STORED_ITEMS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Imp;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.armor.ClothArmor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.EscapeCrystal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.CityPainter;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.painters.Painter;
|
||||
@@ -148,6 +150,11 @@ public class CityLevel extends RegularLevel {
|
||||
@Override
|
||||
protected void onSelect(int index) {
|
||||
if (index == 0){
|
||||
EscapeCrystal crystal = new EscapeCrystal();
|
||||
crystal.storeHeroBelongings(Dungeon.hero);
|
||||
crystal.collect();
|
||||
Dungeon.hero.belongings.armor = new ClothArmor();
|
||||
Dungeon.hero.belongings.armor.identify();
|
||||
CityLevel.super.activateTransition(hero, transition);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ package com.shatteredpixel.shatteredpixeldungeon.levels;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.quest.EscapeCrystal;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.features.LevelTransition;
|
||||
|
||||
public class VaultLevel extends DeadEndLevel { //for now
|
||||
@@ -49,8 +48,6 @@ public class VaultLevel extends DeadEndLevel { //for now
|
||||
|
||||
int entrance = 5 * width() + 5 / 2 + 1;
|
||||
map[entrance] = Terrain.WATER; //override entrance tile
|
||||
|
||||
drop(new EscapeCrystal(), entrance - 2*width);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user