v0.8.0: fixed save/load issues with pitfall traps and added vfx to them
This commit is contained in:
parent
e7540fc8c3
commit
70c45d3709
|
@ -28,6 +28,16 @@ import com.watabou.utils.PointF;
|
||||||
|
|
||||||
public class CellEmitter {
|
public class CellEmitter {
|
||||||
|
|
||||||
|
public static Emitter floor( int cell ) {
|
||||||
|
|
||||||
|
PointF p = DungeonTilemap.tileToWorld( cell );
|
||||||
|
|
||||||
|
Emitter emitter = GameScene.floorEmitter();
|
||||||
|
emitter.pos( p.x, p.y, DungeonTilemap.SIZE, DungeonTilemap.SIZE );
|
||||||
|
|
||||||
|
return emitter;
|
||||||
|
}
|
||||||
|
|
||||||
public static Emitter get( int cell ) {
|
public static Emitter get( int cell ) {
|
||||||
|
|
||||||
PointF p = DungeonTilemap.tileToWorld( cell );
|
PointF p = DungeonTilemap.tileToWorld( cell );
|
||||||
|
|
|
@ -0,0 +1,63 @@
|
||||||
|
/*
|
||||||
|
* Pixel Dungeon
|
||||||
|
* Copyright (C) 2012-2015 Oleg Dolya
|
||||||
|
*
|
||||||
|
* Shattered Pixel Dungeon
|
||||||
|
* Copyright (C) 2014-2020 Evan Debenham
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
|
||||||
|
|
||||||
|
import com.watabou.noosa.particles.Emitter;
|
||||||
|
import com.watabou.noosa.particles.PixelParticle;
|
||||||
|
import com.watabou.utils.Random;
|
||||||
|
|
||||||
|
public class PitfallParticle extends PixelParticle.Shrinking {
|
||||||
|
|
||||||
|
public static final Emitter.Factory FACTORY4 = new Emitter.Factory() {
|
||||||
|
@Override
|
||||||
|
public void emit( Emitter emitter, int index, float x, float y ) {
|
||||||
|
((PitfallParticle)emitter.recycle( PitfallParticle.class )).reset( x, y, 4 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static final Emitter.Factory FACTORY8 = new Emitter.Factory() {
|
||||||
|
@Override
|
||||||
|
public void emit( Emitter emitter, int index, float x, float y ) {
|
||||||
|
((PitfallParticle)emitter.recycle( PitfallParticle.class )).reset( x, y, 8 );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public PitfallParticle(){
|
||||||
|
super();
|
||||||
|
|
||||||
|
color( 0x000000 );
|
||||||
|
angle = Random.Float( -30, 30 );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset( float x, float y, int size ) {
|
||||||
|
revive();
|
||||||
|
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
|
||||||
|
left = lifespan = 1f;
|
||||||
|
|
||||||
|
this.size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,12 +27,15 @@ import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.FlavourBuff;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Mob;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
|
||||||
|
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.PitfallParticle;
|
||||||
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.features.Chasm;
|
import com.shatteredpixel.shatteredpixeldungeon.levels.features.Chasm;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
|
||||||
|
import com.watabou.utils.Bundle;
|
||||||
import com.watabou.utils.PathFinder;
|
import com.watabou.utils.PathFinder;
|
||||||
|
|
||||||
public class PitfallTrap extends Trap {
|
public class PitfallTrap extends Trap {
|
||||||
|
@ -50,11 +53,16 @@ public class PitfallTrap extends Trap {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO visuals
|
|
||||||
DelayedPit p = Buff.affect(Dungeon.hero, DelayedPit.class, 1);
|
DelayedPit p = Buff.affect(Dungeon.hero, DelayedPit.class, 1);
|
||||||
p.depth = Dungeon.depth;
|
p.depth = Dungeon.depth;
|
||||||
p.pos = pos;
|
p.pos = pos;
|
||||||
|
|
||||||
|
for (int i : PathFinder.NEIGHBOURS9){
|
||||||
|
if (!Dungeon.level.solid[pos+i] || Dungeon.level.passable[pos+i]){
|
||||||
|
CellEmitter.floor(pos+i).burst(PitfallParticle.FACTORY4, 8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (pos == Dungeon.hero.pos){
|
if (pos == Dungeon.hero.pos){
|
||||||
GLog.n(Messages.get(this, "triggered_hero"));
|
GLog.n(Messages.get(this, "triggered_hero"));
|
||||||
} else if (Dungeon.level.heroFOV[pos]){
|
} else if (Dungeon.level.heroFOV[pos]){
|
||||||
|
@ -72,8 +80,15 @@ public class PitfallTrap extends Trap {
|
||||||
public boolean act() {
|
public boolean act() {
|
||||||
if (depth == Dungeon.depth) {
|
if (depth == Dungeon.depth) {
|
||||||
for (int i : PathFinder.NEIGHBOURS9) {
|
for (int i : PathFinder.NEIGHBOURS9) {
|
||||||
|
|
||||||
int cell = pos + i;
|
int cell = pos + i;
|
||||||
|
|
||||||
|
if (Dungeon.level.solid[pos+i] && !Dungeon.level.passable[pos+i]){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CellEmitter.floor(pos+i).burst(PitfallParticle.FACTORY8, 12);
|
||||||
|
|
||||||
Heap heap = Dungeon.level.heaps.get(cell);
|
Heap heap = Dungeon.level.heaps.get(cell);
|
||||||
|
|
||||||
if (heap != null) {
|
if (heap != null) {
|
||||||
|
@ -101,6 +116,24 @@ public class PitfallTrap extends Trap {
|
||||||
detach();
|
detach();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String POS = "pos";
|
||||||
|
private static final String DEPTH = "depth";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void storeInBundle(Bundle bundle) {
|
||||||
|
super.storeInBundle(bundle);
|
||||||
|
bundle.put(POS, pos);
|
||||||
|
bundle.put(DEPTH, depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void restoreFromBundle(Bundle bundle) {
|
||||||
|
super.restoreFromBundle(bundle);
|
||||||
|
pos = bundle.getInt(POS);
|
||||||
|
depth = bundle.getInt(DEPTH);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO these used to become chasms when disarmed, but the functionality was problematic
|
//TODO these used to become chasms when disarmed, but the functionality was problematic
|
||||||
|
|
|
@ -147,6 +147,7 @@ public class GameScene extends PixelScene {
|
||||||
private Group traps;
|
private Group traps;
|
||||||
private Group heaps;
|
private Group heaps;
|
||||||
private Group mobs;
|
private Group mobs;
|
||||||
|
private Group floorEmitters;
|
||||||
private Group emitters;
|
private Group emitters;
|
||||||
private Group effects;
|
private Group effects;
|
||||||
private Group gases;
|
private Group gases;
|
||||||
|
@ -226,14 +227,17 @@ public class GameScene extends PixelScene {
|
||||||
|
|
||||||
levelVisuals = Dungeon.level.addVisuals();
|
levelVisuals = Dungeon.level.addVisuals();
|
||||||
add(levelVisuals);
|
add(levelVisuals);
|
||||||
|
|
||||||
|
floorEmitters = new Group();
|
||||||
|
add(floorEmitters);
|
||||||
|
|
||||||
heaps = new Group();
|
heaps = new Group();
|
||||||
add( heaps );
|
add( heaps );
|
||||||
|
|
||||||
for ( Heap heap : Dungeon.level.heaps.valueList() ) {
|
for ( Heap heap : Dungeon.level.heaps.valueList() ) {
|
||||||
addHeapSprite( heap );
|
addHeapSprite( heap );
|
||||||
}
|
}
|
||||||
|
|
||||||
emitters = new Group();
|
emitters = new Group();
|
||||||
effects = new Group();
|
effects = new Group();
|
||||||
healthIndicators = new Group();
|
healthIndicators = new Group();
|
||||||
|
@ -814,6 +818,16 @@ public class GameScene extends PixelScene {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Emitter floorEmitter() {
|
||||||
|
if (scene != null) {
|
||||||
|
Emitter emitter = (Emitter)scene.floorEmitters.recycle( Emitter.class );
|
||||||
|
emitter.revive();
|
||||||
|
return emitter;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static FloatingText status() {
|
public static FloatingText status() {
|
||||||
return scene != null ? (FloatingText)scene.statuses.recycle( FloatingText.class ) : null;
|
return scene != null ? (FloatingText)scene.statuses.recycle( FloatingText.class ) : null;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user