// ----------

    // called upon player game over.  Sends the user's current score to gamecenter
    public static void SendHighScore(int score)
    {
        // store the player's new high score on gamecenter
        if (isConnected == 1)
        {
            if (GameKitXT.localPlayer != null)
            {
                GameKitXT.ReportScore("InfectionsKilled", score);
            }
        }
    }
Beispiel #2
0
 public void SubmitScore(long score)
 {
             #if UNITY_IOS && !UNITY_EDITOR
     GameKitXT.ReportScore(leaderboardID, score);
             #endif
             #if UNITY_ANDROID && !UNITY_EDITOR
     /*Social.ReportScore(score, leaderboardID, (bool success) => {
      *      LoadHighScores();
      * });*/
             #endif
 }
Beispiel #3
0
    void OnGUI()
    {
        KitchenSink.OnGUIBack();

        if (CoreXT.IsDevice)
        {
            GUILayout.BeginArea(new Rect(50, 50, Screen.width - 100, Screen.height / 2 - 50));
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("Load Player Photo", GUILayout.ExpandHeight(true)))
            {
                GameKitXT.localPlayer.LoadPhoto(GKPhotoSize.Normal, delegate(Texture2D photo) {
                    if (photo != null)
                    {
                        Log("Loaded photo");
                        GameObject.Find("PlayerPhoto").guiTexture.texture = photo;
                    }
                    else
                    {
                        Log("Local player has no photo or error loading photo.");
                    }
                });
            }

            if (GUILayout.Button("Show Game Center", GUILayout.ExpandHeight(true)))
            {
                GameKitXT.ShowGameCenter();
            }

            if (GUILayout.Button("Show Banner", GUILayout.ExpandHeight(true)))
            {
                GameKitXT.ShowBanner("Game Kit Basics", "Hello from U3DXT!");

                long score = 100;
                Debug.Log("Reporting score " + score + " on leaderboard " + leaderboardID);
                Social.ReportScore(score, leaderboardID, success => {
                    Debug.Log(success ? "Reported score successfully" : "Failed to report score");
                });
            }

            if (GUILayout.Button("Show Leaderboard", GUILayout.ExpandHeight(true)))
            {
                GameKitXT.ShowLeaderboard(leaderboardID);
            }

            if (GUILayout.Button("Show Achievement", GUILayout.ExpandHeight(true)))
            {
                GameKitXT.ShowAchievements();
            }

            if (GUILayout.Button("Get Leaderboard", GUILayout.ExpandHeight(true)))
            {
                RetrieveTopTenScores();
            }

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            scoreText = GUILayout.TextField(scoreText, GUILayout.ExpandWidth(true));
            if (GUILayout.Button("Report Score", GUILayout.ExpandHeight(true)))
            {
                GameKitXT.ReportScore(leaderboardID, Convert.ToInt64(scoreText));
            }

            achievementText = GUILayout.TextField(achievementText, GUILayout.ExpandWidth(true));
            if (GUILayout.Button("Report Achievement", GUILayout.ExpandHeight(true)))
            {
                GameKitXT.ReportAchievement(achievementID, Convert.ToDouble(achievementText));
            }

            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }

        OnGUILog();
    }