use of com.bladecoder.engine.model.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class SceneActorInputPanel method getActorValues.
private String[] getActorValues(Scene scn) {
Map<String, BaseActor> actors = scn.getActors();
ArrayList<BaseActor> filteredActors = new ArrayList<BaseActor>();
for (BaseActor a : actors.values()) {
if (type == Param.Type.SCENE_CHARACTER_ACTOR) {
if (a instanceof CharacterActor)
filteredActors.add(a);
} else if (type == Param.Type.SCENE_INTERACTIVE_ACTOR) {
if (a instanceof InteractiveActor)
filteredActors.add(a);
} else if (type == Param.Type.SCENE_SPRITE_ACTOR) {
if (a instanceof SpriteActor)
filteredActors.add(a);
} else {
filteredActors.add(a);
}
}
String[] result = new String[isMandatory() ? filteredActors.size() + 1 : filteredActors.size() + 2];
// Add player variable to the list
result[0] = Scene.VAR_PLAYER;
if (!isMandatory())
result[filteredActors.size() + 1] = "";
for (int i = 0; i < filteredActors.size(); i++) {
result[i + 1] = filteredActors.get(i).getId();
}
Arrays.sort(result);
return result;
}
use of com.bladecoder.engine.model.BaseActor 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.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class PositionAnimAction method run.
@Override
public boolean run(VerbRunner cb) {
float scale = EngineAssetManager.getInstance().getScale();
BaseActor a = World.getInstance().getCurrentScene().getActor(actor, true);
float x = a.getX();
float y = a.getY();
if (target != null) {
BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
x = target.getX();
y = target.getY();
if (target instanceof InteractiveActor) {
Vector2 refPoint = ((InteractiveActor) target).getRefPoint();
x += refPoint.x;
y += refPoint.y;
}
if (pos != null) {
x += pos.x * scale;
y += pos.y * scale;
}
} else if (pos != null) {
x = pos.x * scale;
y = pos.y * scale;
}
if (speed == 0 || !(a instanceof SpriteActor)) {
a.setPosition(x, y);
return false;
} else {
// WARNING: only spriteactors support animation
float s;
if (mode != null && mode == Mode.SPEED) {
Vector2 p0 = new Vector2(a.getX(), a.getY());
s = p0.dst(x, y) / (scale * speed);
} else {
s = speed;
}
SpritePosTween t = new SpritePosTween();
t.start((SpriteActor) a, repeat, count, x, y, s, interpolation, wait ? cb : null);
((SpriteActor) a).addTween(t);
}
return wait;
}
use of com.bladecoder.engine.model.BaseActor 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.BaseActor in project bladecoder-adventure-engine by bladecoder.
the class GotoAction method run.
@Override
public boolean run(VerbRunner cb) {
CharacterActor actor = (CharacterActor) World.getInstance().getCurrentScene().getActor(this.actor, false);
float x = actor.getX();
float y = actor.getY();
if (target != null) {
BaseActor target = World.getInstance().getCurrentScene().getActor(this.target, false);
x = target.getX();
y = target.getY();
if (target instanceof InteractiveActor) {
Vector2 refPoint = ((InteractiveActor) target).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();
x = pos.x * scale;
y = pos.y * scale;
}
actor.goTo(new Vector2(x, y), wait ? cb : null, ignoreWalkZone);
return wait;
}
Aggregations