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)
|
if (thievery != null)
|
||||||
thievery.collect(quantity);
|
thievery.collect(quantity);
|
||||||
|
|
||||||
GameScene.pickUp( this );
|
GameScene.pickUp( this, hero.pos );
|
||||||
hero.sprite.showStatus( CharSprite.NEUTRAL, TXT_VALUE, quantity );
|
hero.sprite.showStatus( CharSprite.NEUTRAL, TXT_VALUE, quantity );
|
||||||
hero.spendAndNext( TIME_TO_PICK_UP );
|
hero.spendAndNext( TIME_TO_PICK_UP );
|
||||||
|
|
||||||
|
|
|
@ -104,7 +104,7 @@ public class Item implements Bundlable {
|
||||||
public boolean doPickUp( Hero hero ) {
|
public boolean doPickUp( Hero hero ) {
|
||||||
if (collect( hero.belongings.backpack )) {
|
if (collect( hero.belongings.backpack )) {
|
||||||
|
|
||||||
GameScene.pickUp( this );
|
GameScene.pickUp( this, hero.pos );
|
||||||
Sample.INSTANCE.play( Assets.SND_ITEM );
|
Sample.INSTANCE.play( Assets.SND_ITEM );
|
||||||
hero.spendAndNext( TIME_TO_PICK_UP );
|
hero.spendAndNext( TIME_TO_PICK_UP );
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -51,7 +51,7 @@ public abstract class DocumentPage extends Item {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean doPickUp(Hero hero) {
|
public final boolean doPickUp(Hero hero) {
|
||||||
GameScene.pickUpJournal(this);
|
GameScene.pickUpJournal(this, hero.pos);
|
||||||
GameScene.flashJournal();
|
GameScene.flashJournal();
|
||||||
WndJournal.last_index = 0;
|
WndJournal.last_index = 0;
|
||||||
document().addPage(page);
|
document().addPage(page);
|
||||||
|
|
|
@ -49,7 +49,7 @@ public abstract class Key extends Item {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doPickUp(Hero hero) {
|
public boolean doPickUp(Hero hero) {
|
||||||
GameScene.pickUpJournal(this);
|
GameScene.pickUpJournal(this, hero.pos);
|
||||||
WndJournal.last_index = 1;
|
WndJournal.last_index = 1;
|
||||||
Notes.add(this);
|
Notes.add(this);
|
||||||
Sample.INSTANCE.play( Assets.SND_ITEM );
|
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;
|
return scene != null ? (FloatingText)scene.statuses.recycle( FloatingText.class ) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pickUp( Item item ) {
|
public static void pickUp( Item item, int pos ) {
|
||||||
if (scene != null) scene.toolbar.pickup( item );
|
if (scene != null) scene.toolbar.pickup( item, pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void pickUpJournal( Item item ) {
|
public static void pickUpJournal( Item item, int pos ) {
|
||||||
if (scene != null) scene.pane.pickup( item );
|
if (scene != null) scene.pane.pickup( item, pos );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void flashJournal(){
|
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,
|
pickedUp.reset( item,
|
||||||
|
cell,
|
||||||
btnJournal.icon.x + btnJournal.icon.width()/2f,
|
btnJournal.icon.x + btnJournal.icon.width()/2f,
|
||||||
btnJournal.icon.y + btnJournal.icon.height()/2f,
|
btnJournal.icon.y + btnJournal.icon.height()/2f);
|
||||||
true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flash(){
|
public void flash(){
|
||||||
|
|
|
@ -29,14 +29,17 @@ import com.shatteredpixel.shatteredpixeldungeon.messages.Messages;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite;
|
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.WndBag;
|
||||||
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
import com.shatteredpixel.shatteredpixeldungeon.windows.WndJournal;
|
||||||
|
import com.watabou.noosa.Camera;
|
||||||
import com.watabou.noosa.Game;
|
import com.watabou.noosa.Game;
|
||||||
import com.watabou.noosa.Gizmo;
|
import com.watabou.noosa.Gizmo;
|
||||||
import com.watabou.noosa.Image;
|
import com.watabou.noosa.Image;
|
||||||
import com.watabou.noosa.ui.Button;
|
import com.watabou.noosa.ui.Button;
|
||||||
import com.watabou.noosa.ui.Component;
|
import com.watabou.noosa.ui.Component;
|
||||||
|
import com.watabou.utils.Point;
|
||||||
|
import com.watabou.utils.PointF;
|
||||||
|
|
||||||
public class Toolbar extends Component {
|
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,
|
pickedUp.reset( item,
|
||||||
|
cell,
|
||||||
btnInventory.centerX(),
|
btnInventory.centerX(),
|
||||||
btnInventory.centerY(),
|
btnInventory.centerY());
|
||||||
false );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static CellSelector.Listener informer = new CellSelector.Listener() {
|
private static CellSelector.Listener informer = new CellSelector.Listener() {
|
||||||
|
@ -380,15 +383,13 @@ public class Toolbar extends Component {
|
||||||
|
|
||||||
public static class PickedUpItem extends ItemSprite {
|
public static class PickedUpItem extends ItemSprite {
|
||||||
|
|
||||||
private static final float DISTANCE = DungeonTilemap.SIZE;
|
private static final float DURATION = 0.5f;
|
||||||
private static final float DURATION = 0.2f;
|
|
||||||
|
|
||||||
private float dstX;
|
private float startScale;
|
||||||
private float dstY;
|
private float startX, startY;
|
||||||
|
private float endX, endY;
|
||||||
private float left;
|
private float left;
|
||||||
|
|
||||||
private boolean rising = false;
|
|
||||||
|
|
||||||
public PickedUpItem() {
|
public PickedUpItem() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -399,23 +400,26 @@ public class Toolbar extends Component {
|
||||||
false;
|
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 );
|
view( item );
|
||||||
|
|
||||||
active =
|
active =
|
||||||
visible =
|
visible =
|
||||||
true;
|
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;
|
x = this.startX = start.x - ItemSprite.SIZE / 2;
|
||||||
this.dstY = dstY - 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;
|
left = DURATION;
|
||||||
|
|
||||||
x = this.dstX - DISTANCE;
|
scale.set( startScale = Camera.main.zoom / camera().zoom );
|
||||||
if (rising) y = this.dstY + DISTANCE;
|
|
||||||
else y = this.dstY - DISTANCE;
|
|
||||||
alpha( 1 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -431,12 +435,10 @@ public class Toolbar extends Component {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
float p = left / DURATION;
|
float p = left / DURATION;
|
||||||
scale.set( (float)Math.sqrt( p ) );
|
scale.set( startScale * (float)Math.sqrt( p ) );
|
||||||
float offset = DISTANCE * p;
|
|
||||||
|
|
||||||
x = dstX - offset;
|
x = startX*p + endX*(1-p);
|
||||||
if (rising) y = dstY + offset;
|
y = startY*p + endY*(1-p);
|
||||||
else y = dstY - offset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user