v0.2.2: falling items now appear on the next depth (potions shatter)
This commit is contained in:
@@ -24,6 +24,13 @@ import java.util.Arrays;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Fire;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ParalyticGas;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfLiquidFlame;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfParalyticGas;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfToxicGas;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
@@ -328,6 +335,22 @@ public class Dungeon {
|
|||||||
Actor.add( level.respawner() );
|
Actor.add( level.respawner() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Potion potion : level.fallingPotions){
|
||||||
|
|
||||||
|
int cell = level.randomRespawnCell();
|
||||||
|
while (cell == -1)
|
||||||
|
cell = level.randomRespawnCell();
|
||||||
|
|
||||||
|
if (potion instanceof PotionOfLiquidFlame)
|
||||||
|
GameScene.add(Blob.seed(cell, 2, Fire.class));
|
||||||
|
else if (potion instanceof PotionOfToxicGas)
|
||||||
|
GameScene.add( Blob.seed( cell, 1000, ToxicGas.class ) );
|
||||||
|
else if (potion instanceof PotionOfParalyticGas)
|
||||||
|
GameScene.add( Blob.seed( cell, 1000, ParalyticGas.class ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
level.fallingPotions.clear();
|
||||||
|
|
||||||
hero.pos = pos != -1 ? pos : level.exit;
|
hero.pos = pos != -1 ? pos : level.exit;
|
||||||
|
|
||||||
Light light = hero.buff( Light.class );
|
Light light = hero.buff( Light.class );
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
|
import com.shatteredpixel.shatteredpixeldungeon.items.food.Blandfruit;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.PotionOfMight;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
|
import com.shatteredpixel.shatteredpixeldungeon.items.rings.RingOfWealth;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfWeaponUpgrade;
|
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfWeaponUpgrade;
|
||||||
@@ -148,6 +149,9 @@ public abstract class Level implements Bundlable {
|
|||||||
|
|
||||||
protected ArrayList<Item> itemsToSpawn = new ArrayList<Item>();
|
protected ArrayList<Item> itemsToSpawn = new ArrayList<Item>();
|
||||||
|
|
||||||
|
public ArrayList<Item> fallingItems = new ArrayList<Item>();
|
||||||
|
public ArrayList<Potion> fallingPotions = new ArrayList<Potion>();
|
||||||
|
|
||||||
public int color1 = 0x004400;
|
public int color1 = 0x004400;
|
||||||
public int color2 = 0x88CC44;
|
public int color2 = 0x88CC44;
|
||||||
|
|
||||||
@@ -164,6 +168,7 @@ public abstract class Level implements Bundlable {
|
|||||||
private static final String PLANTS = "plants";
|
private static final String PLANTS = "plants";
|
||||||
private static final String MOBS = "mobs";
|
private static final String MOBS = "mobs";
|
||||||
private static final String BLOBS = "blobs";
|
private static final String BLOBS = "blobs";
|
||||||
|
private static final String FALLING = "falling";
|
||||||
|
|
||||||
public void create() {
|
public void create() {
|
||||||
|
|
||||||
@@ -308,6 +313,8 @@ public abstract class Level implements Bundlable {
|
|||||||
blobs.put( blob.getClass(), blob );
|
blobs.put( blob.getClass(), blob );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fallingItems = (ArrayList)bundle.getCollection( FALLING );
|
||||||
|
|
||||||
buildFlagMaps();
|
buildFlagMaps();
|
||||||
cleanWalls();
|
cleanWalls();
|
||||||
}
|
}
|
||||||
@@ -324,6 +331,7 @@ public abstract class Level implements Bundlable {
|
|||||||
bundle.put( PLANTS, plants.values() );
|
bundle.put( PLANTS, plants.values() );
|
||||||
bundle.put( MOBS, mobs );
|
bundle.put( MOBS, mobs );
|
||||||
bundle.put( BLOBS, blobs.values() );
|
bundle.put( BLOBS, blobs.values() );
|
||||||
|
bundle.put( FALLING, fallingItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int tunnelTile() {
|
public int tunnelTile() {
|
||||||
@@ -573,6 +581,7 @@ public abstract class Level implements Bundlable {
|
|||||||
heap.pos = cell;
|
heap.pos = cell;
|
||||||
if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
|
if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
|
||||||
GameScene.discard( heap );
|
GameScene.discard( heap );
|
||||||
|
fallingItems.add(item);
|
||||||
} else {
|
} else {
|
||||||
heaps.put( cell, heap );
|
heaps.put( cell, heap );
|
||||||
GameScene.add( heap );
|
GameScene.add( heap );
|
||||||
|
|||||||
@@ -103,8 +103,7 @@ public class Chasm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void mobFall( Mob mob ) {
|
public static void mobFall( Mob mob ) {
|
||||||
// Destroy instead of kill to prevent dropping loot
|
mob.die( null );
|
||||||
mob.destroy();
|
|
||||||
|
|
||||||
((MobSprite)mob.sprite).fall();
|
((MobSprite)mob.sprite).fall();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,10 @@
|
|||||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||||
import com.watabou.noosa.BitmapText;
|
import com.watabou.noosa.BitmapText;
|
||||||
import com.watabou.noosa.Camera;
|
import com.watabou.noosa.Camera;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
@@ -246,7 +249,17 @@ public class InterlevelScene extends PixelScene {
|
|||||||
|
|
||||||
private void descend() throws Exception {
|
private void descend() throws Exception {
|
||||||
|
|
||||||
Actor.fixTime();
|
Level level;
|
||||||
|
ArrayList<Item> fallingItems = new ArrayList<Item>();
|
||||||
|
|
||||||
|
if (Dungeon.depth > 0) {
|
||||||
|
level = Dungeon.level;
|
||||||
|
|
||||||
|
fallingItems = level.fallingItems;
|
||||||
|
level.fallingItems = new ArrayList<Item>();
|
||||||
|
}
|
||||||
|
|
||||||
|
Actor.fixTime();
|
||||||
if (Dungeon.hero == null) {
|
if (Dungeon.hero == null) {
|
||||||
Dungeon.init();
|
Dungeon.init();
|
||||||
if (noStory) {
|
if (noStory) {
|
||||||
@@ -257,28 +270,56 @@ public class InterlevelScene extends PixelScene {
|
|||||||
Dungeon.saveLevel();
|
Dungeon.saveLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
Level level;
|
|
||||||
if (Dungeon.depth >= Statistics.deepestFloor) {
|
if (Dungeon.depth >= Statistics.deepestFloor) {
|
||||||
level = Dungeon.newLevel();
|
level = Dungeon.newLevel();
|
||||||
} else {
|
} else {
|
||||||
Dungeon.depth++;
|
Dungeon.depth++;
|
||||||
level = Dungeon.loadLevel( Dungeon.hero.heroClass );
|
level = Dungeon.loadLevel( Dungeon.hero.heroClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Item item : fallingItems){
|
||||||
|
int cell = level.randomRespawnCell();
|
||||||
|
while (cell == -1)
|
||||||
|
cell = level.randomRespawnCell();
|
||||||
|
|
||||||
|
if (!(item instanceof Potion))
|
||||||
|
level.drop(item, cell);
|
||||||
|
else
|
||||||
|
level.fallingPotions.add((Potion)item);
|
||||||
|
}
|
||||||
|
|
||||||
Dungeon.switchLevel( level, level.entrance );
|
Dungeon.switchLevel( level, level.entrance );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fall() throws Exception {
|
private void fall() throws Exception {
|
||||||
|
|
||||||
Actor.fixTime();
|
Level level = Dungeon.level;
|
||||||
|
|
||||||
|
ArrayList<Item> fallingItems = level.fallingItems;
|
||||||
|
level.fallingItems = new ArrayList<Item>();
|
||||||
|
|
||||||
|
Actor.fixTime();
|
||||||
Dungeon.saveLevel();
|
Dungeon.saveLevel();
|
||||||
|
|
||||||
Level level;
|
|
||||||
if (Dungeon.depth >= Statistics.deepestFloor) {
|
if (Dungeon.depth >= Statistics.deepestFloor) {
|
||||||
level = Dungeon.newLevel();
|
level = Dungeon.newLevel();
|
||||||
} else {
|
} else {
|
||||||
Dungeon.depth++;
|
Dungeon.depth++;
|
||||||
level = Dungeon.loadLevel( Dungeon.hero.heroClass );
|
level = Dungeon.loadLevel( Dungeon.hero.heroClass );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Item item : fallingItems){
|
||||||
|
int cell = level.randomRespawnCell();
|
||||||
|
while (cell == -1)
|
||||||
|
cell = level.randomRespawnCell();
|
||||||
|
|
||||||
|
if (!(item instanceof Potion))
|
||||||
|
level.drop(item, cell);
|
||||||
|
else
|
||||||
|
level.fallingPotions.add((Potion)item);
|
||||||
|
}
|
||||||
|
|
||||||
Dungeon.switchLevel( level, fallIntoPit ? level.pitCell() : level.randomRespawnCell() );
|
Dungeon.switchLevel( level, fallIntoPit ? level.pitCell() : level.randomRespawnCell() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user