gameinstance - TogetherGames/Public-Unity-CSharp GitHub Wiki
Together::GameInstance
The GameInstance class represents a Together GameInstance or individual match.
long GameInstanceID
The ID of the GameInstance.
string GameInstanceType
The type of GameInstance. ie (Board 3x3, Board 6x6, Board 9x9)
long GameInstanceDuelID
The ID of the duel the GameInstance belongs to. This is the ID of the first GameInstance in a line of rematches.
long CreatorUserID
The ID of the User that created the GameInstance.
long RoomID
The ID of the Room the GameInstance was created. If equal to 0, then the GameInstance wasn't created in a room.
long ChatRoomID
The ID of the ChatRoom associated with the GameInstance.
int SecondsSinceGameStarted
The number of seconds since the GameInstance was started.
int SecondsSinceLastModified
The number of seconds since the GameInstance was last modified.
int LastModifyTimestamp
A timestamp for when the GameInstance was last modified.
int RoundCount
The number of rounds the GameInstance has progressed through.
int TotalTurnCount
The total number of moves made.
bool Active
A boolean indicating whether the GameInstance is active.
int State
The State of the GameInstance.
int UserCount
The number of users in the GameInstance.
int MaxUsers
The max number of users in the GameInstance.
long TurnUserID
The ID of the User whose turn it is. When 0, it is no User's turn. This will occur if first User makes their initial move and another possible User hasn't joined the GameInstance yet.
int TurnIndex
The index of whose turn it is.
int PlayCount
The number of times a GameInstance has been played in the duel. This value will be 1 for the initial GameInstance. 2 for the second GameInstance in the duel. 3 for the third GameInstance in the duel.
long WinningUserID
The ID of the User that has won the GameInstance. When 0, there is no winner of the GameInstance.
bool IsUserMemberOf
A boolean indicating whether the logged in User is a member of the GameInstance.
long LeaderboardID
The ID of the Leaderboard associated with the GameInstance.
PropertyCollection Properties
A property collection containing all custom properties for the GameInstance.
List<GameInstanceUser> GameInstanceUsers
Contains all the GameInstanceUsers that are playing the GameInstance.
Adds a GameInstanceUser to the manager internally without persistence.
Note
This method is deprecated
Returns void
GameInstance.AddGameInstanceUser( gameInstanceUser )
GameInstanceUser gameInstanceUser
Instance of the GameInstanceUser to add to the internal list
--------------------------------------------------------------------------------Finds the GameInstanceUser with the specified UserID if it exists, otherwise returns null.
Returns GameInstanceUser
GameInstance.FindGameInstanceUserByUserID( userID )
long userID
The ID of the User to find
--------------------------------------------------------------------------------Finds the GameInstanceUser with the specified GameInstanceUserID if it exists, otherwise returns null.
Returns GameInstanceUser
GameInstance.FindGameInstanceUserByGameInstanceUserID( gameInstanceUserID )
long gameInstanceUserID
The ID of the GameInstanceUser to find
--------------------------------------------------------------------------------Gets the number of GameInstanceUsers currently managed internally.
Returns int
GameInstance.GetGameInstanceUserCount( )
Gets the GameInstanceUser at the specified index if it exists, otherwise returns null.
Returns GameInstanceUser
GameInstance.GetGameInstanceUser( index )
int index
The index of the GameInstanceUser to find
--------------------------------------------------------------------------------Gets the TurnIndex for a particular User. Turn indexes are base 0. Returns -1 if the user is not found.
Returns int
GameInstance.GetTurnIndexForUser( userID )
long userID
The ID of the User we're interested in getting the TurnIndex for.
--------------------------------------------------------------------------------Returns the index of the specified GameInstanceUser if it exists, otherwise returns -1.
Returns int
GameInstance.IndexOfGameInstanceUser( gameInstanceUser )
GameInstanceUser gameInstanceUser
Instance of the GameInstanceUser to find the index of
--------------------------------------------------------------------------------Returns the index of the GameInstanceUser with the specified UserID if it exists, otherwise returns -1.
Returns int
GameInstance.IndexOfGameInstanceUserByUserID( userID )
long userID
The ID of the User to find the index of
--------------------------------------------------------------------------------Returns the index of the GameInstanceUser with the specified GameInstanceUserID if it exists, otherwise returns -1.
Returns int
GameInstance.IndexOfGameInstanceUserByGameInstanceUserID( gameInstanceUserID )
long gameInstanceUserID
The ID of the GameInstanceUser to find the index of
--------------------------------------------------------------------------------Removes a GameInstanceUser from the internally managed list. This does not delete the user from the instance persistently.
Note
This method is deprecated
Returns void
GameInstance.RemoveGameInstanceUser( index )
int index
The index of the GameInstanceUser 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
GameInstance.PostProcessUsernames( )
Gets the GameInstance's details. This message should be called whenever it is necessary to get the latest state of a GameInstance. Internally, this method passes the GameInstance's LastModifyTimestamp to the server. If the LastModifyTimestamp is the same value on the server, a "No Change" error will be returned. If you do not wish this behavior, set LastModifyTimestamp on the GameInstance object to 0 before calling this method and full details will always be returned. Upon success, this will automatically update the internal data.
Returns void
GameInstance.GetDetails( gameInstanceID, callbackFunc )
long gameInstanceID
The ID of the GameInstance to retrieve details for
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Finishes a GameInstance. This message should be called whenever a GameInstance is finished. The State of the GameInstance will change to (4 = GAME_STATE_FINISHED). A Leaderboard will be generated for the GameInstance. Upon success this will automatically update the internal data.
Returns void
GameInstance.Finish( winningUserID, callbackFunc )
long winningUserID
The ID of the User that has won the GameInstance. Pass 0 if there was no specific winner.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Forfeits a GameInstance. This message should be called whenever a GameInstance is forfeited by a User. The State of the GameInstance will change to (16 = GAME_STATE_FORFEIT). Upon success, this will automatically update the internal data.
Returns void
GameInstance.Forfeit( callbackFunc )
OnCompleteHandler callbackFunc
The function to call upon completion.
--------------------------------------------------------------------------------Invites a User to a GameInstance. Upon success, this will automatically update the internal data.
Returns void
GameInstance.InviteUser( inviteeUserID, inviteeSocialType, inviteeSocialID, gameUserProperties, notificationMessage, callbackFunc )
long inviteeUserID
The ID of the Together User to invite to the GameInstance. Pass in 0 when inviting an external (Facebook) friend.
[string](#) inviteeSocialTypeThe type of social network we're inviting a friend from. Pass "FB" for Facebook. Pass "" when passing a valid Together User.
[string](#) inviteeSocialIDThe ID of the external (Facebook) friend we're inviting. For a Facebook friend, pass the friend's FacebookID. Pass "" when passing a valid Together User.
[PropertyCollection](./propertycollection) gameUserPropertiesA PropertyCollection to associate with the GameInstanceUser that gets created, or null to attach no properties.
[string](#) notificationMessageThe notification message to send to the Together User. Pass "" to prevent sending a notification.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Leaves this GameInstance. Upon success, this will automatically update the internal data.
Returns void
GameInstance.Leave( callbackFunc )
OnCompleteHandler callbackFunc
The function to call upon completion.
--------------------------------------------------------------------------------Makes a move in the GameInstance with optional turn index updates. Turn indexes are base 0. Upon success, this will
automatically update the internal data.
The following GameInstance members are sent to the server when this method is called.
-
GameInstanceID: The ID of the GameInstance we're making a move in.
-
TurnIndex: The current Index of which User whose turn it is.
-
NewTurnUserID: The UserID of the User whose turn it should be. Pass in 0 to
assign the next turn to no one. The only time 0 should be passed
is if another User can join the game and the game is waiting. This
is because whenever a User joins a game and the current TurnUserID is
unassigned, turn is immediately assigned to the new user.
-
NewTurnIndex: The index of the next User to assign the turn to. For a two player
GameInstance, the TurnIndex should either be 0 or 1.
-
GameInstanceUserID: The current GameInstanceUserID whose turn it is.
-
GameProps: The GameInstance.Properties member representing the properties for the GameInstance.
- GameUserProps: The Properties of the GameInstanceUser that is making the move.
Returns void
GameInstance.MakeMove( callbackFunc )
OnCompleteHandler callbackFunc
The function to call upon completion.
--------------------------------------------------------------------------------Modifies the GameInstance. Upon success, this will automatically update the internal data.
The following GameInstance members are sent to the server when this method is called:
-
GameInstanceID: The ID of the GameInstance we're making a move in.
-
Active: The active boolean on the GameInstance.
-
TurnUserID: The UserID of the User whose turn it should be. Pass in 0 to assign the next turn to no one.
-
TurnIndex: The Index of the User whose turn it is.
-
GameProps: The GameInstance.Properties member representing the properties for the GameInstance.
-
State: The State of the GameInstance.
GAME_STATE_WAITING_FOR_PLAYERS | =1 | Waiting for players to join the game. |
GAME_STATE_IN_PROGRESS | =2 | Players are currently playing the game. |
GAME_STATE_FINISHED | =4 | Game has been finished and a leaderboard was generated. |
GAME_STATE_POSSIBLE_REMATCH | =8 | A rematched Game waiting for enough players to join. |
GAME_STATE_FORFEIT | =16 | Game was forfeited by a User. |
Returns void
GameInstance.Modify( indexOfUserToModify, callbackFunc )
int indexOfUserToModify
The index of the GameInstanceUser to modify as well. Pass -1 to modify no GameInstanceUser.
[OnCompleteHandler](./oncompletehandler) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------