v0.7.4a: fixed crashes involving ward sprites in the attack indicator
This commit is contained in:
parent
e36ea99a61
commit
56746de335
|
@ -145,7 +145,7 @@ public class WandOfWarding extends Wand {
|
|||
|
||||
public static class Ward extends NPC {
|
||||
|
||||
private int tier = 1;
|
||||
public int tier = 1;
|
||||
private int wandLevel = 1;
|
||||
|
||||
private int totalZaps = 0;
|
||||
|
@ -316,7 +316,7 @@ public class WandOfWarding extends Wand {
|
|||
@Override
|
||||
public CharSprite sprite() {
|
||||
WardSprite sprite = (WardSprite) super.sprite();
|
||||
sprite.updateTier(tier);
|
||||
sprite.linkVisuals(this);
|
||||
return sprite;
|
||||
}
|
||||
|
||||
|
@ -324,6 +324,7 @@ public class WandOfWarding extends Wand {
|
|||
public void updateSpriteState() {
|
||||
super.updateSpriteState();
|
||||
((WardSprite)sprite).updateTier(tier);
|
||||
sprite.place(pos);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -133,7 +133,10 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
|||
}
|
||||
}
|
||||
|
||||
public void link(Char ch ) {
|
||||
//intended to be used for placing a character in the game world
|
||||
public void link( Char ch ) {
|
||||
linkVisuals( ch );
|
||||
|
||||
this.ch = ch;
|
||||
ch.sprite = this;
|
||||
|
||||
|
@ -152,6 +155,11 @@ public class CharSprite extends MovieClip implements Tweener.Listener, MovieClip
|
|||
ch.updateSpriteState();
|
||||
}
|
||||
|
||||
//used for just updating a sprite based on a given character, not linking them or placing in the game
|
||||
public void linkVisuals( Char ch ){
|
||||
//do nothin by default
|
||||
}
|
||||
|
||||
public PointF worldToCamera( int cell ) {
|
||||
|
||||
final int csize = DungeonTilemap.SIZE;
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.shatteredpixel.shatteredpixeldungeon.sprites;
|
|||
|
||||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Actor;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.Char;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Beam;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.MagicMissile;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.wands.WandOfWarding;
|
||||
|
@ -71,6 +72,14 @@ public class WardSprite extends MobSprite {
|
|||
} );
|
||||
}
|
||||
|
||||
public void linkVisuals( Char ch ){
|
||||
|
||||
if (ch == null) return;
|
||||
|
||||
updateTier( ((WandOfWarding.Ward)ch).tier );
|
||||
|
||||
}
|
||||
|
||||
public void updateTier(int tier){
|
||||
|
||||
idle = tierIdles[tier];
|
||||
|
@ -94,9 +103,6 @@ public class WardSprite extends MobSprite {
|
|||
perspectiveRaise = 6 / 16f; //6 pixels
|
||||
}
|
||||
|
||||
if (ch != null) {
|
||||
place(ch.pos);
|
||||
}
|
||||
}
|
||||
|
||||
private float baseY = Float.NaN;
|
||||
|
@ -111,7 +117,7 @@ public class WardSprite extends MobSprite {
|
|||
public void update() {
|
||||
super.update();
|
||||
//if tier is greater than 3
|
||||
if (perspectiveRaise >= 6 / 16f){
|
||||
if (perspectiveRaise >= 6 / 16f && !paused){
|
||||
if (Float.isNaN(baseY)) baseY = y;
|
||||
y = baseY + (float) Math.sin(Game.timeTotal);
|
||||
shadowOffset = 0.25f - 0.8f*(float) Math.sin(Game.timeTotal);
|
||||
|
|
|
@ -137,6 +137,7 @@ public class AttackIndicator extends Tag {
|
|||
try {
|
||||
sprite = lastTarget.spriteClass.newInstance();
|
||||
active = true;
|
||||
sprite.linkVisuals(lastTarget);
|
||||
sprite.idle();
|
||||
sprite.paused = true;
|
||||
add( sprite );
|
||||
|
|
Loading…
Reference in New Issue
Block a user