use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class Project method setSelectedActor.
public void setSelectedActor(BaseActor a) {
BaseActor old = null;
old = selectedActor;
selectedActor = a;
selectedFA = null;
firePropertyChange(NOTIFY_ACTOR_SELECTED, old, selectedActor);
}
use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class PolygonalNavGraph method createInitialGraph.
public void createInitialGraph(Collection<BaseActor> actors) {
graphNodes.clear();
// 1.- Add WalkZone convex nodes
float[] verts = walkZone.getTransformedVertices();
for (int i = 0; i < verts.length; i += 2) {
if (!PolygonUtils.isVertexConcave(walkZone, i)) {
graphNodes.add(new NavNodePolygonal(verts[i], verts[i + 1]));
}
}
// 2.- Add obstacles concave nodes
obstacles.clear();
for (BaseActor a : actors) {
if (a instanceof ObstacleActor && a.isVisible())
obstacles.add(a.getBBox());
}
for (Polygon o : obstacles) {
verts = o.getTransformedVertices();
for (int i = 0; i < verts.length; i += 2) {
if (PolygonUtils.isVertexConcave(o, i) && PolygonUtils.isPointInside(walkZone, verts[i], verts[i + 1], false)) {
graphNodes.add(new NavNodePolygonal(verts[i], verts[i + 1]));
}
}
}
// 3.- CALC LINE OF SIGHTs
for (int i = 0; i < graphNodes.size() - 1; i++) {
NavNodePolygonal n1 = graphNodes.get(i);
for (int j = i + 1; j < graphNodes.size(); j++) {
NavNodePolygonal n2 = graphNodes.get(j);
if (inLineOfSight(n1.x, n1.y, n2.x, n2.y)) {
n1.neighbors.add(n2);
n2.neighbors.add(n1);
}
}
}
}
use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class DefaultSceneScreen 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(viewport, unprojectTmp);
if (!showDesc || ia.getDesc() == null) {
float size = DPIUtils.ICON_SIZE * DPIUtils.getSizeMultiplier();
if (ia.getVerb("leave") != null) {
TransformDrawable drawable = (TransformDrawable) getUI().getSkin().getDrawable("leave");
drawable.draw(batch, unprojectTmp.x - size / 2, unprojectTmp.y - size / 2, size / 2, size / 2, size, size, 1.0f, 1.0f, calcLeaveArrowRotation(ia));
} else {
Drawable drawable = getUI().getSkin().getDrawable("hotspot");
if (drawable != null)
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.BaseActor 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.BaseActor 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);
}
}
}
Aggregations