v2.0.0: improved gameplay logic for wandmaker ritual quest
This commit is contained in:
+104
-36
@@ -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,62 +71,126 @@ 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);
|
||||||
|
|
||||||
Elemental.NewbornFireElemental elemental = new Elemental.NewbornFireElemental();
|
boolean allCandles = true;
|
||||||
Char ch = Actor.findChar( ritualPos );
|
for (Heap h : candleHeaps){
|
||||||
if (ch != null) {
|
if (h != null && h.type == Heap.Type.HEAP){
|
||||||
ArrayList<Integer> candidates = new ArrayList<>();
|
boolean foundCandle = false;
|
||||||
for (int n : PathFinder.NEIGHBOURS8) {
|
for (Item i : h.items){
|
||||||
int cell = ritualPos + n;
|
if (i instanceof CeremonialCandle){
|
||||||
if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar( cell ) == null) {
|
if (!((CeremonialCandle) i).aflame) {
|
||||||
candidates.add( cell );
|
((CeremonialCandle) i).aflame = true;
|
||||||
|
h.sprite.view(h).place(h.pos);
|
||||||
}
|
}
|
||||||
|
foundCandle = true;
|
||||||
}
|
}
|
||||||
if (candidates.size() > 0) {
|
}
|
||||||
elemental.pos = Random.element( candidates );
|
if (!foundCandle){
|
||||||
} else {
|
allCandles = false;
|
||||||
elemental.pos = ritualPos;
|
}
|
||||||
|
} 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();
|
||||||
|
Char ch = Actor.findChar( ritualPos );
|
||||||
|
if (ch != null) {
|
||||||
|
ArrayList<Integer> candidates = new ArrayList<>();
|
||||||
|
for (int n : PathFinder.NEIGHBOURS8) {
|
||||||
|
int cell = ritualPos + n;
|
||||||
|
if ((Dungeon.level.passable[cell] || Dungeon.level.avoid[cell]) && Actor.findChar( cell ) == null) {
|
||||||
|
candidates.add( cell );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (candidates.size() > 0) {
|
||||||
|
elemental.pos = Random.element( candidates );
|
||||||
} else {
|
} else {
|
||||||
elemental.pos = ritualPos;
|
elemental.pos = ritualPos;
|
||||||
}
|
}
|
||||||
elemental.state = elemental.HUNTING;
|
} else {
|
||||||
GameScene.add(elemental, 1);
|
elemental.pos = ritualPos;
|
||||||
|
|
||||||
for (int i : PathFinder.NEIGHBOURS9){
|
|
||||||
CellEmitter.get(ritualPos+i).burst(ElmoParticle.FACTORY, 10);
|
|
||||||
}
|
|
||||||
Sample.INSTANCE.play(Assets.Sounds.BURNING);
|
|
||||||
}
|
}
|
||||||
|
elemental.state = elemental.HUNTING;
|
||||||
|
GameScene.add(elemental, 1);
|
||||||
|
|
||||||
|
for (int i : PathFinder.NEIGHBOURS9){
|
||||||
|
CellEmitter.get(ritualPos+i).burst(ElmoParticle.FACTORY, 10);
|
||||||
|
}
|
||||||
|
Sample.INSTANCE.play(Assets.Sounds.BURNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user