use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class DefaultSceneScreen method sceneClick.
private void sceneClick(int button, int count) {
World w = World.getInstance();
w.getSceneCamera().getInputUnProject(viewport, unprojectTmp);
Scene s = w.getCurrentScene();
CharacterActor player = s.getPlayer();
if (currentActor != null) {
if (EngineLogger.debugMode()) {
EngineLogger.debug(currentActor.toString());
}
// DOUBLE CLICK: Fastwalk when leaving scene.
if (count > 1) {
if (count == 2 && fastLeave && !recorder.isRecording() && player != null && currentActor.getVerb(Verb.LEAVE_VERB) != null) {
player.fastWalk();
}
return;
}
actorClick(currentActor, button);
} else if (player != null) {
if (count > 1)
return;
if (s.getPlayer().getVerb("goto") != null) {
runVerb(s.getPlayer(), "goto", null);
} else {
Vector2 pos = new Vector2(unprojectTmp.x, unprojectTmp.y);
if (recorder.isRecording()) {
recorder.add(pos);
}
player.goTo(pos, null, false);
}
}
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class SayDialogAction method resume.
@Override
public void resume() {
World w = World.getInstance();
BaseActor actor = w.getCurrentScene().getActor(characterName, false);
if (characterTurn) {
characterTurn = false;
if (previousAnim != null) {
SpriteActor player = World.getInstance().getCurrentScene().getPlayer();
player.startAnimation(previousAnim, null);
}
if (responseText != null) {
Rectangle boundingRectangle = actor.getBBox().getBoundingRectangle();
float x = boundingRectangle.getX() + boundingRectangle.getWidth() / 2;
float y = boundingRectangle.getY() + boundingRectangle.getHeight();
World.getInstance().getTextManager().addText(responseText, x, y, false, Text.Type.TALK, ((CharacterActor) actor).getTextColor(), null, actor.getId(), responseVoiceId, this);
if (actor instanceof CharacterActor) {
startTalkAnim((CharacterActor) actor);
}
} else {
previousAnim = null;
super.resume();
}
} else {
if (actor instanceof SpriteActor && previousAnim != null) {
((SpriteActor) actor).startAnimation(previousAnim, null);
}
super.resume();
}
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class SetActorAttrAction method run.
@Override
public boolean run(VerbRunner cb) {
Scene s = actor.getScene();
BaseActor a = s.getActor(actor.getActorId(), true);
if (a == null) {
EngineLogger.error("SetActorAttr - Actor not found:" + this.actor.getActorId());
return false;
}
if (visible != null)
a.setVisible(visible);
if (interaction != null) {
if (a instanceof InteractiveActor)
((InteractiveActor) a).setInteraction(interaction);
else
EngineLogger.error("'Interaction' property not supported for actor:" + a.getId());
}
if (layer != null) {
if (a instanceof InteractiveActor) {
InteractiveActor iActor = (InteractiveActor) a;
String oldLayer = iActor.getLayer();
s.getLayer(oldLayer).remove(iActor);
iActor.setLayer(layer);
SceneLayer l = s.getLayer(layer);
l.add(iActor);
if (!l.isDynamic())
l.orderByZIndex();
} else
EngineLogger.error("'layer' property not supported for actor:" + a.getId());
}
if (zIndex != null) {
if (a instanceof InteractiveActor) {
InteractiveActor iActor = (InteractiveActor) a;
iActor.setZIndex(zIndex);
SceneLayer l = s.getLayer(iActor.getLayer());
if (!l.isDynamic())
l.orderByZIndex();
} else
EngineLogger.error("'zIndex' property not supported for actor:" + a.getId());
}
if (scale != null) {
if (a instanceof SpriteActor)
((SpriteActor) a).setScale(scale);
else
EngineLogger.error("'scale' property not supported for actor:" + a.getId());
}
if (rotation != null) {
if (a instanceof SpriteActor)
((SpriteActor) a).setRot(rotation);
else
EngineLogger.error("'rotation' property not supported for actor:" + a.getId());
}
if (tint != null) {
if (a instanceof SpriteActor)
((SpriteActor) a).setTint(tint);
else
EngineLogger.error("'tint' property not supported for actor:" + a.getId());
}
if (fakeDepth != null) {
if (a instanceof SpriteActor) {
((SpriteActor) a).setFakeDepth(fakeDepth);
} else
EngineLogger.error("'fakeDepth' property not supported for actor:" + a.getId());
}
if (standAnimation != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setStandAnim(standAnimation);
else
EngineLogger.error("'standAnimation' property not supported for actor:" + a.getId());
}
if (walkAnimation != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setWalkAnim(walkAnimation);
else
EngineLogger.error("'walkAnimation' property not supported for actor:" + a.getId());
}
if (talkAnimation != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setTalkAnim(talkAnimation);
else
EngineLogger.error("'talkAnimation' property not supported for actor:" + a.getId());
}
if (walkingSpeed != null) {
if (a instanceof CharacterActor)
((CharacterActor) a).setWalkingSpeed(walkingSpeed);
else
EngineLogger.error("'walkingSpeed' property not supported for actor:" + a.getId());
}
if (uiActor != null) {
if (a instanceof InteractiveActor) {
if (uiActor)
setUIActor(s, (InteractiveActor) a);
else
removeUIActor(s, (InteractiveActor) a);
} else
EngineLogger.error("'uiActor' property not supported for actor:" + a.getId());
}
return false;
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class SetDialogOptionAttrAction method run.
@Override
public boolean run(VerbRunner cb) {
final Scene s = actor.getScene();
CharacterActor a = (CharacterActor) s.getActor(actor.getActorId(), true);
Dialog d = a.getDialog(dialog);
if (d == null) {
EngineLogger.error("SetDialogOptionAttrAction: Dialog '" + dialog + "' not found");
return false;
}
DialogOption o = d.getOptions().get(option);
if (o == null) {
EngineLogger.error("SetDialogOptionAttrAction: Option '" + option + "' not found");
return false;
}
if (visible != null)
o.setVisible(visible);
return false;
}
use of com.bladecoder.engine.model.CharacterActor in project bladecoder-adventure-engine by bladecoder.
the class TalktoAction method run.
@Override
public boolean run(VerbRunner cb) {
CharacterActor a = (CharacterActor) World.getInstance().getCurrentScene().getActor(actor, false);
World.getInstance().setCurrentDialog(a.getDialog(dialog));
return false;
}
Aggregations