public abstract class AbstractPerson
extends com.badlogic.gdx.graphics.g2d.Sprite
Modifier and Type | Class and Description |
---|---|
static class |
AbstractPerson.Direction
This is used to describe the direction the person is currently facing or moving in.
|
static class |
AbstractPerson.Personality
These are the possible personalities of the person
|
static class |
AbstractPerson.PersonPositionComparator
This class is to sort a list of AbstractPerson in highest Y coordinate to lowest Y coordinate
|
static class |
AbstractPerson.PersonState
The state of the person explains what they are currently doing.
|
Modifier and Type | Field and Description |
---|---|
protected float |
animTime |
protected float |
animTimer
The following variables control the walking animation speed
|
boolean |
canMove
This is whether the NPC can move or not.
|
protected com.badlogic.gdx.math.Vector2 |
coordinates
This is the players location in the current room.
|
protected com.badlogic.gdx.graphics.g2d.TextureRegion |
currentRegion
This stores the current region of the above texture that is to be drawn
to the map
|
private Room |
currentRoom
The current room of the AbstractPerson.
|
protected Vector2Int |
destinationTile
A store of the destination for a movement.
|
protected AbstractPerson.Direction |
direction
The direction determines the way the character is facing.
|
protected com.badlogic.gdx.utils.JsonValue |
jsonData
This is the JSON data for the Player/NPC
|
private java.lang.String |
name
The Name of the Person
|
protected static int |
SPRITE_HEIGHT
The height of the texture region for each person
|
protected static int |
SPRITE_WIDTH
The width of the texture region for each person
|
protected com.badlogic.gdx.graphics.Texture |
spriteSheet
This stores the sprite sheet of the Player/NPC
|
protected Vector2Int |
startTile
A store of the starting point for a movement.
|
protected AbstractPerson.PersonState |
state
This is the current walking state of the Person.
|
protected Vector2Int |
tileCoordinates
This is the location of the person in the room in terms of tiles eg (0,0) would be the bottom left of the room
Uses the Vector2Int as the tileCoordinates should never be floats as the person should only be between tiles during the move process.
|
Constructor and Description |
---|
AbstractPerson(java.lang.String name,
java.lang.String img,
int tileX,
int tileY)
This constructs the player calling super on the sprite class
|
Modifier and Type | Method and Description |
---|---|
void |
finishMove()
Finalises the move by resetting the animation timer and setting the state back to standing.
|
AbstractPerson.Direction |
getDirection()
Getter for direction.
|
java.lang.String |
getName()
This method returns the Persons name as a String
|
abstract AbstractPerson.Personality |
getPersonality()
This returns the persons personality
|
Room |
getRoom()
This method returns the room that the Person is in
|
java.lang.String |
getSpeech(Clue clue)
This method returns the response based on the clue given
|
abstract java.lang.String |
getSpeech(Clue clue,
AbstractPerson.Personality style)
This handles speech for a clue that has a question style
|
java.lang.String |
getSpeech(java.lang.String key)
Gets a random item from the correct dictionary key.
|
AbstractPerson.PersonState |
getState()
This method returns the Persons walking state.
|
Vector2Int |
getTileCoordinates()
This method gets the Persons tile coordinates
|
abstract void |
importDialogue(java.lang.String fileName)
Reads in the JSON file of tha character and stores dialogue in the dialogue HashMap
|
void |
initialiseMove(AbstractPerson.Direction dir)
Sets up the move, initialising the start position and destination as well as the state of the person.
|
void |
pushCoordinatesToSprite()
This method moves the coordinates in the AbstractPersons coordinates to
the Sprites position so that it can then be rendered at the correct location.
|
void |
setAnimTime(float animTime)
Setter for the animation time.
|
private void |
setCoords(float x,
float y)
Used internally to store the coordinates of the person.
|
void |
setDirection(AbstractPerson.Direction dir)
Setter for the direction the person is facing.
|
void |
setRoom(Room room)
This method sets the currentRoom to the room parameter
|
void |
setTileCoordinates(int x,
int y)
This sets the tile coordinates of the person.
|
void |
update()
This is called to update the players position.
|
void |
updateTextureRegion()
Updates the texture region based upon how far though the animation time it is.
|
draw, draw, flip, getBoundingRectangle, getColor, getHeight, getOriginX, getOriginY, getRotation, getScaleX, getScaleY, getVertices, getWidth, getX, getY, rotate, rotate90, scale, scroll, set, setAlpha, setBounds, setCenter, setCenterX, setCenterY, setColor, setColor, setColor, setFlip, setOrigin, setOriginCenter, setPosition, setRegion, setRotation, setScale, setScale, setSize, setU, setU2, setV, setV2, setX, setY, translate, translateX, translateY
getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, split, split
protected static int SPRITE_HEIGHT
protected static int SPRITE_WIDTH
public boolean canMove
protected Vector2Int tileCoordinates
protected com.badlogic.gdx.math.Vector2 coordinates
protected Vector2Int startTile
protected Vector2Int destinationTile
protected float animTimer
protected float animTime
protected com.badlogic.gdx.graphics.Texture spriteSheet
protected com.badlogic.gdx.graphics.g2d.TextureRegion currentRegion
protected com.badlogic.gdx.utils.JsonValue jsonData
protected AbstractPerson.Direction direction
protected AbstractPerson.PersonState state
getState()
private java.lang.String name
private Room currentRoom
public AbstractPerson(java.lang.String name, java.lang.String img, int tileX, int tileY)
name
- - The name of the Personimg
- - this a path to the sprite sheet imagetileX
- - This is the start x coordinate for the PersontileY
- - This is the start y coordinate for the Personpublic void pushCoordinatesToSprite()
public AbstractPerson.PersonState getState()
public void setTileCoordinates(int x, int y)
x
- The x coordinate of the tile grid.y
- The y coordinate of the tile grid.public void update()
public void initialiseMove(AbstractPerson.Direction dir)
dir
- the direction that the person is moving in.public void finishMove()
public abstract void importDialogue(java.lang.String fileName)
fileName
- public java.lang.String getSpeech(java.lang.String key)
key
- public java.lang.String getSpeech(Clue clue)
clue
- - The clue to get the response forpublic abstract java.lang.String getSpeech(Clue clue, AbstractPerson.Personality style)
clue
- the clue to be questioned aboutstyle
- the style of questioningpublic void updateTextureRegion()
private void setCoords(float x, float y)
x
- the x coordinate you wish to storey
- the y coordinate you wish to storepublic abstract AbstractPerson.Personality getPersonality()
public java.lang.String getName()
name
public AbstractPerson.Direction getDirection()
public void setDirection(AbstractPerson.Direction dir)
dir
- - Desired direction for the person to face.public void setAnimTime(float animTime)
animTime
- - The animation time you want to set.public Room getRoom()
currentRoom
public void setRoom(Room room)
room
- - The room to change currentRoom to currentRoom
public Vector2Int getTileCoordinates()
tileCoordinates