public void submitAchievementScore(Action <bool, string> callback)
        {
            submitAchievementScoreCallback = callback;
            string gameObjectName = "OpenKitSubmitAchievementScoreObject." + DateTime.Now.Ticks;

            callbackGameObjectName = gameObjectName;


            // Create a new OKAchievementScore gameobject (called scoreComponent) and give it a unique name
            // This allows us to track unique score submission requests and handle
            // async native code

#if !UNITY_EDITOR
            GameObject gameObject = new GameObject(gameObjectName);
            DontDestroyOnLoad(gameObject);

            OKAchievementScore achievementScoreComponent = gameObject.AddComponent <OKAchievementScore>();
            achievementScoreComponent.submitAchievementScoreCallback = callback;

            achievementScoreComponent.progress                             = progress;
            achievementScoreComponent.OKAchievementID                      = OKAchievementID;
            achievementScoreComponent.callbackGameObjectName               = gameObjectName;
            achievementScoreComponent.GameCenterAchievementIdentifier      = GameCenterAchievementIdentifier;
            achievementScoreComponent.GameCenterAchievementPercentComplete = GameCenterAchievementPercentComplete;

            OKManager.SubmitAchievementScore(achievementScoreComponent);
#endif
        }
Beispiel #2
0
 public void _SubmitAchievementScore(OKAchievementScore achievementScore)
 {
     nativeBridge.SubmitAchievementScore(achievementScore);
 }
Beispiel #3
0
 public static void SubmitAchievementScore(OKAchievementScore achievementScore)
 {
     OKManager.Instance._SubmitAchievementScore(achievementScore);
 }
Beispiel #4
0
 public void _SubmitAchievementScore(OKAchievementScore achievementScore)
 {
     nativeBridge.SubmitAchievementScore(achievementScore);
 }
Beispiel #5
0
 public static void SubmitAchievementScore(OKAchievementScore achievementScore)
 {
     OKManager.Instance._SubmitAchievementScore(achievementScore);
 }
 public void SubmitAchievementScore(OKAchievementScore achievementScore)
 {
     OKAndroidPlugin.CallStatic("submitAchievementScore", achievementScore.progress, achievementScore.OKAchievementID, achievementScore.GetCallbackGameObjectName());
 }
 void UnlockSampleAchievement()
 {
     var achievementProgress = 5;
     var achievementID = 3;
     OKAchievementScore achievementScore = new OKAchievementScore(achievementProgress, achievementID);
     achievementScore.submitAchievementScore((success, errorMessage) => {
         if (success) {
             Debug.Log("Achievement score/progress submitted successfully!");
         } else {
             Debug.Log("Achievement score/progress did not submit. Error: " + errorMessage);
         }
     });
 }
Beispiel #8
0
    void OnGUI()
    {
        ///Scale the button sizes for retina displays
        float screenScale = (float)(Screen.width / 480.0);
        Matrix4x4 scaledMatrix = Matrix4x4.Scale(new Vector3(screenScale, screenScale, screenScale));
        GUI.matrix = scaledMatrix;

        if(GUI.Button(new Rect(30,10,400,100), "Show Leaderboards & Achievements"))
        {
            // Show leaderboards.
            // If the user is not logged into OpenKit, the login UI
            // will be shown ontop of the leaderboards
            OKManager.ShowLeaderboards();
        }

        if(GUI.Button(new Rect(30,120,400,100), "Show Login UI"))
        {
            // Show the OpenKit Login UI
            OKManager.ShowLoginToOpenKit();
        }

        if(GUI.Button(new Rect(30,230,400,100), "Submit Score to Level 3 Leaderboard"))
        {

        #if !UNITY_EDITOR
            // Submit a score to a leaderboard, with a value of 2134 to leaderboard ID 4
            // If the user is not logged in, the score will not be submitted successfully

            string scoreString = "" + DateTime.Now.Month;
            scoreString += DateTime.Now.Day;
            scoreString += DateTime.Now.Hour;
            scoreString += DateTime.Now.Minute;

            long scoreValue = long.Parse(scoreString);

            OKScore score = new OKScore(scoreValue, 4);

            // Set the displayString to include the units of the score
            score.displayString = score.scoreValue + " points";

            // Store some metadata in the score-- this is not used by OpenKit but is stored and returned with each score
            score.metadata = 1;

            score.submitScore(scoreSubmitHandler);

        #endif
        }

        if(GUI.Button(new Rect(30,340,400,100), "Unlock Achievement"))
        {
            //Unlock achievement by setting its progress for the current user
            // to 5. The achievement ID is pulled from the OpenKit dashboard,
            // and we know that the target goal of the achievement is also 5 which is set in the dashboard,
            // so this unlocks the achievement

            OKAchievementScore achievementScore = new OKAchievementScore(5, 3);

            achievementScore.submitAchievementScore(achievementScoreSubmitHandler);
        }

        if(GUI.Button(new Rect(30,450,400,100), "Store dictionary"))
        {
            //Store a dictionary

            ArrayList y = new ArrayList();
            y.Add("First element.");
            y.Add("Second!");

            Dictionary<string, object> x = new Dictionary<string, object>();
            x.Add("prop1", "YEAAAAAAH BUDDY.");
            x.Add("prop2", 99);
            x.Add("prop3", y);

            // Cloud store.
            OKCloud.Set(x, "aKey", delegate(object obj, OKCloudException err)
            {
                if (err == null) {
                    OKLog.Info("Stored object of type: " + obj.GetType().Name);
                } else {
                    OKLog.Info("Error during store: " + err);
                }
            });
        }

        if(GUI.Button(new Rect(30,560,400,100), "Retrieve dictionary"))
        {
            //Retrieve the dictionary

            OKCloud.Get("aKey", delegate(JSONObject obj, OKCloudException err)
            {
                if (err == null) {
                    OKLog.Info("Retrieved object of type: " + obj.GetType().Name);
                    OKLog.Info("Obj: " + obj);
                    OKLog.Info("Can I get an element of an Array? " + obj.GetField("prop3")[1]);
                } else {
                    OKLog.Info("Error during store: " + err);
                }
            });
        }
    }
Beispiel #9
0
 void UnlockSampleGamecenterAchievementOnly()
 {
     OKAchievementScore score = new OKAchievementScore();
     score.GameCenterAchievementIdentifier = "achievement2";
     score.GameCenterAchievementPercentComplete = 100f;
     score.submitAchievementScore((success, errorMessage) => {
         if (success) {
             OKLog.Info("GC achievement score/progress submitted successfully!");
         } else {
             OKLog.Info("GC achievement score/progress did not submit. Error: " + errorMessage);
         }
     });
 }
Beispiel #10
0
    void UnlockSampleAchievement()
    {
        int SampleAchievementID = 189;
        int SampleAchievementProgress = 10;
        string SampleAchievementGamecenterID = "achievement2";

        OKAchievementScore achievementScore = new OKAchievementScore(SampleAchievementProgress, SampleAchievementID);

        // On iOS, we can also support GameCenter achievements with this simple wrapper
        achievementScore.GameCenterAchievementIdentifier = SampleAchievementGamecenterID;
        achievementScore.GameCenterAchievementPercentComplete = 100.0f;

        achievementScore.submitAchievementScore((success, errorMessage) => {
            if (success) {
                OKLog.Info("Achievement score/progress submitted successfully!");
            } else {
                OKLog.Info("Achievement score/progress did not submit. Error: " + errorMessage);
            }
        });
    }