v0.7.0b: adjusted wraith spawning from bones functionality

This commit is contained in:
Evan Debenham 2018-11-03 17:31:20 -04:00
parent aec81b5917
commit e298e4671e
11 changed files with 39 additions and 12 deletions

View File

@ -63,8 +63,6 @@ import java.util.LinkedList;
public class Heap implements Bundlable {
private static final int SEEDS_TO_POTION = 3;
public enum Type {
HEAP,
FOR_SALE,
@ -82,6 +80,7 @@ public class Heap implements Bundlable {
public ItemSprite sprite;
public boolean seen = false;
public boolean haunted = false;
public LinkedList<Item> items = new LinkedList<Item>();
@ -141,6 +140,14 @@ public class Heap implements Bundlable {
default:
}
if (haunted){
if (Wraith.spawnAt( pos ) == null) {
hero.sprite.emitter().burst( ShadowParticle.CURSE, 6 );
hero.damage( hero.HP / 2, this );
}
Sample.INSTANCE.play( Assets.SND_CURSED );
}
if (type != Type.MIMIC) {
type = Type.HEAP;
ArrayList<Item> bonus = RingOfWealth.tryRareDrop(hero, 1);
@ -153,6 +160,17 @@ public class Heap implements Bundlable {
}
}
public Heap setHauntedIfCursed( float chance ){
for (Item item : items) {
if (item.cursed && Random.Float() < chance) {
haunted = true;
item.cursedKnown = true;
break;
}
}
return this;
}
public int size() {
return items.size();
}
@ -429,6 +447,7 @@ public class Heap implements Bundlable {
private static final String SEEN = "seen";
private static final String TYPE = "type";
private static final String ITEMS = "items";
private static final String HAUNTED = "haunted";
@SuppressWarnings("unchecked")
@Override
@ -449,6 +468,8 @@ public class Heap implements Bundlable {
}
}
haunted = bundle.getBoolean( HAUNTED );
}
@Override
@ -457,6 +478,7 @@ public class Heap implements Bundlable {
bundle.put( SEEN, seen );
bundle.put( TYPE, type.toString() );
bundle.put( ITEMS, items );
bundle.put( HAUNTED, haunted );
}
}

View File

@ -202,7 +202,7 @@ public class CavesBossLevel extends Level {
do {
pos = Random.IntRange( ROOM_LEFT, ROOM_RIGHT ) + Random.IntRange( ROOM_TOP + 1, ROOM_BOTTOM ) * width();
} while (pos == entrance);
drop( item, pos ).type = Heap.Type.REMAINS;
drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
}
}

View File

@ -173,7 +173,7 @@ public class CityBossLevel extends Level {
Random.IntRange( LEFT + 1, LEFT + HALL_WIDTH - 2 ) +
Random.IntRange( TOP + HALL_HEIGHT + 2, TOP + HALL_HEIGHT + CHAMBER_HEIGHT ) * width();
} while (pos == entrance);
drop( item, pos ).type = Heap.Type.REMAINS;
drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
}
}

View File

@ -163,7 +163,7 @@ public class HallsBossLevel extends Level {
do {
pos = Random.IntRange( ROOM_LEFT, ROOM_RIGHT ) + Random.IntRange( ROOM_TOP + 1, ROOM_BOTTOM ) * width();
} while (pos == entrance);
drop( item, pos ).type = Heap.Type.REMAINS;
drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
}
}

View File

@ -121,7 +121,7 @@ public class LastShopLevel extends RegularLevel {
do {
pos = pointToCell(roomEntrance.random());
} while (pos == entrance);
drop( item, pos ).type = Heap.Type.REMAINS;
drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
}
}

View File

@ -159,7 +159,7 @@ public class PrisonBossLevel extends Level {
protected void createItems() {
Item item = Bones.get();
if (item != null) {
drop( item, randomRespawnCell() ).type = Heap.Type.REMAINS;
drop( item, randomRespawnCell() ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
}
drop(new IronKey(10), randomPrisonCell());
}

View File

@ -341,7 +341,11 @@ public abstract class RegularLevel extends Level {
addItemToSpawn(new GoldenKey(Dungeon.depth));
}
} else {
drop( toDrop, cell ).type = type;
Heap dropped = drop( toDrop, cell );
dropped.type = type;
if (type == Heap.Type.SKELETON){
dropped.setHauntedIfCursed(0.75f);
}
}
}
@ -362,7 +366,7 @@ public abstract class RegularLevel extends Level {
map[cell] = Terrain.GRASS;
losBlocking[cell] = false;
}
drop( item, cell ).type = Heap.Type.REMAINS;
drop( item, cell ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
}
//guide pages

View File

@ -121,7 +121,7 @@ public class SewerBossLevel extends SewerLevel {
do {
pos = pointToCell(roomEntrance.random());
} while (pos == entrance || solid[pos]);
drop( item, pos ).type = Heap.Type.REMAINS;
drop( item, pos ).setHauntedIfCursed(1f).type = Heap.Type.REMAINS;
}
}

View File

@ -51,7 +51,7 @@ public class SecretSummoningRoom extends SecretRoom {
Painter.fill(level, this, 1, Terrain.SECRET_TRAP);
Point center = center();
level.drop(Generator.random(), level.pointToCell(center)).type = Heap.Type.SKELETON;
level.drop(Generator.random(), level.pointToCell(center)).setHauntedIfCursed(0.75f).type = Heap.Type.SKELETON;
for (Point p : getPoints()){
int cell = level.pointToCell(p);

View File

@ -89,6 +89,7 @@ public class MassGraveRoom extends SpecialRoom {
pos = level.pointToCell(random());
} while (level.map[pos] != Terrain.EMPTY_SP || level.heaps.get(pos) != null);
Heap h = level.drop(item, pos);
h.haunted = true;
h.type = Heap.Type.SKELETON;
}
}

View File

@ -81,7 +81,7 @@ public class PitRoom extends SpecialRoom {
int n = Random.IntRange( 1, 2 );
for (int i=0; i < n; i++) {
level.drop( prize( level ), remains );
level.drop( prize( level ), remains ).setHauntedIfCursed(0.75f);
}
}