Exemple #1
0
 void GCAuthentication(string status)
 {
     print("delegate call back status= " + status);
     print("Before alias= " + KTGameCenter.SharedCenter().PlayerAlias + " name= " +
           KTGameCenter.SharedCenter().PlayerName + " id= " + KTGameCenter.SharedCenter().PlayerId);
     StartCoroutine(CheckAttributes());
 }
Exemple #2
0
    IEnumerator CheckAttributes()
    {
        yield return(new WaitForSeconds(1.0f));

        print(" alias= " + KTGameCenter.SharedCenter().PlayerAlias + " name= " +
              KTGameCenter.SharedCenter().PlayerName + " id= " + KTGameCenter.SharedCenter().PlayerId);
    }
    void authenticate()
    {
        #if USE_MOBILE_LEADERBOARD
                #if             UNITY_ANDROID
        // Authenticate
        //mWaitingForAuth = true;
        mDebug("Authenticating...");
        if (Social.localUser.authenticated == false)
        {
            Social.localUser.Authenticate((bool success) => {
                //mWaitingForAuth = false;
                if (success)
                {
                    mDebug("Welcome " + Social.localUser.userName);
                    std_call_computeAchievements();
                }
                else
                {
                    mDebug("Authentication failed.");
                }
            });
        }
#endif
                #if UNITY_IOS
        KTGameCenter.SharedCenter().Authenticate();
#endif
        #endif
    }
Exemple #4
0
 void OnDisable()
 {
     KTGameCenter.SharedCenter().GCUserAuthenticated    -= GCAuthentication;
     KTGameCenter.SharedCenter().GCScoreSubmitted       -= ScoreSubmitted;
     KTGameCenter.SharedCenter().GCAchievementSubmitted -= AchievementSubmitted;
     KTGameCenter.SharedCenter().GCAchievementsReset    -= AchivementsReset;
     KTGameCenter.SharedCenter().GCMyScoreFetched       -= MyScoreFetched;
 }
Exemple #5
0
    IEnumerator RegisterForGameCenter()
    {
        yield return(new WaitForSeconds(0.5f));

        KTGameCenter.SharedCenter().GCUserAuthenticated    += GCAuthentication;
        KTGameCenter.SharedCenter().GCScoreSubmitted       += ScoreSubmitted;
        KTGameCenter.SharedCenter().GCAchievementSubmitted += AchievementSubmitted;
        KTGameCenter.SharedCenter().GCAchievementsReset    += AchivementsReset;
        KTGameCenter.SharedCenter().GCMyScoreFetched       += MyScoreFetched;
    }
