v0.6.2: improved visuals for picked up items
This commit is contained in:
parent
b02d1d0d1a
commit
697c814551
|
@ -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 );
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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(){
|
||||
|
|
|
@ -221,11 +221,11 @@ public class StatusPane extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
public void pickup( Item item ) {
|
||||
public void pickup( Item item, int cell) {
|
||||
pickedUp.reset( item,
|
||||
btnJournal.icon.x + btnJournal.icon.width()/2f,
|
||||
btnJournal.icon.y + btnJournal.icon.height()/2f,
|
||||
true );
|
||||
cell,
|
||||
btnJournal.icon.x + btnJournal.icon.width()/2f,
|
||||
btnJournal.icon.y + btnJournal.icon.height()/2f);
|
||||
}
|
||||
|
||||
public void flash(){
|
||||
|
|
|
@ -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,14 +383,12 @@ 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;
|
||||
|
||||
this.dstX = dstX - ItemSprite.SIZE / 2;
|
||||
this.dstY = dstY - ItemSprite.SIZE / 2;
|
||||
PointF tile = DungeonTerrainTilemap.raisedTileCenterToWorld(cell);
|
||||
Point screen = Camera.main.cameraToScreen(tile.x, tile.y);
|
||||
PointF start = camera().screenToCamera(screen.x, screen.y);
|
||||
|
||||
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;
|
||||
|
||||
x = dstX - offset;
|
||||
if (rising) y = dstY + offset;
|
||||
else y = dstY - offset;
|
||||
scale.set( startScale * (float)Math.sqrt( p ) );
|
||||
|
||||
x = startX*p + endX*(1-p);
|
||||
y = startY*p + endY*(1-p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user