v0.2.2: fixed a visual sync bug with bones system

This commit is contained in:
Evan Debenham 2014-10-25 14:11:46 -04:00
parent 2d176b4b62
commit bd4405a805
6 changed files with 31 additions and 14 deletions

View File

@ -99,7 +99,7 @@ public class Bones {
if (!items.isEmpty()) { if (!items.isEmpty()) {
item = Random.element(items); item = Random.element(items);
if (item.stackable){ if (item.stackable){
item.quantity(Random.NormalIntRange(1, (int)Math.sqrt(item.quantity()))); item.quantity((int)Math.sqrt(item.quantity()));
} }
} }
} }
@ -147,9 +147,7 @@ public class Bones {
} }
} }
if (item instanceof Ring) { item.syncVisuals();
((Ring)item).syncGem();
}
return item; return item;
} else { } else {

View File

@ -112,6 +112,10 @@ public class Item implements Bundlable {
Dungeon.level.drop( detachAll( hero.belongings.backpack ), hero.pos ).sprite.drop( hero.pos ); Dungeon.level.drop( detachAll( hero.belongings.backpack ), hero.pos ).sprite.drop( hero.pos );
} }
public void syncVisuals(){
//do nothing by default, as most items need no visual syncing.
}
public void doThrow( Hero hero ) { public void doThrow( Hero hero ) {
GameScene.selectCell( thrower ); GameScene.selectCell( thrower );
} }

View File

@ -110,9 +110,14 @@ public class Potion extends Item {
public Potion() { public Potion() {
super(); super();
syncVisuals();
}
@Override
public void syncVisuals(){
image = handler.image( this ); image = handler.image( this );
color = handler.label( this ); color = handler.label( this );
} };
@Override @Override
public ArrayList<String> actions( Hero hero ) { public ArrayList<String> actions( Hero hero ) {

View File

@ -93,10 +93,10 @@ public class Ring extends KindofMisc {
public Ring() { public Ring() {
super(); super();
syncGem(); syncVisuals();
} }
public void syncGem() { public void syncVisuals() {
image = handler.image( this ); image = handler.image( this );
gem = handler.label( this ); gem = handler.label( this );
} }

View File

@ -92,9 +92,14 @@ public abstract class Scroll extends Item {
public Scroll() { public Scroll() {
super(); super();
syncVisuals();
}
@Override
public void syncVisuals(){
image = handler.image( this ); image = handler.image( this );
rune = handler.label( this ); rune = handler.label( this );
} };
@Override @Override
public ArrayList<String> actions( Hero hero ) { public ArrayList<String> actions( Hero hero ) {

View File

@ -125,13 +125,18 @@ public abstract class Wand extends KindOfWeapon {
calculateDamage(); calculateDamage();
try { try {
image = handler.image( this ); syncVisuals();
wood = handler.label( this );
} catch (Exception e) { } catch (Exception e) {
// Wand of Magic Missile // Wand of Magic Missile
} }
} }
@Override
public void syncVisuals(){
image = handler.image( this );
wood = handler.label( this );
}
@Override @Override
public ArrayList<String> actions( Hero hero ) { public ArrayList<String> actions( Hero hero ) {
ArrayList<String> actions = super.actions( hero ); ArrayList<String> actions = super.actions( hero );