V0.2.1 : Added particle effects to Goo

This commit is contained in:
Evan Debenham 2014-10-02 00:31:44 -04:00
parent 13cf972982
commit 346f5b4e88
4 changed files with 170 additions and 37 deletions

View File

@ -0,0 +1,58 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.blobs;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Roots;
import com.shatteredpixel.shatteredpixeldungeon.effects.BlobEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.FlameParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.GooWarnParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ShadowParticle;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.WindParticle;
/**
* Created by Evan on 29/09/2014.
*/
public class GooWarn extends Blob {
//cosmetic blob, used to warn noobs that goo's pump up should, infact, be avoided.
protected int pos;
@Override
protected void evolve() {
for (int i=0; i < LENGTH; i++) {
int offv = cur[i] > 0 ? cur[i] - 1 : 0;
off[i] = offv;
if (offv > 0) {
volume += offv;
}
}
}
public void seed( int cell, int amount ) {
int diff = amount - cur[cell];
if (diff > 0) {
cur[cell] = amount;
volume += diff;
}
}
@Override
public void use( BlobEmitter emitter ) {
super.use( emitter );
emitter.start(GooWarnParticle.FACTORY, 0.2f, 0 );
}
@Override
public String tileDesc() {
return "Dark energy is building here!";
}
}

View File

@ -19,11 +19,16 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import java.util.HashSet;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.Blob;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.GooWarn;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.effects.CellEmitter;
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.ElmoParticle;
import com.watabou.noosa.Camera;
import com.shatteredpixel.shatteredpixeldungeon.Badges;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.blobs.ToxicGas;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Ooze;
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
@ -37,12 +42,12 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CharSprite;
import com.shatteredpixel.shatteredpixeldungeon.sprites.GooSprite;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Random;
public class Goo extends Mob {
private static final float PUMP_UP_DELAY = 2f;
{
name = "Goo";
HP = HT = 80;
@ -54,11 +59,18 @@ public class Goo extends Mob {
lootChance = 0.333f;
}
private boolean pumpedUp = false;
private int pumpedUp = 0;
@Override
public int damageRoll() {
if (pumpedUp) {
if (pumpedUp > 0) {
pumpedUp = 0;
for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) {
int j = pos + Level.NEIGHBOURS9DIST2[i];
if (j >= 0 && j <= 1023 && Level.passable[j])
CellEmitter.get(j).burst(ElmoParticle.FACTORY, 5);
}
Sample.INSTANCE.play( Assets.SND_BURNING );
return Random.NormalIntRange( 5, 30 );
} else {
return Random.NormalIntRange( 2, 12 );
@ -67,7 +79,7 @@ public class Goo extends Mob {
@Override
public int attackSkill( Char target ) {
return pumpedUp ? 30 : 15;
return (pumpedUp > 0) ? 30 : 15;
}
@Override
@ -88,7 +100,7 @@ public class Goo extends Mob {
@Override
protected boolean canAttack( Char enemy ) {
return pumpedUp ? distance( enemy ) <= 2 : super.canAttack(enemy);
return (pumpedUp > 0) ? distance( enemy ) <= 2 : super.canAttack(enemy);
}
@Override
@ -98,7 +110,7 @@ public class Goo extends Mob {
enemy.sprite.burst( 0x000000, 5 );
}
if (pumpedUp) {
if (pumpedUp > 0) {
Camera.main.shake( 3, 0.2f );
}
@ -107,13 +119,26 @@ public class Goo extends Mob {
@Override
protected boolean doAttack( Char enemy ) {
if (pumpedUp || Random.Int( 3 ) > 0) {
if (pumpedUp == 1) {
((GooSprite)sprite).pumpUp();
for (int i = 0; i < Level.NEIGHBOURS9DIST2.length; i++) {
int j = pos + Level.NEIGHBOURS9DIST2[i];
if (j >= 0 && j <= 1023 && Level.passable[j])
GameScene.add(Blob.seed(j, 2, GooWarn.class));
}
pumpedUp++;
spend( attackDelay() );
return true;
} else if (pumpedUp >= 2 || Random.Int( 3 ) > 0) {
boolean visible = Dungeon.visible[pos];
if (visible) {
if (pumpedUp)
((GooSprite)sprite).pumpAttack();
if (pumpedUp >= 2) {
((GooSprite) sprite).pumpAttack();
}
else
sprite.attack( enemy.pos );
} else {
@ -126,16 +151,24 @@ public class Goo extends Mob {
} else {
pumpedUp = true;
spend( PUMP_UP_DELAY );
pumpedUp++;
((GooSprite)sprite).pumpUp();
for (int i=0; i < Level.NEIGHBOURS9DIST2.length; i++) {
int j = pos + Level.NEIGHBOURS9DIST2[i];
if (j >=0 && j <= 1023 && Level.passable[j])
GameScene.add( Blob.seed( j , 2, GooWarn.class ));
}
if (Dungeon.visible[pos]) {
sprite.showStatus( CharSprite.NEGATIVE, "!!!" );
GLog.n( "Goo is pumping itself up!" );
}
spend( attackDelay() );
return true;
}
}
@ -143,13 +176,13 @@ public class Goo extends Mob {
@Override
public boolean attack( Char enemy ) {
boolean result = super.attack( enemy );
pumpedUp = false;
pumpedUp = 0;
return result;
}
@Override
protected boolean getCloser( int target ) {
pumpedUp = false;
pumpedUp = 0;
return super.getCloser( target );
}
@ -187,6 +220,24 @@ public class Goo extends Mob {
"conglomerate of substances from the sewers that gained rudiments of free will.";
}
private final String PUMPEDUP = "pumpedup";
@Override
public void storeInBundle( Bundle bundle ) {
super.storeInBundle( bundle );
bundle.put( PUMPEDUP , pumpedUp );
}
@Override
public void restoreFromBundle( Bundle bundle ) {
super.restoreFromBundle( bundle );
pumpedUp = bundle.getInt( PUMPEDUP );
}
private static final HashSet<Class<?>> RESISTANCES = new HashSet<Class<?>>();
static {
RESISTANCES.add( ToxicGas.class );

View File

@ -0,0 +1,25 @@
package com.shatteredpixel.shatteredpixeldungeon.effects.particles;
import com.watabou.noosa.particles.Emitter;
/**
* Created by Evan on 30/09/2014.
*/
public class GooWarnParticle extends WindParticle {
public static final Emitter.Factory FACTORY = new Emitter.Factory() {
@Override
public void emit( Emitter emitter, int index, float x, float y ) {
((GooWarnParticle)emitter.recycle( GooWarnParticle.class )).reset( x, y );
}
};
@Override
public void update() {
super.update();
float p = left / lifespan;
color( 0x000000 );
am = (p < 0.5f ? p : 1 - p) * size;
}
}

View File

@ -39,7 +39,6 @@ public class WindParticle extends PixelParticle {
private static float angle = Random.Float( PointF.PI * 2 );
private static PointF speed = new PointF().polar( angle, 5 );
private float size;
public WindParticle() {
super();