v0.4.1: added a visual effect for adding items to the journal
This commit is contained in:
parent
c0eecb1338
commit
80a4ef2b9b
|
@ -23,6 +23,7 @@ package com.shatteredpixel.shatteredpixeldungeon.items.keys;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.utils.Bundle;
|
||||
|
||||
|
@ -44,7 +45,7 @@ public abstract class Key extends Item {
|
|||
|
||||
@Override
|
||||
public boolean doPickUp(Hero hero) {
|
||||
//TODO add a pickup animation to the journal
|
||||
GameScene.pickUpJournal(this);
|
||||
Sample.INSTANCE.play( Assets.SND_ITEM );
|
||||
hero.spendAndNext( TIME_TO_PICK_UP );
|
||||
return true;
|
||||
|
|
|
@ -110,6 +110,8 @@ public class GameScene extends PixelScene {
|
|||
private FogOfWar fog;
|
||||
private HeroSprite hero;
|
||||
|
||||
private StatusPane pane;
|
||||
|
||||
private GameLog log;
|
||||
|
||||
private BusyIndicator busy;
|
||||
|
@ -249,10 +251,10 @@ public class GameScene extends PixelScene {
|
|||
|
||||
add( cellSelector = new CellSelector( tiles ) );
|
||||
|
||||
StatusPane sb = new StatusPane();
|
||||
sb.camera = uiCamera;
|
||||
sb.setSize( uiCamera.width, 0 );
|
||||
add( sb );
|
||||
pane = new StatusPane();
|
||||
pane.camera = uiCamera;
|
||||
pane.setSize( uiCamera.width, 0 );
|
||||
add( pane );
|
||||
|
||||
toolbar = new Toolbar();
|
||||
toolbar.camera = uiCamera;
|
||||
|
@ -284,7 +286,7 @@ public class GameScene extends PixelScene {
|
|||
busy = new BusyIndicator();
|
||||
busy.camera = uiCamera;
|
||||
busy.x = 1;
|
||||
busy.y = sb.bottom() + 1;
|
||||
busy.y = pane.bottom() + 1;
|
||||
add( busy );
|
||||
|
||||
switch (InterlevelScene.mode) {
|
||||
|
@ -656,6 +658,10 @@ public class GameScene extends PixelScene {
|
|||
scene.toolbar.pickup( item );
|
||||
}
|
||||
|
||||
public static void pickUpJournal( Item item ) {
|
||||
scene.pane.pickup( item );
|
||||
}
|
||||
|
||||
public static void resetMap() {
|
||||
if (scene != null) {
|
||||
scene.tiles.map(Dungeon.level.map, Level.WIDTH );
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.shatteredpixel.shatteredpixeldungeon.Assets;
|
|||
import com.shatteredpixel.shatteredpixeldungeon.Dungeon;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.Speck;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.effects.particles.BloodParticle;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.items.Item;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.scenes.PixelScene;
|
||||
import com.shatteredpixel.shatteredpixeldungeon.sprites.HeroSprite;
|
||||
|
@ -69,6 +70,8 @@ public class StatusPane extends Component {
|
|||
private JournalButton btnJournal;
|
||||
private MenuButton btnMenu;
|
||||
|
||||
private Toolbar.PickedUpItem pickedUp;
|
||||
|
||||
@Override
|
||||
protected void createChildren() {
|
||||
|
||||
|
@ -135,6 +138,8 @@ public class StatusPane extends Component {
|
|||
|
||||
buffs = new BuffIndicator( Dungeon.hero );
|
||||
add( buffs );
|
||||
|
||||
add( pickedUp = new Toolbar.PickedUpItem());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -218,6 +223,13 @@ public class StatusPane extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
public void pickup( Item item ) {
|
||||
pickedUp.reset( item,
|
||||
btnJournal.icon.x + btnJournal.icon.width()/2f,
|
||||
btnJournal.icon.y + btnJournal.icon.height()/2f,
|
||||
true );
|
||||
}
|
||||
|
||||
private static class JournalButton extends Button {
|
||||
|
||||
private Image bg;
|
||||
|
|
|
@ -267,7 +267,8 @@ public class Toolbar extends Component {
|
|||
public void pickup( Item item ) {
|
||||
pickedUp.reset( item,
|
||||
btnInventory.centerX(),
|
||||
btnInventory.centerY() );
|
||||
btnInventory.centerY(),
|
||||
false );
|
||||
}
|
||||
|
||||
private static CellSelector.Listener informer = new CellSelector.Listener() {
|
||||
|
@ -376,7 +377,7 @@ public class Toolbar extends Component {
|
|||
}
|
||||
}
|
||||
|
||||
private static class PickedUpItem extends ItemSprite {
|
||||
public static class PickedUpItem extends ItemSprite {
|
||||
|
||||
private static final float DISTANCE = DungeonTilemap.SIZE;
|
||||
private static final float DURATION = 0.2f;
|
||||
|
@ -385,6 +386,8 @@ public class Toolbar extends Component {
|
|||
private float dstY;
|
||||
private float left;
|
||||
|
||||
private boolean rising = false;
|
||||
|
||||
public PickedUpItem() {
|
||||
super();
|
||||
|
||||
|
@ -395,19 +398,22 @@ public class Toolbar extends Component {
|
|||
false;
|
||||
}
|
||||
|
||||
public void reset( Item item, float dstX, float dstY ) {
|
||||
public void reset( Item item, float dstX, float dstY, boolean rising ) {
|
||||
view( item );
|
||||
|
||||
active =
|
||||
visible =
|
||||
true;
|
||||
|
||||
this.rising = rising;
|
||||
|
||||
this.dstX = dstX - ItemSprite.SIZE / 2;
|
||||
this.dstY = dstY - ItemSprite.SIZE / 2;
|
||||
left = DURATION;
|
||||
|
||||
x = this.dstX - DISTANCE;
|
||||
y = this.dstY - DISTANCE;
|
||||
if (rising) y = this.dstY + DISTANCE;
|
||||
else y = this.dstY - DISTANCE;
|
||||
alpha( 1 );
|
||||
}
|
||||
|
||||
|
@ -426,8 +432,10 @@ public class Toolbar extends Component {
|
|||
float p = left / DURATION;
|
||||
scale.set( (float)Math.sqrt( p ) );
|
||||
float offset = DISTANCE * p;
|
||||
|
||||
x = dstX - offset;
|
||||
y = dstY - offset;
|
||||
if (rising) y = dstY + offset;
|
||||
else y = dstY - offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user