v0.2.2: falling items now appear on the next depth (potions shatter)

This commit is contained in:
Evan Debenham
2014-10-21 20:47:40 -04:00
parent 29a323ebcf
commit 3706092e7b
4 changed files with 82 additions and 10 deletions

View File

@@ -24,6 +24,13 @@ import java.util.Arrays;
import java.util.Date;
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.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
@@ -327,6 +334,22 @@ public class Dungeon {
if (respawner != null) {
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;

View File

@@ -24,6 +24,7 @@ import java.util.HashMap;
import java.util.HashSet;
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.rings.RingOfWealth;
import com.shatteredpixel.shatteredpixeldungeon.items.scrolls.ScrollOfWeaponUpgrade;
@@ -147,6 +148,9 @@ public abstract class Level implements Bundlable {
public SparseArray<Plant> plants;
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 color2 = 0x88CC44;
@@ -164,6 +168,7 @@ public abstract class Level implements Bundlable {
private static final String PLANTS = "plants";
private static final String MOBS = "mobs";
private static final String BLOBS = "blobs";
private static final String FALLING = "falling";
public void create() {
@@ -307,6 +312,8 @@ public abstract class Level implements Bundlable {
Blob blob = (Blob)b;
blobs.put( blob.getClass(), blob );
}
fallingItems = (ArrayList)bundle.getCollection( FALLING );
buildFlagMaps();
cleanWalls();
@@ -324,6 +331,7 @@ public abstract class Level implements Bundlable {
bundle.put( PLANTS, plants.values() );
bundle.put( MOBS, mobs );
bundle.put( BLOBS, blobs.values() );
bundle.put( FALLING, fallingItems);
}
public int tunnelTile() {
@@ -573,6 +581,7 @@ public abstract class Level implements Bundlable {
heap.pos = cell;
if (map[cell] == Terrain.CHASM || (Dungeon.level != null && pit[cell])) {
GameScene.discard( heap );
fallingItems.add(item);
} else {
heaps.put( cell, heap );
GameScene.add( heap );

View File

@@ -103,8 +103,7 @@ public class Chasm {
}
public static void mobFall( Mob mob ) {
// Destroy instead of kill to prevent dropping loot
mob.destroy();
mob.die( null );
((MobSprite)mob.sprite).fall();
}

View File

@@ -18,7 +18,10 @@
package com.shatteredpixel.shatteredpixeldungeon.scenes;
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.Camera;
import com.watabou.noosa.Game;
@@ -245,8 +248,18 @@ public class InterlevelScene extends PixelScene {
}
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) {
Dungeon.init();
if (noStory) {
@@ -256,29 +269,57 @@ public class InterlevelScene extends PixelScene {
} else {
Dungeon.saveLevel();
}
Level level;
if (Dungeon.depth >= Statistics.deepestFloor) {
level = Dungeon.newLevel();
} else {
Dungeon.depth++;
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 );
}
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();
Level level;
if (Dungeon.depth >= Statistics.deepestFloor) {
level = Dungeon.newLevel();
} else {
Dungeon.depth++;
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() );
}