v0.4.1: reworked evil eyes

This commit is contained in:
Evan Debenham
2016-07-20 16:29:17 -04:00
committed by Evan Debenham
parent 52fc2b1a7d
commit 093635c454
4 changed files with 189 additions and 47 deletions
@@ -23,12 +23,19 @@ package com.shatteredpixel.shatteredpixeldungeon.sprites;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.Eye;
import com.shatteredpixel.shatteredpixeldungeon.effects.Beam;
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
import com.watabou.noosa.TextureFilm;
import com.watabou.noosa.particles.Emitter;
public class EyeSprite extends MobSprite {
private int attackPos;
private int zapPos;
private Animation charging;
private Emitter chargeParticles;
public EyeSprite() {
super();
@@ -39,33 +46,70 @@ public class EyeSprite extends MobSprite {
idle = new Animation( 8, true );
idle.frames( frames, 0, 1, 2 );
charging = new Animation( 12, true);
charging.frames( frames, 3, 4 );
chargeParticles = centerEmitter();
chargeParticles.autoKill = false;
chargeParticles.pour(MagicMissile.MagicParticle.ATTRACTING, 0.05f);
chargeParticles.on = false;
run = new Animation( 12, true );
run.frames( frames, 5, 6 );
attack = new Animation( 8, false );
attack.frames( frames, 4, 3 );
zap = attack.clone();
die = new Animation( 8, false );
die.frames( frames, 7, 8, 9 );
play( idle );
}
@Override
public void attack( int pos ) {
attackPos = pos;
super.attack( pos );
public void link(Char ch) {
super.link(ch);
if (((Eye)ch).beamCharged) play(charging);
}
@Override
public void update() {
super.update();
chargeParticles.pos(center());
chargeParticles.visible = visible;
}
public void charge( int pos ){
turnTo(ch.pos, pos);
play(charging);
}
@Override
public void play(Animation anim) {
chargeParticles.on = anim == charging;
super.play(anim);
}
@Override
public void zap( int pos ) {
zapPos = pos;
super.zap( pos );
}
@Override
public void onComplete( Animation anim ) {
super.onComplete( anim );
if (anim == attack) {
if (Dungeon.visible[ch.pos] || Dungeon.visible[attackPos]) {
parent.add( new Beam.DeathRay( center(), DungeonTilemap.tileCenterToWorld( attackPos ) ) );
if (anim == zap) {
if (Dungeon.visible[ch.pos] || Dungeon.visible[zapPos]) {
parent.add( new Beam.DeathRay( center(), DungeonTilemap.tileCenterToWorld( zapPos ) ) );
}
((Eye)ch).deathGaze();
ch.next();
} else if (anim == die){
chargeParticles.killAndErase();
}
}
}