public static string GetPlayerName()
        {
#if UNITY_IOS
            return(GameCenterBinding.playerAlias());
#elif UNITY_ANDROID && !CHS
            return(PlayGameServices.getLocalPlayerInfo().name);
#else
            return(string.Empty);
#endif
        }
        private void OnAuthenticationSucceeded()
        {
            if (debugMode)
            {
                Debug.LogFormat("PlayGameCenterManager:OnAuthenticationSucceeded()");
            }

            ProcessAuthenticationSucceeded();

            playerNameLoadedEvent?.Invoke(GameCenterBinding.playerAlias());
        }
示例#3
0
    //public AudioClip bgmusic;

    // Use this for initialization
    void Start()
    {
        GameCenterManager.categoriesLoaded += delegate(List <GameCenterLeaderboard> leaderboards)
        {
            this.leaderboards = leaderboards;
        };

        GameCenterManager.achievementMetadataLoaded += delegate(List <GameCenterAchievementMetadata> achievementMetadata)
        {
            this.achievementMetadata = achievementMetadata;
        };

        GameCenterBinding.authenticateLocalPlayer();
        GameCenterBinding.loadLeaderboardTitles();

        string alias = GameCenterBinding.playerAlias();
    }
示例#4
0
    public void Update()
    {
        int    courseIndex = m_gameScript.getCourseIndex();
        string userName    = playerName;
        int    totalScore  = m_gameScript.getTotalScore();
        int    totalPar    = m_gameScript.getTotalPar();

                #if PHOTON_MULTIPLAYER
        //if we are online, and we have an opponent lets show the results
        if (PhotonNetwork.offlineMode == false && Misc.haveOpponent())
        {
            if (m_oneTime == false)
            {
                resultsGT.text = LevelingManager.setResults(totalScore);
                m_oneTime      = true;
            }
        }
#endif
        if (RuntimePlatform.IPhonePlayer == RuntimePlatform.IPhonePlayer)
        {
#if GOT_PRIME31_GAMECENTER
            userName = GameCenterBinding.playerAlias();
#endif
        }

        if (usernameGT)
        {
            usernameGT.text = userName;
        }
        if (totalScoreGT)
        {
            totalScoreGT.text = totalScore.ToString();
        }

        if (totalParGT)
        {
            totalParGT.text = totalPar.ToString();
        }
    }
