use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class PositionAction method run.
@Override
public boolean run(VerbRunner cb) {
Scene s = actor.getScene();
BaseActor a = s.getActor(actor.getActorId(), true);
float x = a.getX();
float y = a.getY();
if (target != null) {
Scene ts = target.getScene();
BaseActor anchorActor = ts.getActor(target.getActorId(), false);
x = anchorActor.getX();
y = anchorActor.getY();
if (anchorActor instanceof InteractiveActor) {
Vector2 refPoint = ((InteractiveActor) anchorActor).getRefPoint();
x += refPoint.x;
y += refPoint.y;
}
if (position != null) {
float scale = EngineAssetManager.getInstance().getScale();
x += position.x * scale;
y += position.y * scale;
}
} else if (position != null) {
float scale = EngineAssetManager.getInstance().getScale();
x = position.x * scale;
y = position.y * scale;
}
a.setPosition(x, y);
return false;
}
use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class RunVerbAction method getVerb.
private Verb getVerb() {
Verb v = null;
Scene s = World.getInstance().getCurrentScene();
if (actor != null) {
InteractiveActor a = (InteractiveActor) s.getActor(actor, true);
v = a.getVerbManager().getVerb(verb, a.getState(), target);
}
if (v == null) {
v = s.getVerbManager().getVerb(verb, s.getState(), target);
}
if (v == null) {
v = World.getInstance().getVerbManager().getVerb(verb, null, target);
}
if (v == null)
EngineLogger.error("Cannot find VERB: " + verb + " for ACTOR: " + actor);
return v;
}
use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class TextAction method run.
@Override
public boolean run(VerbRunner cb) {
if (text == null)
return false;
float x = TextManager.POS_CENTER, y = TextManager.POS_CENTER;
if (target != null) {
Scene ts = target.getScene();
BaseActor anchorActor = ts.getActor(target.getActorId(), true);
x = anchorActor.getX();
y = anchorActor.getY();
if (anchorActor instanceof InteractiveActor) {
Vector2 refPoint = ((InteractiveActor) anchorActor).getRefPoint();
x += refPoint.x;
y += refPoint.y;
}
if (pos != null) {
float scale = EngineAssetManager.getInstance().getScale();
x += pos.x * scale;
y += pos.y * scale;
}
} else if (pos != null) {
float scale = EngineAssetManager.getInstance().getScale();
if (pos.x != TextManager.POS_CENTER)
x = pos.x * scale;
if (pos.y != TextManager.POS_CENTER)
y = pos.y * scale;
} else {
if (type == Text.Type.SUBTITLE) {
x = y = TextManager.POS_SUBTITLE;
}
}
World.getInstance().getTextManager().addText(text, x, y, queue, type, color, style, null, voiceId, wait ? cb : null);
return wait;
}
use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class IfSceneAttrAction method run.
@Override
public boolean run(VerbRunner cb) {
Scene s = (scene != null && !scene.isEmpty()) ? World.getInstance().getScene(scene) : World.getInstance().getCurrentScene();
if (attr == SceneAttr.STATE) {
if (!ActionUtils.compareNullStr(value, s.getState())) {
gotoElse((VerbRunner) cb);
}
} else if (attr == SceneAttr.CURRENT_SCENE) {
String scn = World.getInstance().getCurrentScene().getId();
if (!ActionUtils.compareNullStr(value, scn)) {
gotoElse((VerbRunner) cb);
}
} else if (attr == SceneAttr.PLAYER) {
CharacterActor player = s.getPlayer();
String id = player != null ? player.getId() : null;
if (!ActionUtils.compareNullStr(value, id)) {
gotoElse((VerbRunner) cb);
}
}
return false;
}
use of com.bladecoder.engine.model.Scene in project bladecoder-adventure-engine by bladecoder.
the class ScreenPositionAction method run.
@Override
public boolean run(VerbRunner cb) {
Scene s = actor.getScene();
BaseActor a = s.getActor(actor.getActorId(), true);
if (position != null) {
float scale = EngineAssetManager.getInstance().getScale();
Viewport viewport = ((SceneScreen) BladeEngine.getAppUI().getScreen(Screens.SCENE_SCREEN)).getViewport();
Vector3 v = new Vector3(position.x * scale, position.y * scale, 0);
if (anchor == Anchor.CENTER) {
v.x += viewport.getWorldWidth() / 2;
v.y += viewport.getWorldHeight() / 2;
} else if (anchor == Anchor.TOP_LEFT) {
v.x += 0;
v.y += viewport.getWorldHeight();
} else if (anchor == Anchor.TOP_RIGHT) {
v.x += viewport.getWorldWidth();
v.y += viewport.getWorldHeight();
} else if (anchor == Anchor.BOTTOM_RIGHT) {
v.x += viewport.getWorldWidth();
v.y += 0;
} else if (anchor == Anchor.BOTTOM_LEFT) {
v.x += 0;
v.y += 0;
} else if (anchor == Anchor.TOP) {
v.x += viewport.getWorldWidth() / 2;
v.y += viewport.getWorldHeight();
} else if (anchor == Anchor.BOTTOM) {
v.x += viewport.getWorldWidth() / 2;
v.y += 0;
} else if (anchor == Anchor.LEFT) {
v.x += 0;
v.y += viewport.getWorldHeight() / 2;
} else if (anchor == Anchor.RIGHT) {
v.x += viewport.getWorldWidth();
v.y += viewport.getWorldHeight() / 2;
}
// viewport.project(v);
v.x *= viewport.getScreenWidth() / viewport.getWorldWidth();
v.y *= viewport.getScreenHeight() / viewport.getWorldHeight();
// v.y = viewport.getScreenHeight() - v.y;
v.y = Gdx.graphics.getHeight() - v.y;
World.getInstance().getCurrentScene().getCamera().unproject(v, 0, 0, viewport.getScreenWidth(), viewport.getScreenHeight());
a.setPosition(v.x, v.y);
}
return false;
}
Aggregations