Xbox Live C# API Leaderboard Example - xbox-live

I signed up for the Xbox Creators Program, and I'm trying to get a leaderboard. However I couldn't find any examples that use the C# API. This page shows how to do it in C++.
Here is my code. It won't build because it says XboxLiveContext doesn't have a LeaderboardService property. How do I create a leaderboardservice in C#?
XboxLiveUser user = new XboxLiveUser();
SignInResult x = await user.SignInAsync();
XboxLiveContext context = new XboxLiveContext(user);
LeaderboardResult result = await context.LeaderboardService.GetLeaderboardAsync("scores1", new LeaderboardQuery());

For C# Xbox Creators Program some of the APIs have been moved around. The Leaderboards APIs are now part of the StatsManager. You can use StatsManager.Singleton.GetLeaderboard(...) make a request to get a leaderboard.
That starts the request in the background, and when it's complete, an event will be returned by a call to StatsManager.Singleton.DoWork(). The DoWork method is intended to be called every frame (or whenever you want to be notified of events from StatsManager). Take a look at the Xbox Live Unity Plugin Leaderboards implementation for an example of how to do this.

Related

Get only 2 people to enable video call at a time using agora?

Is their anyway to have only have two people who can go on a video call at a time from a room on agora. For example their are 20 speakers, and only 2 people at a time can have their video on, and if one closes their video someone else can turn it on. Is their an API for this, or a method to do it?
The concept you are asking about is achievable using the Agora RTC and RTM SDKs. The Agora RTC (Voice/Video) SDK supports up to 17 active broadcasters/host (for 128 hosts see FAQ) but does not have any methods to limit the number below that. This is where Agora RTM can help, it is a signaling layer that enables client side devices to communicate with string and JSON msgs.
I would recommend you take a look at this guide on "Dynamic Channels". It explains how to use RTM to create a lobby where users can see existing channels and either join a channel or create a new one. With some slight modifications you could add limitations to the number of participants.
Specifically in this section, currently there is a check before joining the call, you can change the 4 to 2 it will say the channel is full and not allow others to join. The onTap should look like this:
onTap: () {
// limit channel to 2 people
if (_channelList.values.toList()[index] <= 2) {
joinCall(_channelList.keys.toList()[index], _channelList.values.toList()[index]);
} else {
print('Channel is full');
}
},

Actions SDK: Handling unsupported utterance whilst playing media

Question
Is it possible to resume the content of a media object once a user has tried to interact with a Google Home device during the playing of that media?
The problem
Say you have started playing an mp3 file using conv.ask. Your call to conv.ask will look something along the lines of this:
conv.ask(`<speak><audio src="${someUrl1}"><desc>${someDescription}</desc></audio></speak>`)
.add(new MediaObject({
url: someUrl2
}))
.add(new Suggestions(['suggestion1', 'suggestion2']));
This plays all fine and well. But then say a user says something along the lines of 'Ok Google, Gobbledygoop', you then might want to tell the user that their request was nonsensical, and then continue the playing of the media in the media object.
What I have tried already
app.fallback(): This does not seem compatible with the actions SDK. It does not seem possible under any circumstance to get the callback (the one provided to app.fallback) to be called.
Providing conv.ask with null/empty string responses: This was a desperate attempt to see what would happen if you provided nothing to conv.ask. There was a hope that it would see the empty response and just keep playing the media.
There is nothing that is part of Actions on Google itself that will do this for you.
The best you can probably do requires a lot of effort on your part:
You can include as part of the session state (or in a context) when you replied to the user with the Media result.
If you get another request before the Media Status event, you can determine the difference between the two, and this will roughly be how long the audio had been playing.
You can then return a URL for audio that includes starting at this point in the audio. However, the audio offset isn't something that the Assistant does, you'll have to support this on the server that contains the audio as well.
As for the two things you attempted - app.fallback() should have worked to handle any intent that you had set to go to your webhook that didn't have any other handler defined, but that still wouldn't just be able to "resume" the audio. conv.ask() requires you to ask something - null replies aren't allowed.
In this case, you at least want to tell the user that what they said made no sense... before resuming the audio.

How to abort room when there is no opponent player available in Google Play Games?

