v2.0.0: improved gameplay logic for wandmaker ritual quest

This commit is contained in:
Evan Debenham
2022-12-01 17:22:37 -05:00
parent e757d3a17f
commit 2998f1cab7
@@ -31,9 +31,13 @@ import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle; import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.shatteredpixel.shatteredpixeldungeon.items.Heap; import com.shatteredpixel.shatteredpixeldungeon.items.Heap;
import com.shatteredpixel.shatteredpixeldungeon.items.Item; import com.shatteredpixel.shatteredpixeldungeon.items.Item;
import com.shatteredpixel.shatteredpixeldungeon.levels.RegularLevel;
import com.shatteredpixel.shatteredpixeldungeon.levels.rooms.standard.RitualSiteRoom;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSpriteSheet;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
import com.watabou.noosa.particles.Emitter;
import com.watabou.utils.Bundle;
import com.watabou.utils.PathFinder; import com.watabou.utils.PathFinder;
import com.watabou.utils.Random; import com.watabou.utils.Random;
@@ -67,35 +71,100 @@ public class CeremonialCandle extends Item {
@Override @Override
public void doDrop(Hero hero) { public void doDrop(Hero hero) {
super.doDrop(hero); super.doDrop(hero);
aflame = false;
checkCandles(); checkCandles();
} }
@Override @Override
protected void onThrow(int cell) { protected void onThrow(int cell) {
super.onThrow(cell); super.onThrow(cell);
aflame = false;
checkCandles(); checkCandles();
} }
@Override
public boolean doPickUp(Hero hero, int pos) {
if (super.doPickUp(hero, pos)){
aflame = false;
return true;
}
return false;
}
public boolean aflame = false;
public static String AFLAME = "aflame";
@Override
public void storeInBundle(Bundle bundle) {
super.storeInBundle(bundle);
bundle.put(AFLAME, aflame);
}
@Override
public void restoreFromBundle(Bundle bundle) {
super.restoreFromBundle(bundle);
aflame = bundle.getBoolean(AFLAME);
}
@Override
public Emitter emitter() {
if (aflame) {
Emitter emitter = new Emitter();
emitter.pos(6, 0);
emitter.fillTarget = false;
emitter.pour(ElmoParticle.FACTORY, 0.25f);
return emitter;
}
return super.emitter();
}
private static void checkCandles(){ private static void checkCandles(){
Heap heapTop = Dungeon.level.heaps.get(ritualPos - Dungeon.level.width()); if (!(Dungeon.level instanceof RegularLevel)){
Heap heapRight = Dungeon.level.heaps.get(ritualPos + 1); return;
Heap heapBottom = Dungeon.level.heaps.get(ritualPos + Dungeon.level.width()); }
Heap heapLeft = Dungeon.level.heaps.get(ritualPos - 1);
if (heapTop != null && if (!(((RegularLevel) Dungeon.level).room(ritualPos) instanceof RitualSiteRoom)){
heapRight != null && return;
heapBottom != null && }
heapLeft != null){
if (heapTop.peek() instanceof CeremonialCandle && Heap[] candleHeaps = new Heap[4];
heapRight.peek() instanceof CeremonialCandle &&
heapBottom.peek() instanceof CeremonialCandle &&
heapLeft.peek() instanceof CeremonialCandle){
heapTop.pickUp(); candleHeaps[0] = Dungeon.level.heaps.get(ritualPos - Dungeon.level.width());
heapRight.pickUp(); candleHeaps[1] = Dungeon.level.heaps.get(ritualPos + 1);
heapBottom.pickUp(); candleHeaps[2] = Dungeon.level.heaps.get(ritualPos + Dungeon.level.width());
heapLeft.pickUp(); candleHeaps[3] = Dungeon.level.heaps.get(ritualPos - 1);
boolean allCandles = true;
for (Heap h : candleHeaps){
if (h != null && h.type == Heap.Type.HEAP){
boolean foundCandle = false;
for (Item i : h.items){
if (i instanceof CeremonialCandle){
if (!((CeremonialCandle) i).aflame) {
((CeremonialCandle) i).aflame = true;
h.sprite.view(h).place(h.pos);
}
foundCandle = true;
}
}
if (!foundCandle){
allCandles = false;
}
} else {
allCandles = false;
}
}
if (allCandles){
for (Heap h : candleHeaps) {
for (Item i : h.items.toArray(new Item[0])){
if (i instanceof CeremonialCandle){
h.remove(i);
}
}
}
Elemental.NewbornFireElemental elemental = new Elemental.NewbornFireElemental(); Elemental.NewbornFireElemental elemental = new Elemental.NewbornFireElemental();
Char ch = Actor.findChar( ritualPos ); Char ch = Actor.findChar( ritualPos );
@@ -123,7 +192,6 @@ public class CeremonialCandle extends Item {
} }
Sample.INSTANCE.play(Assets.Sounds.BURNING); Sample.INSTANCE.play(Assets.Sounds.BURNING);
} }
}
} }
} }