mirror of
https://github.com/collinsmith/riiablo.git
synced 2025-02-21 20:18:14 +07:00
Added ability to drop items
Added ability to drop items (no support for pickup yet) Added ITM entity type Added debug and bounds checking for non-zone entities
This commit is contained in:
parent
77c851a5ce
commit
0d56f2456e
@ -1,7 +1,5 @@
|
||||
package com.riiablo.codec.excel;
|
||||
|
||||
import com.riiablo.codec.excel.Excel;
|
||||
|
||||
public class ItemEntry extends Excel.Entry {
|
||||
@Override
|
||||
public String toString() {
|
||||
@ -19,6 +17,7 @@ public class ItemEntry extends Excel.Entry {
|
||||
@Column public String type;
|
||||
@Column public String type2;
|
||||
@Column public int component;
|
||||
@Column public String flippyfile;
|
||||
@Column public String invfile;
|
||||
@Column public String uniqueinvfile;
|
||||
@Column public String setinvfile;
|
||||
|
@ -87,7 +87,10 @@ public abstract class Entity {
|
||||
COFD2 getCOFs() {
|
||||
return Riiablo.cofs.chars_cof;
|
||||
}
|
||||
};
|
||||
},
|
||||
ITM("ITEMS",
|
||||
new String[] {"NU"},
|
||||
new String[] {"NIL"});
|
||||
|
||||
public final String PATH;
|
||||
public final String MODE[];
|
||||
|
61
core/src/com/riiablo/entity/ItemHolder.java
Normal file
61
core/src/com/riiablo/entity/ItemHolder.java
Normal file
@ -0,0 +1,61 @@
|
||||
package com.riiablo.entity;
|
||||
|
||||
import com.badlogic.gdx.assets.AssetDescriptor;
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.codec.Animation;
|
||||
import com.riiablo.codec.DC;
|
||||
import com.riiablo.codec.DC6;
|
||||
import com.riiablo.graphics.PaletteIndexedBatch;
|
||||
import com.riiablo.item.Item;
|
||||
import com.riiablo.map.DT1;
|
||||
|
||||
public class ItemHolder extends Entity {
|
||||
|
||||
Item item;
|
||||
|
||||
AssetDescriptor<DC6> flippyDescriptor;
|
||||
DC flippy;
|
||||
|
||||
public ItemHolder(Item item) {
|
||||
super(Type.ITM, "item", null);
|
||||
this.item = item;
|
||||
name(item.getName());
|
||||
|
||||
flippyDescriptor = new AssetDescriptor<>(Type.ITM.PATH + "\\" + item.base.flippyfile + ".dc6", DC6.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelectable() {
|
||||
return animation.isFinished();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getLabelOffset() {
|
||||
return DT1.Tile.SUBTILE_HEIGHT;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateCOF() {
|
||||
Riiablo.assets.load(flippyDescriptor);
|
||||
Riiablo.assets.finishLoadingAsset(flippyDescriptor);
|
||||
flippy = Riiablo.assets.get(flippyDescriptor);
|
||||
animation = Animation.builder()
|
||||
.layer(flippy)
|
||||
.build();
|
||||
animation.setLooping(false);
|
||||
animation.updateBox();
|
||||
animation.addAnimationListener(new Animation.AnimationListener() {
|
||||
@Override
|
||||
public void onFinished(Animation animation) {
|
||||
Riiablo.audio.play(item.base.dropsound, true);
|
||||
animation.removeAnimationListener(this);
|
||||
}
|
||||
});
|
||||
|
||||
Riiablo.audio.play("item_flippy", true);
|
||||
dirty = Dirty.NONE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawShadow(PaletteIndexedBatch batch) {}
|
||||
}
|
@ -37,6 +37,10 @@ public class MapListener {
|
||||
if (entity.over) gameScreen.addLabel(entity.getLabel());
|
||||
}
|
||||
}
|
||||
for (Entity entity : gameScreen.entities.values()) {
|
||||
entity.over = entity.contains(position);
|
||||
if (entity.over) gameScreen.addLabel(entity.getLabel());
|
||||
}
|
||||
}
|
||||
|
||||
private boolean touchDown() {
|
||||
|
@ -1114,6 +1114,13 @@ public class MapRenderer {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Entity entity : entities.values()) {
|
||||
Vector2 position = entity.position();
|
||||
if ((stx <= position.x && position.x < stx + Tile.SUBTILE_SIZE)
|
||||
&& (sty <= position.y && position.y < sty + Tile.SUBTILE_SIZE)) {
|
||||
entity.drawDebug(batch, shapes);
|
||||
}
|
||||
}
|
||||
|
||||
tx++;
|
||||
stx += Tile.SUBTILE_SIZE;
|
||||
|
@ -30,6 +30,7 @@ import com.badlogic.gdx.utils.viewport.Viewport;
|
||||
import com.riiablo.Keys;
|
||||
import com.riiablo.Riiablo;
|
||||
import com.riiablo.entity.Entity;
|
||||
import com.riiablo.entity.ItemHolder;
|
||||
import com.riiablo.entity.Player;
|
||||
import com.riiablo.graphics.PaletteIndexedBatch;
|
||||
import com.riiablo.graphics.PaletteIndexedColorDrawable;
|
||||
@ -108,7 +109,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
||||
|
||||
//Char character;
|
||||
public Player player;
|
||||
IntMap<Player> entities = new IntMap<>();
|
||||
public IntMap<Entity> entities = new IntMap<>();
|
||||
Timer.Task updateTask;
|
||||
|
||||
Socket socket;
|
||||
@ -361,7 +362,7 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
||||
break;
|
||||
case Packets.MOVETO:
|
||||
MoveTo moveTo = packet.readValue(MoveTo.class);
|
||||
Player p = entities.get(moveTo.id);
|
||||
Entity p = entities.get(moveTo.id);
|
||||
//if (p == player) break; // Disable forced update positions for now
|
||||
if (p != null) {
|
||||
p.setPath(map, new Vector2(moveTo.x, moveTo.y));
|
||||
@ -448,7 +449,17 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
||||
} else {
|
||||
stage.screenToStageCoordinates(tmpVec2.set(Gdx.input.getX(), Gdx.input.getY()));
|
||||
Actor hit = stage.hit(tmpVec2.x, tmpVec2.y, true);
|
||||
if (hit == null) mapListener.update();
|
||||
if (hit == null) {
|
||||
Item cursor = Riiablo.cursor.getItem();
|
||||
if (cursor != null && Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
|
||||
Riiablo.cursor.setItem(null);
|
||||
Entity item = new ItemHolder(cursor);
|
||||
item.position().set(player.position());
|
||||
entities.put(entities.size + 1, item);
|
||||
} else {
|
||||
mapListener.update();
|
||||
}
|
||||
}
|
||||
else if (DEBUG_HIT) Gdx.app.debug(TAG, hit.toString());
|
||||
//if (Gdx.input.isButtonPressed(Input.Buttons.LEFT)) {
|
||||
// GridPoint2 coords = mapRenderer.coords();
|
||||
@ -476,7 +487,6 @@ public class GameScreen extends ScreenAdapter implements LoadingScreen.Loadable
|
||||
Riiablo.shapes.begin(ShapeRenderer.ShapeType.Line);
|
||||
mapRenderer.drawDebug(Riiablo.shapes);
|
||||
mapRenderer.drawDebugPath(Riiablo.shapes, player.path());
|
||||
player.drawDebug(Riiablo.batch, Riiablo.shapes);
|
||||
Riiablo.shapes.end();
|
||||
|
||||
b.setProjectionMatrix(Riiablo.viewport.getCamera().combined);
|
||||
|
Loading…
Reference in New Issue
Block a user