Package pacManReloaded.server
Class Player
- java.lang.Object
-
- pacManReloaded.server.Player
-
-
Field Summary
Fields Modifier and Type Field Description Directiondirectionprotected INavigatornavigatorjava.awt.geom.Point2D.Floatpositionprotected floatspeedjava.awt.geom.Point2D.FloatstartPoint
-
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 voidchangePosition()checks the direction of the player, if possible the position of the player will be updatedvoidgameFinished(boolean gameResult)method which handles the finished gameServerThreadgetClient()"getter" for the client(thread)DirectiongetDirection()"getter" for the direction of the playerlonggetMsgSentTime()"getter" for the message send timePlayerStategetState()"getter" for the state of the playervoidnextMove()voidsendActorPosition(java.util.ArrayList<Player> players)sends the position of the player and updates itvoidsendBeginFailed()sends the message for the failed begin of a game to the playervoidsendGameState(GameState gameState)updates the game state and sends itvoidsendInitGameState(GameState gameState)initialization of the gamestate, sets the status and send itvoidsendInitPlayer(java.util.ArrayList<Player> players)initialization of the players, decides type of the actor, if PacMan or GhostvoidsendMap(Map map)creates the map and sends it, sets postions of each objectvoidsendRemoveObject(Ball o)updates the removal of an object, when a PacMan collects a ballvoidsetDirection(Direction direction)"setter" for the direction of a playervoidsetPosition(java.awt.geom.Point2D.Float point)"setter" for the position of an objectvoidsetStartPoint(java.awt.geom.Point2D.Float point)"setter" for the starting point of a playervoidsetState(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
-
-