gameinstancemanager - TogetherGames/Public-Unity-CSharp GitHub Wiki
together.GameInstanceManager
The GameInstanceManager is used for fetching and finding matches that exist for the current game.
List<GameInstance> GameInstances
Stores all the GameInstances contained in the Manager.
Adds a GameInstance to the manager internally without persistence.
Note
This method is deprecated
Returns void
GameInstanceManager.Add( gameInstance )
GameInstance gameInstance
Instance of a GameInstance to add internally
--------------------------------------------------------------------------------Finds the GameInstance with the specified GameInstanceID if it exists, otherwise returns null
Returns GameInstance
GameInstanceManager.FindByGameInstanceID( gameInstanceID )
long gameInstanceID
The ID of the GameInstance to find
--------------------------------------------------------------------------------Gets the number of GameInstances currently managed internally.
Returns int
GameInstanceManager.GetCount( )
Gets the GameInstance at the specified index if it exists, otherwise return null.
Returns GameInstance
GameInstanceManager.Get( index )
int index
The index of the GameInstance to find
--------------------------------------------------------------------------------Returns the index of the specified GameInstance if it exists, otherwise returns -1.
Returns int
GameInstanceManager.IndexOf( gameInstance )
GameInstance gameInstance
Instance of the GameInstance to find the index of
--------------------------------------------------------------------------------Returns the index of the GameInstance with the specified GameInstanceID if it exists, otherwise returns -1
Returns int
GameInstanceManager.IndexOfByGameInstanceID( gameInstanceID )
long gameInstanceID
The ID of the GameInstance to find the index of
--------------------------------------------------------------------------------Removes a GameInstance from the internally managed list. This does not delete the GameInstance from the Game persistently.
Note
This method is deprecated
Returns void
GameInstanceManager.Remove( index )
int index
The index of the GameInstance to be removed internally
--------------------------------------------------------------------------------Post processes the GameInstanceUser's usernames. If a GameInstanceUser's User is registered, its Name member will be assigned the name from their social network account. Otherwise, the Name member will be set to the User's Username.
Returns void
GameInstanceManager.PostProcessUsernames( )
Creates a new GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager.Create( gameInstanceType, gameInstanceSubType, roomID, maxUsers, passTurn, gameInstanceProperties, gameInstanceUserProperties, callbackFunc )
string gameInstanceType
The type of GameInstance to create. Potentially, a Game could have several types of GameInstance types within it. Type is limited to 16 characters.
[string](#) gameInstanceSubTypeThe subtype of the GameInstance that will be created. Potentially, a Game could have several sub types within it. SubType is limited to 16 characters.
[long](#) roomIDThe ID of the room the rematch GameInstance is created in. Pass 0 to bypass room creation.
[int](#) maxUsersThe max number of users the GameInstance supports. Pass in 2 for a two player game.
[bool](#) passTurnA boolean indicating whether the turn should be passed immediately onto the next User. When true, the TurnUserID will actually be set to null. When the next User joins the GameInstance, the TurnUserID will be set to them.
[PropertyCollection](./propertycollection) gameInstancePropertiesThe properties to assign to the GameInstance. Pass null to assign no properties to the GameInstance.
[PropertyCollection](./propertycollection) gameInstanceUserPropertiesThe properties to assign to your GameInstanceUser. Pass null to assign no properties to the GameInstanceUser.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Creates a rematch of a GameInstance. Upon success, this will automatically update the internal list. If the GameInstance is not already finished, it will be finished and a leaderboard will be generated.
Returns void
GameInstanceManager.CreateRematch( originalGameInstanceID, gameInstanceType, gameInstanceSubType, roomID, maxUsers, winningUserID, turnUserID, includeLeftGameUsers, rematchMessage, originalGameProps, origianlGameWinningUserProps, rematchGameProps, callbackFunc )
long originalGameInstanceID
The ID of the original GameInstance we're creating a rematch from.
[string](#) gameInstanceTypeThe type of GameInstance to create. Potentially, a Game could have several types of GameInstance types within it. Type is limited to 16 characters.
[string](#) gameInstanceSubTypeThe subtype of the GameInstance that will be created. Potentially, a Game could have several subtypes within it. SubType is limited to 16 characters.
[long](#) roomIDThe ID of the room the rematch GameInstance is created in. Pass in 0 for no room.
[int](#) maxUsersThe max number of users the GameInstance supports. Pass in 2 for a two player game.
[long](#) winningUserIDThe ID of the User that has won the GameInstance.
[long](#) turnUserIDThe ID of the User whose initial turn it is.
[bool](#) includeLeftGameUsersA boolean dictating whether users that have left the original game should be included in the rematched GameInstance.
[string](#) rematchMessageThe notification message to send to all other users that are a member of the rematched GameInstance. Pass "" to have no notification message sent.
[PropertyCollection](./propertycollection) originalGamePropsThe final properties of the original GameInstance.
[PropertyCollection](./propertycollection) origianlGameWinningUserPropsThe properties of the winning User of the original GameInstance.
[PropertyCollection](./propertycollection) rematchGamePropsThe properties of the rematch GameInstance. Pass in null to assign no properties to the rematched GameInstance.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Deletes a GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager.Delete( gameInstanceID, callbackFunc )
long gameInstanceID
The ID of the GameInstance to delete.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Gets all GameInstances. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager.GetAll( userID, stateMask, maxCount, getGameInstanceProperties, friendsOnly, gameInstanceType, gameInstanceSubtype, callbackFunc )
long userID
The ID of the User who must be a member of a GameInstance retrieved. Pass 0 to fetch all games regardless of membership within them.
[int](#) stateMaskA table containing the GameInstance States to retrieve. The following stateMask table members are examined:
waitingForPlayers | Waiting for players to join the game. |
inProgress | Players are currently playing the game. |
finished | Game has been finished and a leaderboard was generated. |
possibleRematch | A rematched Game waiting for enough players to join. |
forfeit | Game was forfeited by a User. |
// To get all GameInstances that are playable. local stateMasks = { waitingForPlayers=true, inProgress=true }; // To get all GameInstances regardless of State. local stateMasks = { waitingForPlayers=true, inProgress=true, finished=true, possibleRematch=true, forfeit=true };[int](#) maxCount
The maximum number of GameInstance to retrieve.
[bool](#) getGameInstancePropertiesSet TRUE to retrieve the property collections of each game instance, FALSE to retrieve the instances without properties.
[bool](#) friendsOnlySet TRUE to retrieve only gamesin which you and your friends are joined in
[string](#) gameInstanceTypeSet to retrieve only games with this type, pass null to ignore.
[string](#) gameInstanceSubtypeSet to retrieve only games with this subtype, pass null to ignore.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Gets all the GameInstances in a duel. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager.GetAllInDuel( gameInstanceDuelID, callbackFunc )
long gameInstanceDuelID
The ID of the duel to retrieve all GameInstances for.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Joins an existing GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager.Join( gameInstanceID, gameInstanceUserProperties, callbackFunc )
long gameInstanceID
The ID of the specific GameInstance to join.
[PropertyCollection](./propertycollection) gameInstanceUserPropertiesThe properties to assign the User joining the GameInstance.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Joins a random existing GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager.JoinRandom( gameInstanceType, gameInstanceUserProperties, callbackFunc )
string gameInstanceType
The type of GameInstance to join.
[PropertyCollection](./propertycollection) gameInstanceUserPropertiesThe properties to assign the User joining the GameInstance.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------