I am creating a Multiplayer Game in Unity.
To create a room, I am using:
PlayGamesPlatform.Instance.RealTime.CreateQuickGame(MinOpponents, MaxOpponents, GameVariant, listener);
To get progress of room creation, I am using:
public void OnRoomSetupProgress(float progress) {
}
The above function, however, is just called once at progress = 20 and then, never again if there are no other players available.
Since initially, I won't have a lot of players using this app, I want to wait for 10 seconds to connect to any other player and if there are no players, I want to start the game with built in AI. For this, I need to abort the current room setup progress in a clean way. I don't know how can I move further.
Please let me know if you know solution for this scenario.
With regards to Multiplayer Game in Unity, this GitHub post only discussed about leaving the room when the game finishes using PlayGamesPlatform.Instance.RealTime.LeaveRoom(); to trigger a call to your listener's OnLeftRoom.
You may want to try Adding Real-time Multiplayer Support to Your Android Game specifically Adding a waiting room UI which states that
If you use the waiting room UI, you do not need to implement additional logic to decide when the game should be started or canceled, as seen earlier in shouldStartGame() and shouldCancelGame(). When you obtain an Activity.RESULT_OK result, you can start right away since the required number of participants have been connected. Likewise, when you get an error result from the waiting room UI, you can simply leave the room.
To leave the room, call leave():
// leave room
Games.RealTimeMultiplayer.leave(mGoogleApiClient, null, mRoomId);
// remove the flag that keeps the screen on
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

Handling Invitations for Programmatic Turn-Based Game

Thanks to the updates to GameKit API in iOS 6, I am finally able to implement my turn-based board game the way it should be, complete with turn timeouts and better programmatic creation of matches. However, I am running into an issue that I cannot seem to solve. My desire is to have Game Center running entirely invisible to the end-user, so that everything is programmatic and uses my own custom interfaces.
Therefore, I use my own custom table view to display matches, not the default GKTurnBasedMatchmakerViewController. Right now, I have no problem displaying open matches using the -loadMatchesWithCompletionHandler: method. I also use a custom screen to create a match, with a direct creation for auto-match (not a problem) and a table view that loads Game Center friends of the localPlayer for invitation. Since the playersToInvite attribute can now be filled with playerID's, this is possible in iOS 6.
My main problem is handling the invitation on the recipient's side. Lets say I invite Bob to play my game in a two-player match. Right now I can't seem to find a notification for a new invite on Bob's end. The -handleTurnEvent: only gets called for existing matches or if the banner notification is touched (which I can't guarantee the user will do), and -handleInviteFromGameCenter: does nothing for me in this case.
The only way I have come up with to detect new invites and thus update my custom game view controller is to call the -loadMatchesWithCompletionHandler: method and check for new matches in which lastTurnDate of the invited participant is nil and against an existing array of open matches. I run this check about every 10 seconds in the background since I can't find a notification in GKTurnBasedEventHandler that is called when a new invite is received. Please help!
EDIT: In the end, I have just implemented a pull-to-refresh functionality. There is no way without implementing polling or some other method that would just waste the user's data on their phone, so on demand refreshing is the most ideal solution in my opinion.
Please see this : GKInvite Reference and more specifically inviteHandler.
You just need to register an inviteHandler which will be called after Bob accepts the invite in GK/GC.
T.

OpenFeint achievements performance

I've decided to integrate OpenFeint into my new game to have achievements and leaderboards.
The game is dynamic and I would like user to be rewarded immediately for some successful results, but as it seems for me, OpenFeint's achievements are a bit sluggish and it shows visual notification only when it receives confirmation from the server.
Is it possible to change something in settings or hack it a little bit to show notification immediately as soon as it checks only local database if the achievement has not been unlocked it?
Not sure if this relates to the Android version of the SDK (which seems even slower), but we couldn't figure out how to make it faster. It was so unacceptably slow that we started developing our own framework that fixes most of open feint's shortcomings and then some. Check out Swarm, it might fit your needs better.
There are several things you can do to more tightly control the timing of these notifications. I'll explain one approach and you can use this as a starting point to explore further on your own. These suggestions apply specifically to iOS apps. One caveat is that these suggestions refer to internal APIs in OFSDK 2.8 for iOS and not ordinarily recommended for high level use and subject to change in future versions.
The first thing I recommend is that you build the sample app with your own product key. Use the standard sample app to experiment before applying the result to your own code.
You are going to get the snappiest response by separating the notification pop-up UI from the process of submitting the achievement. This way you don't have to worry about getting wrapped up in the logic for deciding whether the submission is going just to the local db or is doing the full confirmation on an async network transaction.
See the declaration of "showAchievementNotice" in "OFNotification.h". Performing a search in the sample app, you will see that this is the internal API used for displaying the achievement pop-up when an achievement is earned. It does not actually submit the achievement. You can call this method directly as it is called from "OFAchievementService.mm" to directly control when the message appears. You can then use the following article to disable the pop-up from being called when the actual submission occurs:
http://support.openfeint.com/dev/notification-pop-ups-in-ios/
This gives you complete freedom to call the submission at a later time provided you keep track of the need to do so. For example, you could locally serialize a flag to take care of the actual submission either after the level is done or the next time the app starts up. Don't forget that the user could quit out of a game without cleanly finishing a level.