Package pacManReloaded.server
Class GameLogic
- java.lang.Object
-
- pacManReloaded.server.GameLogic
-
- All Implemented Interfaces:
INavigator
public class GameLogic extends java.lang.Object implements INavigator
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkSuperPower()
checks if super power is active, while active the ghosts will get a message so they know the PacMans are able to hunt themvoid
collisionWithBallGhost(Ball o)
handles the collision by a ghost with a ball, updates score and the game state, removes the ball on the mapvoid
collisionWithBallPacMan(Ball o)
handles the collision by a pacman with a ball, updates score and the game state, removes the ball on the mapvoid
collisionWithPowerballGhost(PowerBall o)
handles the collision by a ghost with a powerball, updates score and the game state, removes the ball on the mapvoid
collisionWithPowerballPacMan(PowerBall o)
handles the collision by a pacman with a powerball, updates score and the game state, removes the ball on the mapvoid
createBall(java.awt.geom.Point2D.Float point)
creates new ball and adds it to the appropriate listvoid
detectCollisions()
this method finds out of the next step of an actor is a collision with another object/wallvoid
doPlay()
decides which part of the game will happens next, depending on the game statusjava.awt.geom.Point2D.Float
getExitPosition()
GameState
getGameState()
"getter" for the game stateGameStatus
getGameStatus()
"getter" for the game statusfloat
getMapSize()
java.lang.Object
getObjectAtPosition(java.awt.geom.Point2D.Float position)
PacMan
getPacman()
"getter" for the PacMansjava.awt.geom.Point2D.Float
getPacmanPosition()
boolean
isDone()
method which checks if the game is over/doneboolean
isInSpawn(Ghost ghost)
void
nextMove()
allows all actors to perform their next step, in addition, calls the operation checkSuperPower() and detectCollision().void
removeObject(Ball o)
removes the object from the mapvoid
setGameStatus(GameStatus gameStatus)
"setter" for the game status
-
-
-
Constructor Detail
-
GameLogic
public GameLogic(java.util.ArrayList<Player> players, Server server)
Constructor of the Class, starts a game with the players and server as parameters- Parameters:
players
- the players who will be in the game as arraylistserver
- the server where the game will be played on
-
GameLogic
public GameLogic()
Dummy-Constructor for Unit tests
-
-
Method Detail
-
nextMove
public void nextMove()
allows all actors to perform their next step, in addition, calls the operation checkSuperPower() and detectCollision().
-
detectCollisions
public void detectCollisions()
this method finds out of the next step of an actor is a collision with another object/wall
-
collisionWithPowerballPacMan
public void collisionWithPowerballPacMan(PowerBall o)
handles the collision by a pacman with a powerball, updates score and the game state, removes the ball on the map- Parameters:
o
- the powerball on the map
-
collisionWithPowerballGhost
public void collisionWithPowerballGhost(PowerBall o)
handles the collision by a ghost with a powerball, updates score and the game state, removes the ball on the map- Parameters:
o
- the powerball on the map
-
removeObject
public void removeObject(Ball o)
removes the object from the map- Parameters:
o
- the object getting removed
-
collisionWithBallPacMan
public void collisionWithBallPacMan(Ball o)
handles the collision by a pacman with a ball, updates score and the game state, removes the ball on the map- Parameters:
o
- the ball on the map
-
collisionWithBallGhost
public void collisionWithBallGhost(Ball o)
handles the collision by a ghost with a ball, updates score and the game state, removes the ball on the map- Parameters:
o
- the ball on the map
-
getPacman
public PacMan getPacman()
"getter" for the PacMans- Returns:
- players who are PacMans
-
checkSuperPower
public void checkSuperPower()
checks if super power is active, while active the ghosts will get a message so they know the PacMans are able to hunt them
-
createBall
public void createBall(java.awt.geom.Point2D.Float point)
creates new ball and adds it to the appropriate list
-
doPlay
public void doPlay()
decides which part of the game will happens next, depending on the game status
-
isDone
public boolean isDone()
method which checks if the game is over/done- Returns:
- true: game is over; false: game not over yet
-
getGameStatus
public GameStatus getGameStatus()
"getter" for the game status- Returns:
- the actual game status
-
setGameStatus
public void setGameStatus(GameStatus gameStatus)
"setter" for the game status- Parameters:
gameStatus
- the game status
-
getObjectAtPosition
public java.lang.Object getObjectAtPosition(java.awt.geom.Point2D.Float position)
- Specified by:
getObjectAtPosition
in interfaceINavigator
-
getMapSize
public float getMapSize()
- Specified by:
getMapSize
in interfaceINavigator
-
getPacmanPosition
public java.awt.geom.Point2D.Float getPacmanPosition()
- Specified by:
getPacmanPosition
in interfaceINavigator
-
getExitPosition
public java.awt.geom.Point2D.Float getExitPosition()
- Specified by:
getExitPosition
in interfaceINavigator
-
isInSpawn
public boolean isInSpawn(Ghost ghost)
- Specified by:
isInSpawn
in interfaceINavigator
-
getGameState
public GameState getGameState()
"getter" for the game state- Returns:
- the current game state
-
-