mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-07-07 00:39:13 +07:00
Created ItemManager to play drop and flippy sounds for dropped item entities
This commit is contained in:
@ -173,7 +173,6 @@ public class ClientEntityFactory extends ServerEntityFactory {
|
||||
int id = super.createItem(item, position);
|
||||
Item itemWrapper = mItem.get(id);
|
||||
Riiablo.assets.load(itemWrapper.flippyDescriptor);
|
||||
// Riiablo.audio.play("item_flippy", true);
|
||||
/**
|
||||
* FIXME: at least some items appear to be about a half subtile too high after their drop
|
||||
* animations finish -- is this expected? or some issue with offsets? It's happening with
|
||||
|
33
core/src/com/riiablo/engine/client/ItemManager.java
Normal file
33
core/src/com/riiablo/engine/client/ItemManager.java
Normal file
@ -0,0 +1,33 @@
|
||||
package com.riiablo.engine.client;
|
||||
|
||||
import com.artemis.BaseEntitySystem;
|
||||
import com.artemis.ComponentMapper;
|
||||
import com.artemis.annotations.All;
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.Animation;
|
||||
import com.riiablo.engine.client.component.AnimationWrapper;
|
||||
import com.riiablo.engine.server.component.Item;
|
||||
|
||||
@All({Item.class, AnimationWrapper.class})
|
||||
public class ItemManager extends BaseEntitySystem {
|
||||
protected ComponentMapper<Item> mItem;
|
||||
protected ComponentMapper<AnimationWrapper> mAnimationWrapper;
|
||||
|
||||
@Override
|
||||
protected void inserted(int entityId) {
|
||||
com.riiablo.item.Item item = mItem.get(entityId).item;
|
||||
final String sound = item.getDropSound();
|
||||
mAnimationWrapper.get(entityId).animation.addAnimationListener(item.getDropFxFrame(), new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onTrigger(Animation animation, int frame) {
|
||||
Riiablo.audio.play(sound, true);
|
||||
animation.removeAnimationListener(frame, this);
|
||||
}
|
||||
});
|
||||
|
||||
Riiablo.audio.play("item_flippy", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void processSystem() {}
|
||||
}
|
@ -59,6 +59,7 @@ import com.riiablo.engine.client.DialogManager;
|
||||
import com.riiablo.engine.client.DirectionResolver;
|
||||
import com.riiablo.engine.client.HoveredManager;
|
||||
import com.riiablo.engine.client.ItemLoader;
|
||||
import com.riiablo.engine.client.ItemManager;
|
||||
import com.riiablo.engine.client.LabelManager;
|
||||
import com.riiablo.engine.client.MenuManager;
|
||||
import com.riiablo.engine.client.MissileLoader;
|
||||
@ -568,6 +569,8 @@ public class GameScreen extends ScreenAdapter implements GameLoadingScreen.Loada
|
||||
.with(new LabelManager())
|
||||
.with(new MonsterLabelManager())
|
||||
|
||||
.with(new ItemManager())
|
||||
|
||||
.with(new PathDebugger())
|
||||
.with(new Box2DDebugger())
|
||||
.with(new PathfindDebugger())
|
||||
|
Reference in New Issue
Block a user