public class GameEngine
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
GameEngine.State
Encodes possible play-states
These are not to be confused with the game-state (which is directly linked to the renderer)
|
Modifier and Type | Field and Description |
---|---|
private static GameEngine |
_instance |
Chancellor |
chancellorGame |
int |
currentPlayerID
Holds the numeric getID of the player who's currently active in the game
|
private Drawer |
drawer
Object providing QOL drawing functions to simplify visual construction and rendering tasks
|
private com.badlogic.gdx.Game |
game
Stores current game-state, enabling transitions between screens and external QOL drawing functions
|
private GameScreen |
gameScreen
The game's engine only ever runs while the main in-game interface is showing, so it was designed to manipulate
elements (both visual and logical in nature) on that screen
It therefore requires access to the public methods in the GameScreen class, so instantiation in this class
is a necessity
|
Market |
market
Holds all of the data and the functions of the game's market
Also comes bundled with a visual interface which can be rendered on to the game's screen
|
private int |
phase
Holds the number of the phase that the game is currently in
Varies between 1 and 6
|
static Player[] |
players
Stores data pertaining to the game's active players
For more information, check the "Player" class
|
private java.util.ArrayList<RandomEvent> |
randomEvents |
private int |
roboticonIDCounter
An integer signifying the ID of the next roboticon to be created
|
private Tile |
selectedTile
Holds the data pertaining to the currently-selected tile
|
private GameEngine.State |
state
Variable dictating whether the game is running or paused at any given moment
|
private Tile[] |
tiles
Array holding the tiles to be laid over the map
Note that the tiles' visuals are encoded by the image declared and stored in the GameScreen class (and not here)
|
private GameTimer |
timer
Timer used to dictate the pace and flow of the game
This has a visual interface which will be displayed in the top-left corner of the game-screen
|
private com.badlogic.gdx.utils.Array<Trade> |
trades |
Constructor and Description |
---|
GameEngine(com.badlogic.gdx.Game game,
GameScreen gameScreen)
Constructs the game's engine.
|
Modifier and Type | Method and Description |
---|---|
void |
addTrade(Trade trade) |
void |
backToGame() |
private void |
chancellor() |
void |
checkEventDurations() |
private boolean |
checkGameEnd()
Returns a value that's true if all tiles have been claimed, and false otherwise
|
void |
claimTile()
Claims the last tile to have been selected on the main GameScreen for the active player
This grants them the ability to plant a Roboticon on it and yield resources from it for themselves
Specifically registers the selected tile under the object holding the active player's data, re-colours its
border for owner identification purposes and moves the game on to the next player/phase
|
void |
closeTrade() |
Player |
currentPlayer()
Returns the data pertaining to the player who is active at the time when this is called
|
int |
currentPlayerID()
Returns the ID of the player who is active at the time when this is called
|
void |
deployRoboticon()
Deploys a Roboticon on the last tile to have been selected
Draws a Roboticon from the active player's Roboticon count and assigns it to the tile in question
|
boolean |
eventCurrentlyHappening(java.lang.Integer eventValue) |
Trade |
getCurrentPendingTrade() |
GameScreen |
getGameScreen() |
static GameEngine |
getInstance() |
int |
getPhase() |
Player[] |
getPlayers() |
Tile[] |
getTiles() |
int |
getWinner() |
boolean |
isCurrentlyAiPlayer() |
Market |
market()
Returns all of the data pertaining to the game's market, which is declared and managed by the engine
|
void |
miniGame() |
void |
nextPhase()
Advances the game's progress upon call
Acts as a state machine of sorts, moving the game from one phase to another depending on what phase it is
currently at when this method if called.
|
private void |
nextPlayer()
Sets the current player to be that which isn't active whenever this is called
Updates the in-game interface to reflect the statistics and the identity of the player now controlling it
|
void |
pauseGame()
Pauses the game and opens the pause-menu (which is just a sub-stage in the GameScreen class)
Specifically pauses the game's timer and marks the engine's internal play-state to [State.PAUSE]
|
int |
phase()
Return's the game's phase as a number between (or possibly one of) 1 and 6
|
Player[] |
players()
Returns all of the data pertaining to the array of players managed by the game's engine
Unless the game's architecture changes radically, this should only ever return two Player objects
|
private void |
produceResource() |
void |
resumeGame()
Resumes the game and re-opens the primary in-game inteface
Specifically increments the in-game timer by 1 second, restarts it and marks the engine's internal play-state
to [State.PAUSE]
Note that the timer is incremented by 1 second to circumvent a bug that causes it to lose 1 second whenever
it's restarted
|
Tile |
selectedTile()
Returns the data pertaining to the last Tile that was selected by a player
|
private void |
selectRandomEvent() |
void |
selectTile(Tile tile) |
void |
setPlayers(Player[] players) |
GameEngine.State |
state()
Return's the game's current play-state, which can either be [State.RUN] or [State.PAUSE]
This is not to be confused with the game-state (which is directly linked to the renderer)
|
void |
testTrade() |
Tile[] |
tiles()
Collectively returns every Tile managed by the engine in array
|
GameTimer |
timer()
Returns the GameTimer declared and managed by the engine
|
void |
updateCurrentPlayer(Player currentPlayer)
Updates the data pertaining to the game's current player
This is used by the Market class to process item transactions
|
void |
upgradeRoboticon(int resource)
Function for upgrading a particular level of the roboticon stored on the last tile to have been selected
|
private static GameEngine _instance
private com.badlogic.gdx.Game game
public Chancellor chancellorGame
private GameScreen gameScreen
public static Player[] players
public int currentPlayerID
private int phase
private GameTimer timer
private Drawer drawer
public Market market
private Tile[] tiles
private Tile selectedTile
private GameEngine.State state
private int roboticonIDCounter
private com.badlogic.gdx.utils.Array<Trade> trades
private java.util.ArrayList<RandomEvent> randomEvents
public GameEngine(com.badlogic.gdx.Game game, GameScreen gameScreen)
game
- Variable storing the game's stategameScreen
- The object encoding the in-game interface which is to be controlled by this enginepublic static GameEngine getInstance()
public Tile[] getTiles()
public void selectTile(Tile tile)
public void nextPhase()
public void checkEventDurations()
public boolean eventCurrentlyHappening(java.lang.Integer eventValue)
private void chancellor()
private void selectRandomEvent()
private void produceResource()
private void nextPlayer()
public void pauseGame()
public void resumeGame()
public void claimTile()
public void deployRoboticon()
public GameEngine.State state()
public int phase()
public Player[] players()
public Player currentPlayer()
public int currentPlayerID()
public GameTimer timer()
public Tile[] tiles()
public Tile selectedTile()
public Market market()
private boolean checkGameEnd()
public void updateCurrentPlayer(Player currentPlayer)
currentPlayer
- The new Player object to represent the active player withpublic void upgradeRoboticon(int resource)
resource
- The type of resource which the roboticon will gather more of {0: ore | 1: energy | 2: food}public int getPhase()
public int getWinner()
public boolean isCurrentlyAiPlayer()
public void addTrade(Trade trade)
public Trade getCurrentPendingTrade()
public void testTrade()
public void closeTrade()
public void miniGame()
public GameScreen getGameScreen()
public Player[] getPlayers()
public void setPlayers(Player[] players)
public void backToGame()