Exemple #6
0
 void OnGUI()
 {
     if (!KTGameCenter.SharedCenter().IsGameCenterAuthenticated())
     {
         GUI.skin.label.fontSize = 20;
         GUI.Label(new Rect(10, 150, 200, 50), "Authenticating!");
     }
     else
     {
         GUI.skin.button.fontSize = 20;
         if (GUI.Button(new Rect(10, 150, 300, 60), "Show Leaderboards"))
         {
             KTGameCenter.SharedCenter().ShowLeaderboard();
         }
         if (GUI.Button(new Rect(10, 250, 250, 60), "Submit Score"))
         {
             KTGameCenter.SharedCenter().SubmitScore(110, "grp.com.kashiftasneem.thedarkshadow.highestscoresinglerun");
         }
         if (GUI.Button(new Rect(300, 250, 250, 60), "Submit Achievement"))
         {
             KTGameCenter.SharedCenter().SubmitAchievement(100, "grp.com.kashiftasneem.thedarkshadow.kill1zombie", true);
         }
         if (GUI.Button(new Rect(10, 350, 300, 60), "Reset Achievement"))
         {
             KTGameCenter.SharedCenter().ResetAchievements();
         }
         if (GUI.Button(new Rect(330, 350, 250, 60), "Submit Float Score"))
         {
             KTGameCenter.SharedCenter().SubmitFloatScore(110.123f, 3, "com.kashiftasneem.flyingbird.testfloat");
         }
         if (GUI.Button(new Rect(10, 450, 250, 60), "Submit Time"))
         {
             KTGameCenter.SharedCenter().SubmitFloatScore(2459.3f, 2, "com.kashiftasneem.flyingbird.testtime");
         }
         if (GUI.Button(new Rect(10, 550, 250, 60), "Fetch my Score"))
         {
             KTGameCenter.SharedCenter().FetchMyScore("grp.com.kashiftasneem.thedarkshadow.highestscoresinglerun");
         }
     }
 }
    void Start()
    {
        //FOR SCREEN SHOOTING !
        //PlayerPrefs.SetInt("Coins", 1000000);



        Application.targetFrameRate = 60;

        mode = "Main";
        zoom = "mainMenu";

        // Locate sound manager
        GameObject soundManager = GameObject.Find("SoundManager");

        soundEffectController = (SoundEffectController)soundManager.GetComponent(typeof(SoundEffectController));

        // Update the music & sound according to the PlayerPrefs
        UpdateMusicToggle();
        UpdateSoundToggle();

        // Play sound effect
        soundEffectController.playStartEngine();

        //Game center set up
        KTGameCenter.SharedCenter().Authenticate();


        //If its player first time playing, show tutorial.
        int showedTutorial = PlayerPrefs.GetInt("tutorial", 0);

        //If tutorial not opened before.
        if (showedTutorial == 0)
        {
            //open tutorial
            openTutorialScreen();
        }
    }
    public void submitScore()
    {
        //Submit to GameCenter
        //gameCenterController.SubmitScore(score, "ScoreLeaderBoard");

        KTGameCenter.SharedCenter().SubmitScore(score, "ScoreLeaderBoard");


        if (score > currentHighScore)
        {
            //Submit HighScore to player prefeb
            PlayerPrefs.SetInt("HighScore", score);
            currentHighScore = score;

            Debug.Log("Submmited Score, score " + score + " High Score: " + currentHighScore);

            highScoreText.SetText(currentHighScore.ToString());
            newBestScoreImage.SetActive(true);
        }
        else
        {
            newBestScoreImage.SetActive(false);
        }
    }
 public void test_authenticate_only()
 {
     #if USE_MOBILE_LEADERBOARD
             #if             UNITY_ANDROID
     Social.localUser.Authenticate(success => {
         if (success)
         {
             //Debug.Log ("Authentication successful");
             string userInfo = "Username: "******"\nUser ID: " + Social.localUser.id +
                               "\nIsUnderage: " + Social.localUser.underage;
             //Debug.Log (userInfo);
         }
         else
         {
             //Debug.Log ("Authentication failed");
         }
     });
             #endif
     #if UNITY_IOS
     KTGameCenter.SharedCenter().Authenticate();
     #endif
     #endif
 }
 /// <summary>
 /// Shows the leader board.
 /// </summary>
 public void showLeaderBoard()
 {
     Debug.Log("Show Leader Board");
     //Show leader Board
     KTGameCenter.SharedCenter().ShowLeaderboard("ScoreLeaderBoard");
 }
Exemple #11
0
 void Start()
 {
     KTGameCenter.SharedCenter().Authenticate();
 }
    bool compute_achievements()
    {
                #if USE_MOBILE_LEADERBOARD
        int achievementState = 0;
        int keyValue         = 0;
        int i = 0;
        if (achievements != null)                                                                                                               //are there Achievements?
        {
            foreach (achievement a in achievements)                                                                                             //for each of them

            {
                keyValue = readScoreFromPlayerprefs(a.scoreKey);

                if (keyValue >= a.MinScoreValue)                                                                //and test, if is reached
                {
                    achievementState = PlayerPrefs.GetInt(a.AchievementName + "_state");                        //and already reported.
                    a.__reached      = true;                                                                    //When it is reached
                    if (achievementState == 0 || a.__transmitted == true)                                       //and it is not already reported,
                    {
                        if (a.achievement_message != null)
                        {
                            setAchievmentText(a.achievement_message.text);                                                              //tell the congratulations to the user.
                        }
                        if (a.__transmitRequested == false)                                                                             //Then test, if there was a request for transmit

                        {
                            if (a.__transmitted == false)                                                                                               //and if it was transmitted.
                            {
                                                                #if UNITY_IOS
                                KTGameCenter.SharedCenter().SubmitAchievement(100, a.AchievementID, true);
                                                                #endif
                                                                #if             UNITY_ANDROID
                                Social.ReportProgress(a.AchievementID, 100.0f, (bool success) => {                                      //ok, then we can report it, but:
                                    // handle success or failure
                                    if (success)
                                    {
                                        PlayerPrefs.SetInt(a.AchievementName + "_state", 1);
                                        //achievement_reported = true;

                                        a.__transmitted = true;
                                    }
                                    else
                                    {
                                        //Debug.Log ("no");
                                    }

                                    a.__transmitted = true;
                                });
                                                                #endif
                                a.__transmitted       = true;
                                a.__transmitRequested = true;                                                                                           //memorize, we requested the transmit.
                            }
                            return(false);
                        }
                    }
                }
                i++;
            }
        }
        return(true);
                #else
        return(false);
                #endif
    }