Class Player

  • Direct Known Subclasses:
    Ghost, PacMan

    public class Player
    extends java.lang.Object
    • Field Detail

      • position

        public java.awt.geom.Point2D.Float position
      • speed

        protected float speed
      • 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