Пример #1
0
    // ------------------------------------------------------------------


    // make an initial connection to game center
    public static bool ConnectToGameCenter()
    {
        if (CoreXT.IsDevice)
        {
            SocialXT.PostCompleted += OnPostCompleted;

            GameKitXT.LocalPlayerAuthenticated        += OnLocalPlayerAuthenticated;
            GameKitXT.LocalPlayerAuthenticationFailed += OnLocalPlayerAuthenticationFailed;
            GameKitXT.AuthenticateLocalPlayer();

            // if SL Requests cannot be made on the device, turn off the social buttons for this user
            if (U3DXT.iOS.Native.Social.SLRequest.ClassExists == false)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }

        else
        {
            return(false);
        }
    }
Пример #2
0
    // ----------


    // called when a player attempts to open the leaderboard
    public static void ViewLeaderboard()
    {
        if (isConnected == 1)
        {
            GameKitXT.ShowLeaderboard("ZoneReached");
        }
    }
Пример #3
0
 // called when a player attempts to view the game's achievements
 public static void ViewAchievements()
 {
     if (isConnected == 1)
     {
         GameKitXT.ShowAchievements();
     }
 }
Пример #4
0
    // ----------

    // 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);
            }
        }
    }
Пример #5
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
 }
Пример #6
0
    void Start()
    {
        if (CoreXT.IsDevice)
        {
            // subscribe to events
            GameKitXT.LocalPlayerAuthenticated        += OnLocalPlayerAuthenticated;
            GameKitXT.LocalPlayerAuthenticationFailed += LocalPlayerAuthenticationFailed;

            GameKitXT.ScoreReported     += OnScoreReported;
            GameKitXT.ScoreReportFailed += OnScoreReportFailed;

            GameKitXT.AchievementReported     += OnAchievementReported;
            GameKitXT.AchievementReportFailed += OnAchievementReportFailed;

            // finally authenticate player
            GameKitXT.AuthenticateLocalPlayer();
        }
    }
Пример #7
0
    //private string leaderboardID = "CgkItsLusNkLEAIQAg";
        #endif

    public void GameCenterConection()
    {
                #if UNITY_IOS && !UNITY_EDITOR
        if (CoreXT.IsDevice)
        {
            GameKitXT.LocalPlayerAuthenticated += delegate(object sender, EventArgs e) {
                PlayerData.playername = GameKitXT.localPlayer.alias;
            };

            GameKitXT.LocalPlayerAuthenticationFailed += delegate(object sender, U3DXTErrorEventArgs e) {  };



            GameKitXT.AuthenticateLocalPlayer();
        }
                #endif

                #if UNITY_ANDROID && !UNITY_EDITOR
        /*GooglePlayGames.PlayGamesPlatform.Activate();
         * Debug.Log("Activate");
         * GooglePlayGames.OurUtils.Logger.DebugLogEnabled=true;
         *
         *
         *
         * if (!Social.localUser.authenticated) {
         *      // Authenticate
         *      Debug.Log("Authenticating");
         *
         *      Social.localUser.Authenticate((bool success) => {
         *              //GameObject.Find ("TESTE").transform.GetChild(0).GetComponent<Text>().text="After Authenticate";
         *              if (success) {
         *                      //GameObject.Find ("TESTE").transform.GetChild(0).GetComponent<Text>().text="Auth SUCCESS";
         *                      Debug.Log("Authentication successful");
         *              }
         *              else
         *              {
         *                      //GameObject.Find ("TESTE").transform.GetChild(0).GetComponent<Text>().text="Auth Failed";
         *                      Debug.Log("Authentication failed");
         *              }
         *      });
         * }*/
                #endif
    }
Пример #8
0
    void Start()
    {
        // only do it on device
        if (CoreXT.IsDevice)
        {
            // subscribe to events
            GameKitXT.LocalPlayerAuthenticated        += OnLocalPlayerAuthenticated;
            GameKitXT.LocalPlayerAuthenticationFailed += LocalPlayerAuthenticationFailed;

            // init real time multiplayer events and controller
            RealTimeMatchesController.MatchMakerCancelled  += OnMatchMakerCancelled;
            RealTimeMatchesController.MatchMakerFailed     += OnMatchMakerFailed;
            RealTimeMatchesController.MatchMakerFoundMatch += OnMatchMakerFoundMatch;
            RealTimeMatchesController.InviteAccepted       += OnInviteAccepted;
            RealTimeMatchesController.PlayersInvited       += OnPlayersInvited;
            RealTimeMatchesController.Init();

            // finally authenticate player
            GameKitXT.AuthenticateLocalPlayer();
        }
    }
Пример #9
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();
    }