public abstract class OdorWorldEntity
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Behavior |
behavior
Behavior.
|
protected float |
dx
X Velocity.
|
protected float |
dy
Y Velocity.
|
protected float |
x
X Position.
|
protected float |
y
Y Position.
|
Constructor and Description |
---|
OdorWorldEntity(Animation anim,
OdorWorld world)
Construct an entity from an animation.
|
OdorWorldEntity(OdorWorld world)
Construct an entity.
|
OdorWorldEntity(java.lang.String imageLocation,
OdorWorld world)
Construct an odor world entity from a single image location.
|
Modifier and Type | Method and Description |
---|---|
void |
addEffector(Effector effector)
Add an effector.
|
void |
addSensor(Sensor sensor)
Add a sensor.
|
void |
addTileSensors(int numTilesX,
int numTilesY)
Add a grid of tile sensors.
|
void |
addTileSensors(int numTilesX,
int numTilesY,
int offset)
Add a grid of tile sensors, offset by some fraction of a tile's length.
|
void |
applyEffectors()
Apply impact of all effectors.
|
void |
collideHorizontal()
Called before update() if the creature collided with a tile horizontally.
|
void |
collideVertical()
Called before update() if the creature collided with a tile vertically.
|
Animation |
getAnimation() |
Behavior |
getBehavior()
Return the current behavior.
|
java.awt.Rectangle |
getBounds()
Get bounds, based on current image.
|
double[] |
getCenterLocation()
Returns the location of the center of this entity as a double array.
|
double |
getCenterX()
Returns the center x position of this entity.
|
double |
getCenterY()
Returns the center y position of this entity.
|
java.util.List<java.lang.String> |
getCurrentlyHeardPhrases() |
double |
getDoubleX()
Get the X position as a double.
|
double |
getDoubleY()
Get the Y position as a double.
|
java.util.List<Effector> |
getEffectors() |
int |
getHeight()
Gets this OdorWorldEntity's height, based on the size of the current
image.
|
java.lang.String |
getId() |
java.awt.Image |
getImage()
Gets this OdorWorldEntity's current image.
|
double[] |
getLocation()
Returns the location of the entity as a double array.
|
java.lang.String |
getName()
Get the entity's name.
|
OdorWorld |
getParentWorld() |
java.awt.Rectangle |
getReducedBounds()
Reduced bounds used for some entities, to improve the look of collisions
and blocking.
|
java.util.List<Sensor> |
getSensors() |
SmellSource |
getSmellSource() |
float |
getVelocityX()
Gets the horizontal velocity of this OdorWorldEntity in pixels per
millisecond.
|
float |
getVelocityY()
Gets the vertical velocity of this OdorWorldEntity in pixels per
millisecond.
|
int |
getWidth()
Gets this OdorWorldEntity's width, based on the size of the current
image.
|
float |
getX()
Gets this OdorWorldEntity's current x position.
|
float |
getY()
Gets this OdorWorldEntity's current y position.
|
boolean |
hasCollided() |
boolean |
isBlocked()
Returns true if the entity is blocked from moving.
|
boolean |
isEffectorsEnabled() |
boolean |
isInBoundsX(float x)
Check whether, if the provided point is used to set the x (upper left)
coordinate of the entity, the bounds of the object will be in bounds.
|
boolean |
isInBoundsY(float y)
Check whether, if the provided point is used to set the y (upper left)
coordinate of the entity, the bounds of the object will be in bounds.
|
boolean |
isSensorsEnabled() |
boolean |
isShowSensors() |
void |
moveEast(double amount)
Move the object east by the specified amount in pixels.
|
void |
moveNorth(double amount)
Move the object north by the specified amount in pixels.
|
void |
moveSouth(double amount)
Move the object south by the specified amount in pixels.
|
void |
moveWest(double amount)
Move the object west by the specified amount in pixels.
|
void |
postSerializationInit()
Initialize the animation from stored image location(s).
|
void |
removeEffector(Effector effector)
Removes an effector.
|
void |
removeSensor(Sensor sensor)
Removes a sensor.
|
void |
setAnimation(Animation animation) |
void |
setCenterLocation(float x,
float y)
Set the location of this entity.
|
void |
setEffectors(java.util.List<Effector> effectors) |
void |
setEffectorsEnabled(boolean effectorsEnabled) |
void |
setHasCollided(boolean collission) |
void |
setId(java.lang.String id) |
void |
setLocation(float x,
float y)
Set the location of this entity.
|
void |
setName(java.lang.String name)
Set the entity's name.
|
void |
setSensors(java.util.List<Sensor> sensors) |
void |
setSensorsEnabled(boolean sensorsEnabled) |
void |
setShowSensors(boolean showSensors) |
void |
setSmellSource(SmellSource smellSource) |
void |
setVelocityX(float dx)
Sets the horizontal velocity of this OdorWorldEntity in pixels per
millisecond.
|
void |
setVelocityY(float dy)
Sets the vertical velocity of this OdorWorldEntity in pixels per
millisecond.
|
void |
setX(double x) |
void |
setX(float newx)
Sets this OdorWorldEntity's current x position.
|
void |
setY(double y) |
void |
setY(float newy)
Sets this OdorWorldEntity's current y position.
|
void |
speakToEntity(java.lang.String phrase)
Add a phrase to the list of things currently being said.
|
void |
update()
Updates this OdorWorldEntity's Animation and its position based on the
velocity.
|
void |
updateSensors()
Update all sensors.
|
void |
updateSmellSource()
Update this object's smell source, if any.
|
protected float x
protected float y
protected float dx
protected float dy
protected Behavior behavior
public OdorWorldEntity(Animation anim, OdorWorld world)
anim
- animation to use.world
- parent worldpublic OdorWorldEntity(java.lang.String imageLocation, OdorWorld world)
imageLocation
- the image locationworld
- public OdorWorldEntity(OdorWorld world)
world
- parent world of entitypublic void update()
public void collideHorizontal()
public void collideVertical()
public float getX()
public float getY()
public void setX(float newx)
newx
- public void setY(float newy)
newy
- public boolean isInBoundsX(float x)
x
- the point to checkpublic boolean isInBoundsY(float y)
y
- the point to checkpublic int getWidth()
public int getHeight()
public float getVelocityX()
public float getVelocityY()
public void setVelocityX(float dx)
dx
- public void setVelocityY(float dy)
dy
- public java.lang.String getName()
public void setName(java.lang.String name)
name
- string name for entity.public java.lang.String getId()
public void setId(java.lang.String id)
id
- the id to setpublic java.awt.Image getImage()
public java.awt.Rectangle getBounds()
public java.awt.Rectangle getReducedBounds()
public void addEffector(Effector effector)
effector
- effector to addpublic void removeEffector(Effector effector)
effector
- effector to removepublic void addSensor(Sensor sensor)
sensor
- sensor to addpublic void removeSensor(Sensor sensor)
sensor
- sensor to removepublic void applyEffectors()
public void updateSensors()
public void addTileSensors(int numTilesX, int numTilesY)
numTilesX
- number of rows in gridnumTilesY
- number of columns in gridpublic void addTileSensors(int numTilesX, int numTilesY, int offset)
numTilesX
- number of rows in gridnumTilesY
- number of columns in gridoffset
- offset amount in pixelspublic SmellSource getSmellSource()
public void setSmellSource(SmellSource smellSource)
smellSource
- the smellSource to setpublic OdorWorld getParentWorld()
public double[] getCenterLocation()
public double getCenterX()
public double getCenterY()
public void setCenterLocation(float x, float y)
x
- x coordinatey
- y coordinatepublic double[] getLocation()
public void setLocation(float x, float y)
x
- x coordinatey
- y coordinatepublic Animation getAnimation()
public void setAnimation(Animation animation)
animation
- the animation to setpublic void postSerializationInit()
public java.util.List<Sensor> getSensors()
public void setSensors(java.util.List<Sensor> sensors)
sensors
- the sensors to setpublic java.util.List<Effector> getEffectors()
public void setEffectors(java.util.List<Effector> effectors)
effectors
- the effectors to setpublic boolean hasCollided()
public void setHasCollided(boolean collission)
collission
- the collision to setpublic boolean isSensorsEnabled()
public void setSensorsEnabled(boolean sensorsEnabled)
sensorsEnabled
- the sensorsEnabled to setpublic boolean isEffectorsEnabled()
public void setEffectorsEnabled(boolean effectorsEnabled)
effectorsEnabled
- the effectorsEnabled to setpublic boolean isShowSensors()
public void setShowSensors(boolean showSensors)
showSensors
- the showSensors to setpublic boolean isBlocked()
public Behavior getBehavior()
public void moveNorth(double amount)
amount
- amount to move bypublic void moveSouth(double amount)
amount
- amount to move bypublic void moveEast(double amount)
amount
- amount to move bypublic void moveWest(double amount)
amount
- amount to move bypublic double getDoubleX()
public double getDoubleY()
public void setX(double x)
x
- the x to setpublic void setY(double y)
y
- the y to setpublic void updateSmellSource()
public void speakToEntity(java.lang.String phrase)
phrase
- the phrase to addpublic java.util.List<java.lang.String> getCurrentlyHeardPhrases()