v0.2.4: Switched to Watabou's much more elegant logic for items falling between floors
This commit is contained in:
@@ -18,8 +18,11 @@
|
||||
package com.shatteredpixel.shatteredpixeldungeon.scenes;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.*;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Honeypot;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.LootIndicator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.ui.ResumeIndicator;
|
||||
import com.watabou.noosa.Camera;
|
||||
@@ -306,7 +309,24 @@ public class GameScene extends PixelScene {
|
||||
break;
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
ArrayList<Item> dropped = Dungeon.droppedItems.get( Dungeon.depth );
|
||||
if (dropped != null) {
|
||||
for (Item item : dropped) {
|
||||
int pos = Dungeon.level.randomRespawnCell();
|
||||
if (item instanceof Potion) {
|
||||
((Potion)item).shatter( pos );
|
||||
} else if (item instanceof Plant.Seed) {
|
||||
Dungeon.level.plant( (Plant.Seed)item, pos );
|
||||
} else if (item instanceof Honeypot) {
|
||||
(Honeypot)item.shatter( pos );
|
||||
} else {
|
||||
Dungeon.level.drop( item, pos );
|
||||
}
|
||||
}
|
||||
Dungeon.droppedItems.remove( Dungeon.depth );
|
||||
}
|
||||
|
||||
Camera.main.target = hero;
|
||||
fadeIn();
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@ import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Statistics;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Generator;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.potions.Potion;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.levels.Level;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndError;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndStory;
|
||||
@@ -35,7 +33,6 @@ import com.watabou.noosa.audio.Sample;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class InterlevelScene extends PixelScene {
|
||||
|
||||
@@ -212,9 +209,6 @@ public class InterlevelScene extends PixelScene {
|
||||
|
||||
private void descend() throws IOException {
|
||||
|
||||
Level level;
|
||||
ArrayList<Item> fallingItems = new ArrayList<Item>();
|
||||
|
||||
Actor.fixTime();
|
||||
if (Dungeon.hero == null) {
|
||||
Dungeon.init();
|
||||
@@ -223,64 +217,31 @@ public class InterlevelScene extends PixelScene {
|
||||
noStory = false;
|
||||
}
|
||||
} else {
|
||||
level = Dungeon.level;
|
||||
|
||||
fallingItems = level.fallingItems;
|
||||
level.fallingItems = new ArrayList<Item>();
|
||||
|
||||
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 IOException {
|
||||
|
||||
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() );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user