Photon .NET Client API
Public Member Functions | Public Attributes | Properties | List of all members
ExitGames.Client.Photon.LoadBalancing.Player Class Reference

Summarizes a "player" within a room, identified (in that room) by ID (or "actorID"). More...

Public Member Functions

Player Get (int id)
 
Player GetNext ()
 
Player GetNextFor (Player currentPlayer)
 
Player GetNextFor (int currentPlayerId)
 
virtual void CacheProperties (Hashtable properties)
 Caches properties for new Players or when updates of remote players are received. Use SetCustomProperties() for a synced update. More...
 
override string ToString ()
 This Player's NickName and custom properties as string. More...
 
override bool Equals (object p)
 If players are equal (by GetHasCode, which returns this.ID). More...
 
override int GetHashCode ()
 Accompanies Equals, using the ID (actorNumber) as HashCode to return. More...
 
void SetCustomProperties (Hashtable propertiesToSet, Hashtable expectedProperties=null)
 Updates and synchronizes this Player's Custom Properties. Optionally, expectedProperties can be provided as condition. More...
 

Public Attributes

readonly bool IsLocal
 Only one player is controlled by each client. Others are not local. More...
 
object Tag
 Custom object associated with this Player. Not synchronized! More...
 

Properties

int ID [get]
 Identifier of this player in current room. Also known as: actorNumber or actorID. It's -1 outside of rooms. More...
 
string NickName [get, set]
 Non-unique nickname of this player. Synced automatically in a room and used as fallback-UserId, if that wasn't set. More...
 
string Name [get, set]
 
bool IsMasterClient [get]
 The player with the lowest actorID is the master and could be used for special tasks. The LoadBalancingClient.LocalPlayer is not master unless in a room (this is the only player which exists outside of rooms, to store a nickname). More...
 
Hashtable CustomProperties [get, set]
 Read-only cache for custom properties of player. Set via Player.SetCustomProperties. More...
 
Hashtable AllProperties [get]
 Creates a Hashtable with all properties (custom and "well known" ones). More...
 
bool IsInactive [get, set]
 In turnbased games, other players might be inactive in a room. True when another player is not in the current room. More...
 

Detailed Description

Summarizes a "player" within a room, identified (in that room) by ID (or "actorID").

Each player has a actorID, valid for that room. It's -1 until assigned by server (and client logic).

Member Function Documentation

virtual void ExitGames.Client.Photon.LoadBalancing.Player.CacheProperties ( Hashtable  properties)
inlinevirtual

Caches properties for new Players or when updates of remote players are received. Use SetCustomProperties() for a synced update.

This only updates the CustomProperties and doesn't send them to the server. Mostly used when creating new remote players, where the server sends their properties.

override bool ExitGames.Client.Photon.LoadBalancing.Player.Equals ( object  p)
inline

If players are equal (by GetHasCode, which returns this.ID).

Player ExitGames.Client.Photon.LoadBalancing.Player.Get ( int  id)
inline
override int ExitGames.Client.Photon.LoadBalancing.Player.GetHashCode ( )
inline

Accompanies Equals, using the ID (actorNumber) as HashCode to return.

Player ExitGames.Client.Photon.LoadBalancing.Player.GetNext ( )
inline
Player ExitGames.Client.Photon.LoadBalancing.Player.GetNextFor ( Player  currentPlayer)
inline
Player ExitGames.Client.Photon.LoadBalancing.Player.GetNextFor ( int  currentPlayerId)
inline
void ExitGames.Client.Photon.LoadBalancing.Player.SetCustomProperties ( Hashtable  propertiesToSet,
Hashtable  expectedProperties = null 
)
inline

Updates and synchronizes this Player's Custom Properties. Optionally, expectedProperties can be provided as condition.

Custom Properties are a set of string keys and arbitrary values which is synchronized for the players in a Room. They are available when the client enters the room, as they are in the response of OpJoin and OpCreate.

Custom Properties either relate to the (current) Room or a Player (in that Room).

Both classes locally cache the current key/values and make them available as property: CustomProperties. This is provided only to read them. You must use the method SetCustomProperties to set/modify them.

Any client can set any Custom Properties anytime. It's up to the game logic to organize how they are best used.

You should call SetCustomProperties only with key/values that are new or changed. This reduces traffic and performance.

Unless you define some expectedProperties, setting key/values is always permitted. In this case, the property-setting client will not receive the new values from the server but instead update its local cache in SetCustomProperties.

If you define expectedProperties, the server will skip updates if the server property-cache does not contain all expectedProperties with the same values. In this case, the property-setting client will get an update from the server and update it's cached key/values at about the same time as everyone else.

The benefit of using expectedProperties can be only one client successfully sets a key from one known value to another. As example: Store who owns an item in a Custom Property "ownedBy". It's 0 initally. When multiple players reach the item, they all attempt to change "ownedBy" from 0 to their actorNumber. If you use expectedProperties {"ownedBy", 0} as condition, the first player to take the item will have it (and the others fail to set the ownership).

Properties get saved with the game state for Turnbased games (which use IsPersistent = true).

Parameters
propertiesToSetHashtable of Custom Properties that changes.
expectedPropertiesProvide some keys/values to use as condition for setting the new values.
override string ExitGames.Client.Photon.LoadBalancing.Player.ToString ( )
inline

This Player's NickName and custom properties as string.

Member Data Documentation

readonly bool ExitGames.Client.Photon.LoadBalancing.Player.IsLocal

Only one player is controlled by each client. Others are not local.

object ExitGames.Client.Photon.LoadBalancing.Player.Tag

Custom object associated with this Player. Not synchronized!

Property Documentation

Hashtable ExitGames.Client.Photon.LoadBalancing.Player.AllProperties
get

Creates a Hashtable with all properties (custom and "well known" ones).

Creates new Hashtables each time used, so if used more often, cache this.

Hashtable ExitGames.Client.Photon.LoadBalancing.Player.CustomProperties
getset

Read-only cache for custom properties of player. Set via Player.SetCustomProperties.

Don't modify the content of this Hashtable. Use SetCustomProperties and the properties of this class to modify values. When you use those, the client will sync values with the server.

int ExitGames.Client.Photon.LoadBalancing.Player.ID
get

Identifier of this player in current room. Also known as: actorNumber or actorID. It's -1 outside of rooms.

The ID is assigned per room and only valid in that context. It will change even on leave and re-join. IDs are never re-used per room.

bool ExitGames.Client.Photon.LoadBalancing.Player.IsInactive
getset

In turnbased games, other players might be inactive in a room. True when another player is not in the current room.

bool ExitGames.Client.Photon.LoadBalancing.Player.IsMasterClient
get

The player with the lowest actorID is the master and could be used for special tasks. The LoadBalancingClient.LocalPlayer is not master unless in a room (this is the only player which exists outside of rooms, to store a nickname).

string ExitGames.Client.Photon.LoadBalancing.Player.Name
getset
string ExitGames.Client.Photon.LoadBalancing.Player.NickName
getset

Non-unique nickname of this player. Synced automatically in a room and used as fallback-UserId, if that wasn't set.

A player might change his own playername in a room (it's only a property). Setting this value updates the server and other players (using an operation).


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