OpenFeint is a fairly popular social network for players. The social component is always important for casual (and not only) games, because it adds interest to the game from users, and it also contributes to distribution.
So, our task at the moment is
to embed OpenFeint into our project of a game on Unity3d . So, everything is in order.
First you need to register on the OpenFient site in
the developers section . After registration, we create a new game, simply by clicking the "Add new game" button. You must select the platform on which you are going to publish the game and enter its name. Everything is half done.
If viewed in a cross-sectional perspective (iOS and Android), then OpenFeint supports game achievements (achievements, or achievements in common people) and leaderboards (leaderboards). You can go to those and others by clicking the Features tab in the so-called developer's dashboard. The remaining features are currently supported only for iOS.
We add the necessary leaderboards, we fill in the achivki. Each of them has a very important parameter - Unique ID. And we will need it, with its help we will open achievements and fill in leaderboards.
Get down to business. Everything is simple: download the OpenFeint Unity SDK
for iOS or
for Android . The contents of the SDK must be placed in the project's Plugins folder (via adding assets or dragging into the project hierarchy). The OpenFeintFacade class represents the main set of functions for working with the OpenFeint social network functions.
In the example that is attached to the SDK, it is done as described below (the source code may be slightly different from the original example, but it is working).
We create our own class, which at the start creates an object-facade for the open-end. In it we will use the OpenFeint functions. We will call the class OpenFeintController and place the script on the GameObject in the Unity3d scene we need. Through him, and we will call all that we need.
private static OpenFeintFacade openFeint; private static OpenFeintController instance; private const string appName = "";
Add a couple of functions for opening a deshbord, filling a high-speed leaderboard and unlocking achivok:
')
public static void ViewDashboard() { if(!Application.isEditor) { openFeint.OpenDashboard(); } } public static void ReportScore(int score, string leaderboard) { if (!Application.isEditor) { if (openFeint.isUserLoggedIn()) openFeint.SubmitScore(leaderboard, score); } } public static void UnlockAchievement(int achievementID) { if (!Application.isEditor) { if (openFeint.isUserLoggedIn()) openFeint.UnlockAchievement(achievementID); } }
You can add another function if your application uses achievements that open gradually (that is, you can set the progress of earning achievements - from 0 to 100%). OpenFeint is capable of it, and it is very interesting:
public static void UpdateAchievement(int achievementID, float percentage, bool showNotification) { if (!Application.isEditor) { if (openFeint.isUserLoggedIn()) openFeint.UpdateAchievement(achievementID, percentage, showNotification); } }
The OpenFeintFacade class contains many more useful features that will greatly enhance the sociality of the game being developed, but I really like it essentially. By the way, this example works only on Android. For iOS, things are a little different. To learn more, refer to the documentation on
iOS and
Android integration of OpenFeint in Unity3d.
All success, thank you for your time.
Related Links: