Class Trigger
java.lang.Object
de.gurkenlabs.litiengine.entities.Entity
de.gurkenlabs.litiengine.entities.CollisionEntity
de.gurkenlabs.litiengine.entities.Trigger
- All Implemented Interfaces:
EntityRenderedListener,EntityRenderListener,ICollisionEntity,IEntity,IUpdateable,Tweenable,EventListener
TODO: Triggers should be able to call entity actions (similar to the current message approach)
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class de.gurkenlabs.litiengine.entities.Entity
ANY_MESSAGE -
Constructor Summary
ConstructorsConstructorDescriptionTrigger(Trigger.TriggerActivation activation, String message) Instantiates a newTriggerentity.Trigger(Trigger.TriggerActivation activation, String message, boolean isOneTime) Instantiates a newTriggerentity.Trigger(Trigger.TriggerActivation activation, String message, boolean isOneTime, int cooldown) Initializes a new instance of theTriggerclass.Trigger(Trigger.TriggerActivation activation, String name, String message) Instantiates a newTriggerentity.Trigger(Trigger.TriggerActivation activation, String name, String message, boolean isOneTime) Instantiates a newTriggerentity. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddActivatedListener(TriggerActivatedListener listener) voidaddActivatingCondition(TriggerActivatingCondition condition) voidaddActivator(int mapId) voidaddActivator(IEntity activator) voidvoidaddTarget(int mapId) voidvoidaddTriggerListener(TriggerListener listener) booleancanTrigger(ICollisionEntity entity) Checks whether the specified entity can interact with this trigger.intbooleanbooleanbooleanvoidvoidvoidvoidremoveTriggerListener(TriggerListener listener) voidsetCooldown(int cooldown) voidsetHeight(double height) voidsetMessage(String message) voidsetSize(double width, double height) voidsetWidth(double width) voidupdate()This method is called by the game loop on all objects that are attached to the loop.Methods inherited from class de.gurkenlabs.litiengine.entities.CollisionEntity
canCollideWith, fireCollisionEvent, getCollisionBox, getCollisionBox, getCollisionBox, getCollisionBoxAlign, getCollisionBoxCenter, getCollisionBoxHeight, getCollisionBoxValign, getCollisionBoxWidth, getCollisionType, getTweenValues, hasCollision, onCollision, refreshCollisionBox, removeCollisionListener, setCollision, setCollisionBoxAlign, setCollisionBoxHeight, setCollisionBoxValign, setCollisionBoxWidth, setCollisionType, setLocation, setTweenValuesMethods inherited from class de.gurkenlabs.litiengine.entities.Entity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, canRender, detachControllers, getAngle, getBoundingBox, getCenter, getController, getControllers, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, rendered, rendering, renderWithLayer, sendMessage, setAngle, setController, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setVisible, setX, setY, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface de.gurkenlabs.litiengine.entities.IEntity
actions, addController, addEntityRenderListener, addListener, addTag, addTransformListener, animations, attachControllers, behavior, detachControllers, getAngle, getBoundingBox, getCenter, getController, getEnvironment, getHeight, getLocation, getMapId, getName, getProperties, getRenderType, getTags, getWidth, getX, getY, hasTag, isLoaded, isVisible, loaded, onMessage, onMessage, onRendered, perform, register, removed, removeListener, removeListener, removeListener, removeListener, removeListener, removeTag, renderWithLayer, sendMessage, setAngle, setController, setLocation, setMapId, setName, setRenderType, setRenderWithLayer, setVisible, setX, setY
-
Constructor Details
-
Trigger
Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.message- The message that gets sent by this trigger upon activation.
-
Trigger
Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.name- The name of this trigger.message- The message that gets sent by this trigger upon activation.
-
Trigger
Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.message- The message that gets sent by this trigger upon activation.isOneTime- A flag, indicating whether this instance can only be triggered once.
-
Trigger
public Trigger(Trigger.TriggerActivation activation, String name, String message, boolean isOneTime) Instantiates a newTriggerentity.- Parameters:
activation- The activation method for this trigger.name- The name of this trigger.message- The message that gets sent by this trigger upon activation.isOneTime- A flag, indicating whether this instance can only be triggered once.
-
Trigger
public Trigger(Trigger.TriggerActivation activation, String message, boolean isOneTime, int cooldown) Initializes a new instance of theTriggerclass.- Parameters:
activation- The activation method for this trigger.message- The message that gets sent by this trigger upon activation.isOneTime- A flag, indicating whether this instance can only be triggered once.cooldown- The cooldown that needs to be respected between two activation events.
-
-
Method Details
-
addTriggerListener
-
removeTriggerListener
-
addActivatedListener
-
removeActivatedListener
-
addActivatingCondition
-
removeActivatingCondition
-
addDeactivatedListener
-
removeDeactivatedListener
-
addActivator
public void addActivator(int mapId) -
addActivator
-
addTarget
public void addTarget(int mapId) -
addTarget
-
getActivationType
-
getActivators
-
getMessage
-
getTargets
-
getCooldown
public int getCooldown() -
canTrigger
Checks whether the specified entity can interact with this trigger.- Parameters:
entity- The entity.- Returns:
- True if the entity can interact with the trigger; otherwise false.
-
isOneTimeTrigger
public boolean isOneTimeTrigger() -
isActivated
public boolean isActivated() -
interact
-
setMessage
-
setHeight
public void setHeight(double height) - Specified by:
setHeightin interfaceIEntity- Overrides:
setHeightin classCollisionEntity
-
setWidth
public void setWidth(double width) - Specified by:
setWidthin interfaceIEntity- Overrides:
setWidthin classCollisionEntity
-
setSize
public void setSize(double width, double height) - Specified by:
setSizein interfaceIEntity- Overrides:
setSizein classCollisionEntity
-
setCooldown
public void setCooldown(int cooldown) -
update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
-