🤼‍♀️Two Players

How two player matches work

Two player matches let you find opponents and sync data between the two devices. Once you create a match, each player can get and update the match's game state. This is serialized for you into a custom class. Prizes can be awarded automatically to winners (configure on your dashboard).

⬆️ Create a match

Create a match with a random opponent

GalaxyClientAPI.CreateMatch(new GalaxySDK.ClientModels.CreateMatchRequest{ }, result => {
    //use result.MatchId
}, error => { });

Create a match with a friend (see ViewOptions)

GalaxyClientAPI.Controller.OpenMatchmaker(Options: ViewOptions)

Subscribe to the delegate to be notified of new matches from the matchmaker UI

//Subscribe to the delegate
GalaxyClientAPI.Controller.didCreateMatch += OnMatchCreated

void OnMatchCreated(string MatchId){
    //Do something
}

⬇️ Get match list

Get this player's matches

GalaxyClientAPI.GetMatchList(new GalaxySDK.ClientModels.MatchListRequest { }, result => {
    //Use result.Matches array
    string firstMatchId = result.Matches[0].MatchId
}, error => { });
Match Objects

Response

public Match[] Matches;

Match reference

⬇️ Get a specific match

Get a match and deserialize the current state. CustomState can be any class

GalaxyClientAPI.Controller.GetMatch<CustomState>(MatchId, (MyGameState, Match) => {
    //MyGameState is an object of type CustomState
    //Match is the match object described above
}, error => { });

⬆️ Update a match

Update a match with MyNewGameState of type CustomState

GalaxyClientAPI.Controller.UpdateMatch<CustomState>(MatchId, MyNewGameState, 
(MyGameState, Match) => {
    //MyGameState is an object of type CustomState
    //Match is the match object described above
}, error => { });

⬆️ End a match

End the match with id MatchId. If you pass Score and LeaderboardId (optional), the score will be reported to the leaderboard and the winner of the match will be awarded a prize, if applicable.

GalaxyClientAPI.Controller.EndMatch(MatchId, Score?); //Score is optional

Last updated