v2.2.0: implemented a bunch of functionality for the crystal spire

This commit is contained in:
Evan Debenham
2023-09-19 14:20:50 -04:00
parent e45206016a
commit 6827da804d
7 changed files with 160 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 340 B

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -40,6 +40,11 @@ public class CrystalGuardian extends Mob{
state = SLEEPING;
}
@Override
public boolean reset() {
return true;
}
public CrystalGuardian(){
super();
switch (Random.Int(3)){

View File

@@ -21,17 +21,103 @@
package com.shatteredpixel.shatteredpixeldungeon.actors.mobs;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Amok;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Dread;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Paralysis;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Sleep;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Terror;
import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Vertigo;
import com.shatteredpixel.shatteredpixeldungeon.actors.mobs.npcs.Blacksmith;
import com.shatteredpixel.shatteredpixeldungeon.items.quest.Pickaxe;
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.CrystalSpireSprite;
import com.watabou.noosa.audio.Sample;
import com.watabou.utils.Bundle;
import com.watabou.utils.Callback;
import com.watabou.utils.Random;
public class CrystalSpire extends Mob {
{
HP = HT = 1;
HP = HT = 200;
spriteClass = CrystalSpireSprite.class;
state = PASSIVE;
alignment = Alignment.NEUTRAL;
properties.add(Property.IMMOVABLE);
properties.add(Property.MINIBOSS);
properties.add(Property.INORGANIC);
}
@Override
protected boolean act() {
alerted = false;
return super.act();
}
//TODO just whaling on this thing is boring, it has to do something in retaliation other than aggroing guardians
@Override
public void beckon(int cell) {
//do nothing
}
@Override
public boolean reset() {
return true;
}
@Override
public void damage(int dmg, Object src) {
if (!(src instanceof Pickaxe) ){
dmg = 0;
}
super.damage(dmg, src);
}
@Override
public boolean interact(Char c) {
if (c == Dungeon.hero){
final Pickaxe p = Dungeon.hero.belongings.getItem(Pickaxe.class);
if (p == null){
//maybe a game log entry here?
return true;
}
Dungeon.hero.sprite.attack(pos, new Callback() {
@Override
public void call() {
//does its own special damage calculation that's only influenced by pickaxe level
int dmg = Random.NormalIntRange(3+p.buffedLvl(), 15+3*p.buffedLvl());
damage(dmg, p);
sprite.bloodBurstA(Dungeon.hero.sprite.center(), dmg);
sprite.flash();
if (isAlive()) {
Sample.INSTANCE.play(Assets.Sounds.SHATTER, 1f, Random.Float(1.15f, 1.25f));
((CrystalSpireSprite) sprite).updateIdle();
} else {
Sample.INSTANCE.play(Assets.Sounds.SHATTER);
Sample.INSTANCE.playDelayed(Assets.Sounds.ROCKS, 0.1f);
PixelScene.shake( 3, 0.7f );
Blacksmith.Quest.beatBoss();
}
Dungeon.hero.spendAndNext(Actor.TICK);
}
});
return false;
}
return true;
}
public CrystalSpire(){
@@ -68,4 +154,13 @@ public class CrystalSpire extends Mob {
spriteClass = bundle.getClass(SPRITE);
}
{
immunities.add( Paralysis.class );
immunities.add( Amok.class );
immunities.add( Sleep.class );
immunities.add( Terror.class );
immunities.add( Dread.class );
immunities.add( Vertigo.class );
}
}

View File

@@ -405,6 +405,10 @@ public class Blacksmith extends NPC {
started = true;
}
public static boolean beatBoss(){
return bossBeaten = true;
}
public static boolean bossBeaten(){
return bossBeaten;
}

View File

@@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.effects;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.watabou.noosa.Visual;
import com.watabou.noosa.particles.Emitter;
import com.watabou.noosa.particles.PixelParticle;
import com.watabou.utils.PointF;
@@ -66,6 +67,21 @@ public class Splash {
emitter.burst( FACTORY, n );
}
public static void around(Visual v, final int color, int n ) {
if (n <= 0) {
return;
}
Emitter emitter = GameScene.emitter();
if (emitter == null) return;
emitter.pos( v );
FACTORY.color = color;
FACTORY.dir = -3.1415926f / 2;
FACTORY.cone = 3.1415926f;
emitter.burst( FACTORY, n );
}
public static void at( PointF p, final float dir, final float cone, final int color, int n, float interval ) {
if (n <= 0) {

View File

@@ -23,12 +23,17 @@ package com.shatteredpixel.shatteredpixeldungeon.sprites;
import com.shatteredpixel.shatteredpixeldungeon.Assets;
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
import com.shatteredpixel.shatteredpixeldungeon.effects.Splash;
import com.watabou.noosa.TextureFilm;
public abstract class CrystalSpireSprite extends MobSprite {
{
perspectiveRaise = 7 / 16f; //7 pixels
shadowWidth = 1f;
shadowHeight = 1f;
shadowOffset = 1f;
}
public CrystalSpireSprite(){
@@ -46,15 +51,44 @@ public abstract class CrystalSpireSprite extends MobSprite {
zap = idle.clone();
die = new Animation(1, false);
die.frames( frames, 0+c );
die.frames( frames, 4+c );
play(idle);
}
public void updateIdle(){
float hpPercent = 1f;
if (ch != null){
hpPercent = ch.HP/(float)ch.HT;
}
TextureFilm frames = new TextureFilm( texture, 30, 45 );
if (hpPercent > 0.8f){
idle.frames( frames, 0+texOffset() );
} else if (hpPercent > 0.5f){
idle.frames( frames, 1+texOffset() );
} else if (hpPercent > 0.25f){
idle.frames( frames, 2+texOffset() );
} else {
idle.frames( frames, 3+texOffset() );
}
play(idle, true);
run = idle.clone();
attack = idle.clone();
zap = idle.clone();
}
@Override
public void link(Char ch) {
super.link(ch);
renderShadow = false;
updateIdle();
}
@Override
public void die() {
super.die();
Splash.around(this, blood(), 100);
}
protected abstract int texOffset();
@@ -73,7 +107,7 @@ public abstract class CrystalSpireSprite extends MobSprite {
public static class Green extends CrystalSpireSprite {
@Override
protected int texOffset() {
return 1;
return 5;
}
@Override
public int blood() {
@@ -84,7 +118,7 @@ public abstract class CrystalSpireSprite extends MobSprite {
public static class Red extends CrystalSpireSprite {
@Override
protected int texOffset() {
return 2;
return 10;
}
@Override
public int blood() {

View File

@@ -73,7 +73,7 @@ public class SpawnerSprite extends MobSprite {
@Override
public void die() {
Splash.at( center(), blood(), 100 );
Splash.around( this, blood(), 100 );
killAndErase();
}