v0.6.2: improved visuals for picked up items

This commit is contained in:
Evan Debenham 2017-08-31 02:49:10 -04:00
parent b02d1d0d1a
commit 697c814551
7 changed files with 39 additions and 37 deletions

View File

@ -69,7 +69,7 @@ public class Gold extends Item {
if (thievery != null)
thievery.collect(quantity);
GameScene.pickUp( this );
GameScene.pickUp( this, hero.pos );
hero.sprite.showStatus( CharSprite.NEUTRAL, TXT_VALUE, quantity );
hero.spendAndNext( TIME_TO_PICK_UP );

View File

@ -104,7 +104,7 @@ public class Item implements Bundlable {
public boolean doPickUp( Hero hero ) {
if (collect( hero.belongings.backpack )) {
GameScene.pickUp( this );
GameScene.pickUp( this, hero.pos );
Sample.INSTANCE.play( Assets.SND_ITEM );
hero.spendAndNext( TIME_TO_PICK_UP );
return true;

View File

@ -51,7 +51,7 @@ public abstract class DocumentPage extends Item {
@Override
public final boolean doPickUp(Hero hero) {
GameScene.pickUpJournal(this);
GameScene.pickUpJournal(this, hero.pos);
GameScene.flashJournal();
WndJournal.last_index = 0;
document().addPage(page);

View File

@ -49,7 +49,7 @@ public abstract class Key extends Item {
@Override
public boolean doPickUp(Hero hero) {
GameScene.pickUpJournal(this);
GameScene.pickUpJournal(this, hero.pos);
WndJournal.last_index = 1;
Notes.add(this);
Sample.INSTANCE.play( Assets.SND_ITEM );

View File

@ -729,12 +729,12 @@ public class GameScene extends PixelScene {
return scene != null ? (FloatingText)scene.statuses.recycle( FloatingText.class ) : null;
}
public static void pickUp( Item item ) {
if (scene != null) scene.toolbar.pickup( item );
public static void pickUp( Item item, int pos ) {
if (scene != null) scene.toolbar.pickup( item, pos );
}
public static void pickUpJournal( Item item ) {
if (scene != null) scene.pane.pickup( item );
public static void pickUpJournal( Item item, int pos ) {
if (scene != null) scene.pane.pickup( item, pos );
}
public static void flashJournal(){

View File

@ -221,11 +221,11 @@ public class StatusPane extends Component {
}
}
public void pickup( Item item ) {
public void pickup( Item item, int cell) {
pickedUp.reset( item,
cell,
btnJournal.icon.x + btnJournal.icon.width()/2f,
btnJournal.icon.y + btnJournal.icon.height()/2f,
true );
btnJournal.icon.y + btnJournal.icon.height()/2f);
}
public void flash(){

View File

@ -29,14 +29,17 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTilemap;
import com.shatteredpixel.shatteredpixeldungeon.tiles.DungeonTerrainTilemap;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndBag;
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
import com.watabou.noosa.Camera;
import com.watabou.noosa.Game;
import com.watabou.noosa.Gizmo;
import com.watabou.noosa.Image;
import com.watabou.noosa.ui.Button;
import com.watabou.noosa.ui.Component;
import com.watabou.utils.Point;
import com.watabou.utils.PointF;
public class Toolbar extends Component {
@ -265,11 +268,11 @@ public class Toolbar extends Component {
}
}
public void pickup( Item item ) {
public void pickup( Item item, int cell ) {
pickedUp.reset( item,
cell,
btnInventory.centerX(),
btnInventory.centerY(),
false );
btnInventory.centerY());
}
private static CellSelector.Listener informer = new CellSelector.Listener() {
@ -380,15 +383,13 @@ public class Toolbar extends Component {
public static class PickedUpItem extends ItemSprite {
private static final float DISTANCE = DungeonTilemap.SIZE;
private static final float DURATION = 0.2f;
private static final float DURATION = 0.5f;
private float dstX;
private float dstY;
private float startScale;
private float startX, startY;
private float endX, endY;
private float left;
private boolean rising = false;
public PickedUpItem() {
super();
@ -399,23 +400,26 @@ public class Toolbar extends Component {
false;
}
public void reset( Item item, float dstX, float dstY, boolean rising ) {
public void reset( Item item, int cell, float endX, float endY ) {
view( item );
active =
visible =
true;
this.rising = rising;
PointF tile = DungeonTerrainTilemap.raisedTileCenterToWorld(cell);
Point screen = Camera.main.cameraToScreen(tile.x, tile.y);
PointF start = camera().screenToCamera(screen.x, screen.y);
this.dstX = dstX - ItemSprite.SIZE / 2;
this.dstY = dstY - ItemSprite.SIZE / 2;
x = this.startX = start.x - ItemSprite.SIZE / 2;
y = this.startY = start.y - ItemSprite.SIZE / 2;
this.endX = endX - ItemSprite.SIZE / 2;
this.endY = endY - ItemSprite.SIZE / 2;
left = DURATION;
x = this.dstX - DISTANCE;
if (rising) y = this.dstY + DISTANCE;
else y = this.dstY - DISTANCE;
alpha( 1 );
scale.set( startScale = Camera.main.zoom / camera().zoom );
}
@Override
@ -431,12 +435,10 @@ public class Toolbar extends Component {
} else {
float p = left / DURATION;
scale.set( (float)Math.sqrt( p ) );
float offset = DISTANCE * p;
scale.set( startScale * (float)Math.sqrt( p ) );
x = dstX - offset;
if (rising) y = dstY + offset;
else y = dstY - offset;
x = startX*p + endX*(1-p);
y = startY*p + endY*(1-p);
}
}
}