BomberUnits
...a Unity learning project
LocalPlayer Class Reference
+ Inheritance diagram for LocalPlayer:
+ Collaboration diagram for LocalPlayer:

Public Member Functions

override bool IsLocal ()
 Helper to make the many queries for a player being local more readable.
 
override void FreeResourcesAndRemove ()
 references to this any more.
 
void Update (int inputDictKey, NetData newNetData)
 Used to update properties of players, here with more parameters for local player properties. More...
 
void UpdateClientId (string clientId)
 
void UpdateState (State newState)
 Setter for the state member, causing a netData update if there was a change. More...
 
override NetData GetNetData ()
 A local player can access its netdata even when disconnected via a shortcut to the local version.
 
override string ToString ()
 
- Public Member Functions inherited from Player
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 new void Awake ()
 
static bool Contains (int uid)
 
static LocalPlayer Get (int uid)
 
static new Dictionary< int, LocalPlayerGetAll ()
 This method hides the GetAll method of Player.
 
static LocalPlayer GetMain ()
 
static new int Count ()
 
static LocalPlayer CreateNew ()
 Creates a new local player and publishes its networked data. More...
 
static LocalPlayer CreateMainFromSave ()
 Load the main player as was saved to player prefs. More...
 
static void SaveMain ()
 Saves the main player's settings to the PlayerPrefs. More...
 
- Static Public Member Functions inherited from Player
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

InputScheme input
 Player resource shared between local players only.
 
bool isNew
 Flag to indicate a player addition when the NetData event arrives for this.
 
- Public Attributes inherited from Player
readonly int uid
 
GameObject playerFigure
 
Vector3 spawnLoc
 

Private Member Functions

 LocalPlayer (string clientId, int uid, InputScheme input, NetData netData)
 Inaccessible Constructor to be used by static Creator methods. More...
 

Static Private Attributes

static Dictionary< int, LocalPlayerlocalPlayers
 
static LocalPlayer main
 

Additional Inherited Members

- Public Types inherited from Player
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).
 
- Protected Member Functions inherited from Player
 Player (string clientId, int uid, NetData netData)
 Constructor is only called from concrete subclasses. More...
 
- Protected Attributes inherited from Player
string clientId
 

Detailed Description

Definition at line 11 of file LocalPlayer.cs.

Constructor & Destructor Documentation

◆ LocalPlayer()

LocalPlayer ( string  clientId,
int  uid,
InputScheme  input,
NetData  netData 
)
inlineprivate

Inaccessible Constructor to be used by static Creator methods.

It is responsible for tracking instances.

Definition at line 184 of file LocalPlayer.cs.

Member Function Documentation

◆ CreateMainFromSave()

static LocalPlayer CreateMainFromSave ( )
inlinestatic

Load the main player as was saved to player prefs.

Returns std values if no safe can be found. This is done during initialization, so we don't need to check for player limits. This could and should be moved to dedicated save game handling once necessary.

Definition at line 74 of file LocalPlayer.cs.

◆ CreateNew()

static LocalPlayer CreateNew ( )
inlinestatic

Creates a new local player and publishes its networked data.

Returns null if a new player cannot be created due to player limits.

Definition at line 58 of file LocalPlayer.cs.

◆ SaveMain()

static void SaveMain ( )
inlinestatic

Saves the main player's settings to the PlayerPrefs.

Called by PlayerManager upon Application Quit.

Definition at line 101 of file LocalPlayer.cs.

◆ Update()

void Update ( int  inputDictKey,
NetData  newNetData 
)
inline

Used to update properties of players, here with more parameters for local player properties.

Just add more local parameters if needed. Regarding the networked data, the request is forwarded to the Player class. No netData update is sent if the content has not changed or null was given.

Definition at line 141 of file LocalPlayer.cs.

◆ UpdateState()

void UpdateState ( State  newState)
inline

Setter for the state member, causing a netData update if there was a change.

Only local players are able to update their data for now.

Definition at line 160 of file LocalPlayer.cs.


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