This is an upcoming rebrand of the Skee-Ball 2 game released on Android and re-released on iOS coming soon.


Splash ScreenScreenshot_2013-06-26-15-06-52Screenshot_2013-06-26-15-07-43

A lot of the code in this game is held over from the Skee-Ball 2 game, but we did add some functionality and change some of the user experience. These samples are from the new additions.

Below is some sample code I wrote for integrating a new SDK into the game so we could release the game under a new publishing agreement with Mobage. These functions utilize a callback system, which I demonstrate implementing both inline and in separate declared functions.

This function is specific to an Android only implementation of our SocialManager class. Inline callback implementation.

SocialManager.cs:

public override void Init (string facebookID, string[] facebookPermissions, string twitterKey, string twitterSecret)
{
SocialManager.instance.QuitIfNoInternet();

// init Mobage, trigger login, and register user
if(!Application.isEditor)
{

Mobage.Mobage.initializeMobageWithStandardParameters(ServerEnvironment.Production, appID, appVersion, mobageConsumerKey, mobageConsumerSecret);
Mobage.SocialService.executeLogin((status, error) => {
switch (status)
{
case Mobage.CancelableAPIStatus.CancelableAPIStatusCancel:
Debug.Log ("Login was Canceled by player, re initializing");
// This is because Mobage doesn't allow full use of the game without logging in to their system, so we have to re-initialize the Mobage Login if they cancel
SocialManager.instance.InitMobage();
break;
case Mobage.CancelableAPIStatus.CancelableAPIStatusError:
Debug.Log ("Login Failed! Error: " + error.localizedDescription + error.code + error.domain);
break;
case Mobage.CancelableAPIStatus.CancelableAPIStatusSuccess:
Debug.Log ("Login Successful. User is logged in now!");
isLoggedInMobage = true;
People.getCurrentUser((getStatus, getError, currentUser) => {
if(getStatus == SimpleAPIStatus.SimpleAPIStatusSuccess)
GlobalData.Instance.currentUser = currentUser;
else if(getStatus == SimpleAPIStatus.SimpleAPIStatusError)
Debug.Log ("Mobage User didn't return a valid user: " + getError.localizedDescription + getError.code + getError.domain);
});
break;
}
});
}

TwitterAndroid.init(twitterKey, twitterSecret);
}

These functions are for reporting some of our score tracking to the users Mobage account. Separate callback implementation.

TicketManager.cs:

void ReportMobageTickets()
{
string boardID = All_TIME_TICKETS_LEADERBOARD_ID.Replace ("grp.ldr.","");
Mobage.GameLeaderboard.getLeaderboardForId(boardID,GetGameLeaderboard_Callback);
}

void GetGameLeaderboard_Callback(Mobage.SimpleAPIStatus status, Mobage.Error error,Mobage.GameLeaderboard board)
{
if(status != Mobage.SimpleAPIStatus.SimpleAPIStatusError)
{
Mobage.GameLeaderboard.updateCurrentUserScoreForLeaderboard (board,scoreToReport,UpdateLeaderboard_Callback);
}
else
Debug.Log ("Get Leaderboard failed in TicketManager: " + error.description + " " + error.domain);
}

void UpdateLeaderboard_Callback(Mobage.SimpleAPIStatus status, Mobage.Error error, Mobage.Score score)
{
if(status != Mobage.SimpleAPIStatus.SimpleAPIStatusError)
{
Debug.Log ("Tickets Updated");

// This new leaderboard UI isn't fully implemented yet
if(!Application.isEditor)
RefreshLeaderboardUI();
}
else
Debug.Log ("Ticket Update failed: " + error.description + " " + error.domain);
}