public void submitScore(int score) { if (loggedIn) { SwarmLeaderboard.submitScoreGetRank(SwarmConsts.Leaderboard.LEADERBOARD_ID, score, delegate(int rank){ checkRGBMaster(rank); }); } else { SwarmLeaderboard.submitScore(SwarmConsts.Leaderboard.LEADERBOARD_ID, score); } }
// Use this for initialization void Start() { // SwarmLoginManager.addLoginListener(delegate(int status) { // if (status == SwarmLoginManager.USER_LOGGED_IN) { // // The player has successfully logged in // // For example, you may wish to call Application.LoadLevel("MyLevel"); // } else if (status == SwarmLoginManager.LOGIN_STARTED) { // // The player has started logging in // } else if (status == SwarmLoginManager.LOGIN_CANCELED) { // // The player has cancelled the login // } else if (status == SwarmLoginManager.USER_LOGGED_OUT) { // // The player has logged out // } // }); //Swarm.showLeaderboards(); SwarmLeaderboard.showLeaderboard(7801); }
/** * Submit a score to the leaderboard for ranking and get the user's rank back asynchronously. * * @param leadeboardId The Id number of the leaderboard you want to submit to. * @param score The player's score to be submitted. * @param action The action to be performed (delegate to be called) when the callback is complete (the user data is returned). */ public static void submitScoreGetRank(int leaderboardId, float score, System.Action <int> action) { #if UNITY_ANDROID #if !UNITY_EDITOR string objName = "SwarmLeaderboard." + leaderboardId + "." + score + "." + DateTime.Now.Ticks; GameObject gameObj = new GameObject(objName); DontDestroyOnLoad(gameObj); SwarmLeaderboard component = gameObj.AddComponent <SwarmLeaderboard>(); component.callbackAction = action; AndroidJavaObject callback = new AndroidJavaObject("java.lang.String", objName); jvalue[] args = new jvalue[3]; args[0].i = leaderboardId; args[1].f = score; args[2].l = callback.GetRawObject(); AndroidJNI.CallStaticVoidMethod(swarmUnityInterface, submitScoreGetRankMethod, args); #endif #endif }