Package pacManReloaded.server
Class Player
- java.lang.Object
-
- pacManReloaded.server.Player
-
-
Field Summary
Fields Modifier and Type Field Description Direction
direction
protected INavigator
navigator
java.awt.geom.Point2D.Float
position
protected float
speed
java.awt.geom.Point2D.Float
startPoint
-
Constructor Summary
Constructors Constructor Description Player()
Player(ServerThread client)
Constructor of the Player
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
changePosition()
checks the direction of the player, if possible the position of the player will be updatedvoid
gameFinished(boolean gameResult)
method which handles the finished gameServerThread
getClient()
"getter" for the client(thread)Direction
getDirection()
"getter" for the direction of the playerlong
getMsgSentTime()
"getter" for the message send timePlayerState
getState()
"getter" for the state of the playervoid
nextMove()
void
sendActorPosition(java.util.ArrayList<Player> players)
sends the position of the player and updates itvoid
sendBeginFailed()
sends the message for the failed begin of a game to the playervoid
sendGameState(GameState gameState)
updates the game state and sends itvoid
sendInitGameState(GameState gameState)
initialization of the gamestate, sets the status and send itvoid
sendInitPlayer(java.util.ArrayList<Player> players)
initialization of the players, decides type of the actor, if PacMan or Ghostvoid
sendMap(Map map)
creates the map and sends it, sets postions of each objectvoid
sendRemoveObject(Ball o)
updates the removal of an object, when a PacMan collects a ballvoid
setDirection(Direction direction)
"setter" for the direction of a playervoid
setPosition(java.awt.geom.Point2D.Float point)
"setter" for the position of an objectvoid
setStartPoint(java.awt.geom.Point2D.Float point)
"setter" for the starting point of a playervoid
setState(PlayerState state)
"setter" for the state of the player
-
-
-
Field Detail
-
direction
public Direction direction
-
position
public java.awt.geom.Point2D.Float position
-
speed
protected float speed
-
navigator
protected INavigator navigator
-
startPoint
public java.awt.geom.Point2D.Float startPoint
-
-
Constructor Detail
-
Player
public Player(ServerThread client)
Constructor of the Player- Parameters:
client
- thread of the client
-
Player
public Player()
-
-
Method Detail
-
getClient
public ServerThread getClient()
"getter" for the client(thread)- Returns:
- the (thread of the) client
-
getState
public PlayerState getState()
"getter" for the state of the player- Returns:
- state of the player
-
sendMap
public void sendMap(Map map)
creates the map and sends it, sets postions of each object- Parameters:
map
- the map
-
sendInitPlayer
public void sendInitPlayer(java.util.ArrayList<Player> players)
initialization of the players, decides type of the actor, if PacMan or Ghost- Parameters:
players
- list of all players
-
sendInitGameState
public void sendInitGameState(GameState gameState)
initialization of the gamestate, sets the status and send it- Parameters:
gameState
- current game state
-
sendRemoveObject
public void sendRemoveObject(Ball o)
updates the removal of an object, when a PacMan collects a ball- Parameters:
o
- ball to remove
-
sendGameState
public void sendGameState(GameState gameState)
updates the game state and sends it
-
sendActorPosition
public void sendActorPosition(java.util.ArrayList<Player> players)
sends the position of the player and updates it
-
setState
public void setState(PlayerState state)
"setter" for the state of the player- Parameters:
state
- state of the player
-
getMsgSentTime
public long getMsgSentTime()
"getter" for the message send time- Returns:
- the sending time of the message
-
sendBeginFailed
public void sendBeginFailed()
sends the message for the failed begin of a game to the player
-
gameFinished
public void gameFinished(boolean gameResult)
method which handles the finished game- Parameters:
gameResult
- - gives the result as boolean. true equals a win and false equals a loss.
-
changePosition
protected void changePosition()
checks the direction of the player, if possible the position of the player will be updated
-
nextMove
public void nextMove()
-
setStartPoint
public void setStartPoint(java.awt.geom.Point2D.Float point)
"setter" for the starting point of a player- Parameters:
point
- the position of the map (startpoint)
-
setPosition
public void setPosition(java.awt.geom.Point2D.Float point)
"setter" for the position of an object- Parameters:
point
- the position of the map
-
getDirection
public Direction getDirection()
"getter" for the direction of the player- Returns:
- the direction
-
setDirection
public void setDirection(Direction direction)
"setter" for the direction of a player- Parameters:
direction
- players direction
-
-