BomberUnits
...a Unity learning project
Player Class Referenceabstract

A Player is one participant in a game. More...

+ Inheritance diagram for Player:
+ Collaboration diagram for Player:

Classes

class  UnityStringIntEvent
 

Public Types

enum  State : short { notPlaying = 0, playing = 1, ready = 2 }
 Holds current state of this player here, so it is not bound to any specific go (player figure).
 

Public Member Functions

abstract bool IsLocal ()
 Helper to make the many queries for a player being local more readable.
 
virtual void FreeResourcesAndRemove ()
 Removes this instance from the tracking list. More...
 
abstract NetData GetNetData ()
 Returns a copy(!) of the currently held NetData of this Player. More...
 
bool HasFigure ()
 
PlayerController GetCtrl ()
 This getter shortens the access to a player's controller and thus player figure status.
 
string GetClientId ()
 
string GetName ()
 
ColorScheme GetColor ()
 
PlayerFigurePrefab GetPrefab ()
 
State GetState ()
 
void UpdateMultiple (NetData newNetData)
 Interface to update multiple net dat content at once. More...
 
void OnNetDataChange (NetData newNetData)
 This ensures actions on changing networked data are taken, such as player resource usage.
 
override string ToString ()
 

Static Public Member Functions

static void Awake ()
 Player is no MonoBehaviour, so this has to be called from playerManager during startup.
 
static bool Contains (string clientId, int uid)
 
static Player Get (string clientId, int uid)
 
static Dictionary< int, PlayerGetAll ()
 
static int Count ()
 

Public Attributes

readonly int uid
 
GameObject playerFigure
 
Vector3 spawnLoc
 

Protected Member Functions

 Player (string clientId, int uid, NetData netData)
 Constructor is only called from concrete subclasses. More...
 

Protected Attributes

string clientId
 

Private Attributes

int colorDictKeyBackup
 Copy to be able to compare incoming changes.
 

Static Private Attributes

static Dictionary< int, Playerplayers
 

Detailed Description

A Player is one participant in a game.

There may be multiple players playing from one client. This wraps all player information needed for the Lobby and in-game. It does not currently contain match information! This is tracked by the figure controller.

Definition at line 15 of file Player.cs.

Constructor & Destructor Documentation

◆ Player()

Player ( string  clientId,
int  uid,
NetData  netData 
)
inlineprotected

Constructor is only called from concrete subclasses.

Adds standard values for new Player objects. Also tracks all Players in a Dictionary.

Todo:
: Does this work? How about the same color joining? Check beforehand?

Definition at line 192 of file Player.cs.

Member Function Documentation

◆ FreeResourcesAndRemove()

virtual void FreeResourcesAndRemove ( )
inlinevirtual

Removes this instance from the tracking list.

This is extended with additional steps in the Player subclasses, to be called by instances. At this point, the player's net data is most likely not available -> use backups for the resources.

Reimplemented in RemotePlayer, and LocalPlayer.

Definition at line 99 of file Player.cs.

◆ GetNetData()

abstract NetData GetNetData ( )
pure virtual

Returns a copy(!) of the currently held NetData of this Player.

Whether a server request or local shortcut can be used is implemented by the concrete classes.

Implemented in RemotePlayer, and LocalPlayer.

◆ UpdateMultiple()

void UpdateMultiple ( NetData  newNetData)
inline

Interface to update multiple net dat content at once.

Will not send an update if the content has not changed or is null.

Definition at line 154 of file Player.cs.


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