示例#5
0
    void OnGUI()
    {
        float yPos       = 5.0f;
        float xPos       = 5.0f;
        float width      = (Screen.width >= 960 || Screen.height >= 960) ? 320 : 160;
        float height     = (Screen.width >= 960 || Screen.height >= 960) ? 80 : 40;
        float heightPlus = height + 5.0f;


        if (GUI.Button(new Rect(xPos, yPos, width, height), "Authenticate"))
        {
            GameCenterBinding.authenticateLocalPlayer();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Load Achievement Metadata"))
        {
            GameCenterBinding.retrieveAchievementMetadata();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Get Raw Achievements"))
        {
            GameCenterBinding.getAchievements();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Post Achievement"))
        {
            if (achievementMetadata != null && achievementMetadata.Count > 0)
            {
                int percentComplete = (int)Random.Range(2, 60);
                Debug.Log("sending percentComplete: " + percentComplete);
                GameCenterBinding.reportAchievement(achievementMetadata[0].identifier, percentComplete);
            }
            else
            {
                Debug.Log("you must load achievement metadata before you can post an achievement");
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Issue Achievement Challenge"))
        {
            if (achievementMetadata != null && achievementMetadata.Count > 0)
            {
                var playerIds = new string[] { "player1", "player2" };
                GameCenterBinding.issueAchievementChallenge(achievementMetadata[0].identifier, playerIds, "I challenge you");
            }
            else
            {
                Debug.Log("you must load achievement metadata before you can issue an achievement challenge");
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Show Achievements"))
        {
            GameCenterBinding.showAchievements();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Reset Achievements"))
        {
            GameCenterBinding.resetAchievements();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Multiplayer Scene"))
        {
            Application.LoadLevel("GameCenterMultiplayerTestScene");
        }


        // Second Column
        xPos = Screen.width - width - 5.0f;
        yPos = 5.0f;


        if (GUI.Button(new Rect(xPos, yPos, width, height), "Get Player Alias"))
        {
            string alias = GameCenterBinding.playerAlias();
            Debug.Log("Player alias: " + alias);
        }



        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Load Leaderboard Data"))
        {
            GameCenterBinding.loadLeaderboardTitles();
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Post Score"))
        {
            // We must have a leaderboard to post the score to
            if (leaderboards != null && leaderboards.Count > 0)
            {
                Debug.Log("about to report a random score for leaderboard: " + leaderboards[0].leaderboardId);
                GameCenterBinding.reportScore(Random.Range(1, 99999), leaderboards[0].leaderboardId);
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Issue Score Challenge"))
        {
            // We must have a leaderboard to post the score to
            if (leaderboards != null && leaderboards.Count > 0)
            {
                var playerIds = new string[] { "player1", "player2" };
                var score     = Random.Range(1, 9999);
                GameCenterBinding.issueScoreChallenge(score, 0, leaderboards[0].leaderboardId, playerIds, "Beat this score!");
            }
            else
            {
                Debug.Log("you must load your leaderboards before you can issue a score challenge");
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Show Leaderboards"))
        {
            GameCenterBinding.showLeaderboardWithTimeScope(GameCenterLeaderboardTimeScope.AllTime);
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Get Raw Score Data"))
        {
            // We must have a leaderboard to retrieve scores from
            if (leaderboards != null && leaderboards.Count > 0)
            {
                GameCenterBinding.retrieveScores(false, GameCenterLeaderboardTimeScope.AllTime, 1, 25, leaderboards[0].leaderboardId);
            }
            else
            {
                Debug.Log("Load leaderboard data before attempting to retrieve scores");
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Get Scores for Me"))
        {
            // We must have a leaderboard to retrieve scores from
            if (leaderboards != null && leaderboards.Count > 0)
            {
                GameCenterBinding.retrieveScoresForPlayerId(GameCenterBinding.playerIdentifier(), leaderboards[0].leaderboardId);
            }
            else
            {
                Debug.Log("Load leaderboard data before attempting to retrieve scores");
            }
        }


        if (GUI.Button(new Rect(xPos, yPos += heightPlus, width, height), "Retrieve Friends"))
        {
            GameCenterBinding.retrieveFriends(true);
        }
    }
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Get Player Alias"))
        {
            string alias = GameCenterBinding.playerAlias();
            Debug.Log("Player alias: " + alias);
        }


        if (_hasFriends)
        {
            // see if we have any friends with a profile image on disk
            var friendWithProfileImage = _friends.Where(f => f.hasProfilePhoto).FirstOrDefault();
            GUI.enabled = friendWithProfileImage != null;
            if (GUILayout.Button("Show Friends Profile Image"))
            {
                var tex = friendWithProfileImage.profilePhoto;

                // grab our cube and display it with the texture
                var cube = GameObject.Find("Cube");
                cube.renderer.enabled = true;
                cube.renderer.material.mainTexture = tex;
            }
            GUI.enabled = true;
        }


        if (GUILayout.Button("Load Received Challenges"))
        {
            GameCenterBinding.loadReceivedChallenges();
        }


        if (GUILayout.Button("Show GC Leaderboards (iOS 6+)"))
        {
            GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Leaderboards);
        }


        if (GUILayout.Button("Show GC Achievements (iOS 6+)"))
        {
            GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Achievements);
        }


        endColumn(true);



        // toggle to show two different sets of buttons
        if (toggleButtonState("Show Achievement Buttons"))
        {
            leaderboardsGUI();
        }
        else
        {
            achievementsGUI();
        }
        toggleButton("Show Achievement Buttons", "Show Leaderboard Buttons");


        endColumn();


        if (bottomLeftButton("Load Multiplayer Scene (Requires Multiplayer Plugin!)", 340))
        {
            Application.LoadLevel("GameCenterMultiplayerTestScene");
        }
    }
示例#7
0
 // Gets the alias of the current player.
 public string GetPlayerAlias()
 {
     //Debug.Log ("GameCenter::GetAlias");
     PlayerAlias = GameCenterBinding.playerAlias();
     return(PlayerAlias);
 }