Tanks Multiplayer  1.4
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
GameManager

Manages game workflow and provides high-level access to networked logic during a game. It manages functions such as team fill, scores and ending a game, but also video ad results. More...

Inheritance diagram for GameManager:

Public Member Functions

override void OnStartServer ()
 Server only: initialize SyncList length with team size once. Also verifies the team fill for each team in case of host migration. More...
 
override void OnStartClient ()
 On establishing a successful connection to the master and initializing client variables, update the game UI, i.e. team fill and scores, by looping over the received SyncLists. More...
 
int GetTeamFill ()
 Returns the next team index a player should be assigned to. More...
 
Vector3 GetSpawnPosition (int teamIndex)
 Returns a random spawn position within the team's spawn area. More...
 
void AddScore (ScoreType scoreType, int teamIndex)
 Adds points to the target team depending on matching game mode and score type. This allows us for granting different amount of points on different score actions. More...
 
int AddBufferedCollectible (NetworkInstanceId id, Vector3 position, NetworkInstanceId tarId)
 Add Collectible to the networked buffered list for tracking it on all clients. This method actually checks whether the Collectible is existent already and then modifies that entry, before adding it. The object ID has to be assigned in all cases, but the other parameters depend on the state. More...
 
void OnCollectibleStateChanged (SyncListStruct< CollectibleState >.Operation op, int index)
 Method called by the SyncList operation over the Network when its content changes. This is an implementation for changes to the buffered Collectibles, updating their position and assignment. Parameters: type of operation, index of Collectible which received updates. More...
 
bool IsGameOver ()
 Returns whether a team reached the maximum game score. More...
 
void DisplayDeath (bool skipAd=false)
 Only for this player: sets the death text stating the killer on death. If Unity Ads is enabled, tries to show an ad during the respawn delay. By using the 'skipAd' parameter is it possible to force skipping ads. More...
 
void DisplayGameOver (int teamIndex)
 Only for this player: sets game over text stating the winning team. Disables player movement so no updates are sent through the network. More...
 

Static Public Member Functions

static GameManager GetInstance ()
 Returns a reference to this script instance. More...
 
static bool isMaster ()
 Global check whether this client is the match master or not. More...
 

Public Attributes

Player localPlayer
 The local player instance spawned for this client. More...
 
GameMode gameMode = GameMode.TDM
 Active game mode played in the current scene. More...
 
UIGame ui
 Reference to the UI script displaying game stats. More...
 
Team[] teams
 Definition of playing teams with additional properties. More...
 
SyncListInt size = new SyncListInt()
 Networked list storing team fill for each team. E.g. if size[0] = 2, there are two players in team 0. More...
 
SyncListInt score = new SyncListInt()
 Networked list storing team scores for each team. E.g. if score[0] = 2, team 0 scored 2 points. More...
 
SyncListCollectible collects = new SyncListCollectible()
 Networked list storing Collectible pickups/drops. Each entry is of type CollectibleState. More...
 
int maxScore = 30
 The maximum amount of kills to reach before ending the game. More...
 
int respawnTime = 5
 The delay in seconds before respawning a player after it got killed. More...
 
bool friendlyFire = false
 Enable or disable friendly fire. This is verified in the Bullet script on collision. More...
 

Detailed Description

Manages game workflow and provides high-level access to networked logic during a game. It manages functions such as team fill, scores and ending a game, but also video ad results.

Member Function Documentation

int AddBufferedCollectible ( NetworkInstanceId  id,
Vector3  position,
NetworkInstanceId  tarId 
)

Add Collectible to the networked buffered list for tracking it on all clients. This method actually checks whether the Collectible is existent already and then modifies that entry, before adding it. The object ID has to be assigned in all cases, but the other parameters depend on the state.

void AddScore ( ScoreType  scoreType,
int  teamIndex 
)

Adds points to the target team depending on matching game mode and score type. This allows us for granting different amount of points on different score actions.

void DisplayDeath ( bool  skipAd = false)

Only for this player: sets the death text stating the killer on death. If Unity Ads is enabled, tries to show an ad during the respawn delay. By using the 'skipAd' parameter is it possible to force skipping ads.

void DisplayGameOver ( int  teamIndex)

Only for this player: sets game over text stating the winning team. Disables player movement so no updates are sent through the network.

static GameManager GetInstance ( )
static

Returns a reference to this script instance.

Vector3 GetSpawnPosition ( int  teamIndex)

Returns a random spawn position within the team's spawn area.

int GetTeamFill ( )

Returns the next team index a player should be assigned to.

bool IsGameOver ( )

Returns whether a team reached the maximum game score.

static bool isMaster ( )
static

Global check whether this client is the match master or not.

void OnCollectibleStateChanged ( SyncListStruct< CollectibleState >.Operation  op,
int  index 
)

Method called by the SyncList operation over the Network when its content changes. This is an implementation for changes to the buffered Collectibles, updating their position and assignment. Parameters: type of operation, index of Collectible which received updates.

override void OnStartClient ( )

On establishing a successful connection to the master and initializing client variables, update the game UI, i.e. team fill and scores, by looping over the received SyncLists.

override void OnStartServer ( )

Server only: initialize SyncList length with team size once. Also verifies the team fill for each team in case of host migration.

Member Data Documentation

Networked list storing Collectible pickups/drops. Each entry is of type CollectibleState.

bool friendlyFire = false

Enable or disable friendly fire. This is verified in the Bullet script on collision.

GameMode gameMode = GameMode.TDM

Active game mode played in the current scene.

Player localPlayer

The local player instance spawned for this client.

int maxScore = 30

The maximum amount of kills to reach before ending the game.

int respawnTime = 5

The delay in seconds before respawning a player after it got killed.

SyncListInt score = new SyncListInt()

Networked list storing team scores for each team. E.g. if score[0] = 2, team 0 scored 2 points.

SyncListInt size = new SyncListInt()

Networked list storing team fill for each team. E.g. if size[0] = 2, there are two players in team 0.

Team [] teams

Definition of playing teams with additional properties.

UIGame ui

Reference to the UI script displaying game stats.


The documentation for this class was generated from the following file: