use of com.bladecoder.engine.model.InteractiveActor in project bladecoder-adventure-engine by bladecoder.
the class RetroSceneScreen method drawDebugText.
private void drawDebugText(SpriteBatch batch) {
World w = World.getInstance();
w.getSceneCamera().getInputUnProject(worldViewport, unprojectTmp);
Color color;
sbTmp.setLength(0);
if (EngineLogger.lastError != null) {
sbTmp.append(EngineLogger.lastError);
color = Color.RED;
} else {
sbTmp.append("( ");
sbTmp.append((int) unprojectTmp.x);
sbTmp.append(", ");
sbTmp.append((int) unprojectTmp.y);
sbTmp.append(") FPS:");
sbTmp.append(Gdx.graphics.getFramesPerSecond());
// sbTmp.append(" Density:");
// sbTmp.append(Gdx.graphics.getDensity());
// sbTmp.append(" UI Multiplier:");
// sbTmp.append(DPIUtils.getSizeMultiplier());
sbTmp.append(" UI STATE: ");
sbTmp.append(state.toString());
if (w.getCurrentScene().getPlayer() != null) {
sbTmp.append(" Depth Scl: ");
sbTmp.append(w.getCurrentScene().getFakeDepthScale(unprojectTmp.y));
}
color = Color.WHITE;
}
String strDebug = sbTmp.toString();
textLayout.setText(ui.getSkin().getFont("debug"), strDebug, color, worldViewport.getScreenWidth(), Align.left, true);
RectangleRenderer.draw(batch, 0, worldViewport.getScreenHeight() - textLayout.height - 10, textLayout.width, textLayout.height + 10, Color.BLACK);
ui.getSkin().getFont("debug").draw(batch, textLayout, 0, worldViewport.getScreenHeight() - 5);
// Draw actor states when debug
if (EngineLogger.getDebugLevel() == EngineLogger.DEBUG1) {
for (BaseActor a : w.getCurrentScene().getActors().values()) {
Rectangle r = a.getBBox().getBoundingRectangle();
sbTmp.setLength(0);
sbTmp.append(a.getId());
if (a instanceof InteractiveActor && ((InteractiveActor) a).getState() != null)
sbTmp.append(".").append(((InteractiveActor) a).getState());
unprojectTmp.set(r.getX(), r.getY(), 0);
w.getSceneCamera().scene2screen(worldViewport, unprojectTmp);
if (w.getInventory().isVisible()) {
// unprojectTmp.y += verbUI.getHeight();
}
ui.getSkin().getFont("debug").draw(batch, sbTmp.toString(), unprojectTmp.x, unprojectTmp.y);
}
}
}
use of com.bladecoder.engine.model.InteractiveActor in project bladecoder-adventure-engine by bladecoder.
the class RetroSceneScreen method drawHotspots.
private void drawHotspots(SpriteBatch batch) {
final World world = World.getInstance();
for (BaseActor a : world.getCurrentScene().getActors().values()) {
if (!(a instanceof InteractiveActor) || !a.isVisible() || a == world.getCurrentScene().getPlayer())
continue;
InteractiveActor ia = (InteractiveActor) a;
if (!ia.canInteract())
continue;
Polygon p = a.getBBox();
if (p == null) {
EngineLogger.error("ERROR DRAWING HOTSPOT FOR: " + a.getId());
}
Rectangle r = a.getBBox().getBoundingRectangle();
unprojectTmp.set(r.getX() + r.getWidth() / 2, r.getY() + r.getHeight() / 2, 0);
world.getSceneCamera().scene2screen(worldViewport, unprojectTmp);
if (world.getInventory().isVisible()) {
// unprojectTmp.y += verbUI.getHeight();
}
if (ia.getDesc() == null) {
float size = DPIUtils.ICON_SIZE * DPIUtils.getSizeMultiplier();
Drawable drawable = ((TextureRegionDrawable) getUI().getSkin().getDrawable("circle")).tint(Color.RED);
drawable.draw(batch, unprojectTmp.x - size / 2, unprojectTmp.y - size / 2, size, size);
} else {
BitmapFont font = getUI().getSkin().getFont("desc");
String desc = ia.getDesc();
if (desc.charAt(0) == I18N.PREFIX)
desc = I18N.getString(desc.substring(1));
textLayout.setText(font, desc);
float textX = unprojectTmp.x - textLayout.width / 2;
float textY = unprojectTmp.y + textLayout.height;
RectangleRenderer.draw(batch, textX - 8, textY - textLayout.height - 8, textLayout.width + 16, textLayout.height + 16, Color.BLACK);
font.draw(batch, textLayout, textX, textY);
}
}
}
use of com.bladecoder.engine.model.InteractiveActor in project bladecoder-adventure-engine by bladecoder.
the class ActionCallbackSerialization method find.
private static String find(ActionCallback cb, Inventory inv) {
for (int i = 0; i < inv.getNumItems(); i++) {
InteractiveActor a = inv.get(i);
String id = find(cb, a);
if (id != null) {
StringBuilder stringBuilder = new StringBuilder(INVENTORY_TAG);
stringBuilder.append(SEPARATION_SYMBOL).append(id);
return stringBuilder.toString();
}
}
return null;
}
Aggregations