I have a very preliminar support of leaderboards in one of my games.
You first have to query the leaderboard. In example:
StatisticManager statsManager;
var query=new LeaderboardQuery();
query.MaxItems=numScores;
statsManager.GetLeaderboard (user,leaderboardId,query);
afterwards you have to manually query statsManager with DoWork (in example, in every Update cycle, or through a Thread) which returns you different events.
Try/catch it, as DoWork can throw exceptions.
var eventList=live.statsManager.DoWork();
foreach (var ev in eventList)
{
if (ev.EventType==StatisticEventType.GetLeaderboardComplete)
{
var args=ev.EventArgs as LeaderboardResultEventArgs;
if (args!=null && args.Result!=null)
{
processLeaderboardResults (args.Result);
leaderboardAltered=true;
}
}
}
Inside processLeaderboardResults, you do a
foreach (var row in result.Rows)
and you have each leaderboard entry in those rows. row.GamerTag, row.Rank , âŚ
What you do with those (i.e. put them in a list to display them ) itâs all up to you.
DoWork() can throw exceptions too!? Dang, everything needs try/catch.
Also @KakCAT , I believe games can be set up in âmulti-user modeâ but Iâve never messed with it myself. Essentially your game needs to be structured that way from the start as it will affect how you handle Xbox Live (to my understanding).
It is indeed complicating a lot the sign in process and specially the savegames, I have to think wether using or not. After all, you can also control several gamepads without loging in.
Yeah, my game has a local coop mode but I just stick with the single user mode. The second player is essentially just playing as a guest on the main playerâs account and any achievements they unlock together are just unlocked for the primary player.
First of thank you everyone for your posts. I have had a nightmare of a time trying to find any decent documentation on how to integrate the Xbox Live SDK into an existing project (The old XNA framework was a million times better and had proper documentation) and these posts have helped me get closer to the solution. One edit thatâs needed (probably because MS changed it and didnât bother to make it backwards compatible) is that the xboxservices.config needs the following format