Пример #1
0
 public void DisplayDefaultView()
 {
                 #if UNITY_IPHONE && API_SCORE_GAMECENTER
     if (Enabled)
     {
         GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Default);
     }
     else
     {
         Login();
     }
                 #endif
 }
Пример #2
0
    void OnGUI()
    {
        //PAUSE MENU
        if (displayMainMenu)
        {
            gameOver = false;
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);

            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.3f, buttonWidth, buttonHeight), "RESUME GAME", customHighlightStyle))
            {
                displayMainMenu       = false;
                displayMainMenuPaused = false;
                Camera.main.GetComponent <beeGUI>().dispMenu = true;
                Time.timeScale = 1;
            }

            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.4f, buttonWidth, buttonHeight), "LEADERBOARD", customButtonStyle))
            {
                if (GameCenterBinding.isPlayerAuthenticated())
                {
                    if (_hasLeaderboardData)
                    {
                        GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Leaderboards);
                    }
                }
                else
                {
                    GameCenterBinding.authenticateLocalPlayer();
                    GameCenterBinding.loadLeaderboardTitles();
                }
            }


            if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.5f, buttonWidth, buttonHeight), "RATE", customHighlightStyle))
            {
                Application.OpenURL("itms-apps://itunes.apple.com/app/id875911453");
            }


            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.6f, buttonWidth, buttonHeight), "EXTRA LIVES", customButtonStyle))
                {
                    displayExtraLives = true;
                    displayMainMenu   = false;
                }
            }


            if (EncryptedPlayerPrefs.GetInt("removeadverts") != 1)
            {
                if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
                {
                    if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.7f, buttonWidth, buttonHeight), "REMOVE ADS", customHighlightStyle))
                    {
                        displayRemoveAds = true;
                        displayMainMenu  = false;
                    }
                }
                else
                {
                    if (GUI.Button(new Rect((sW - buttonWidth) / 2, sH * 0.6f, buttonWidth, buttonHeight), "REMOVE ADS", customButtonStyle))
                    {
                        displayRemoveAds = true;
                        displayMainMenu  = false;
                    }
                }
            }
        }


        //EXTRA LIVES
        if (displayExtraLives)
        {
            GUI.DrawTextureWithTexCoords(rRect(0f, 0f, 1f, 1f), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(rRect(0.2f, 0.1f, 0.6f, 0.1f), gamelogo);


            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "BUY EXTRA LIVES", customHighlightStyle);
                GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "Survive longer each game by buying extra life options. You can buy an extra 3 or a whopping 10 extra lives!", customPaddedStyle);

                if (GUI.Button(rRect(0.125f, 0.6f, 0.375f, 0.05f), "3 EXTRA LIVES", customHighlightStyle))
                {
                    BuyExtraLives();
                }

                if (GUI.Button(rRect(0.5f, 0.6f, 0.375f, 0.05f), "RESTORE", customHighlightStyle))
                {
                    RestoreButtonPressed();
                }

                if (GUI.Button(rRect(0.125f, 0.65f, 0.375f, 0.05f), "10 EXTRA LIVES", customHighlightStyle))
                {
                    Buy10ExtraLives();
                }

                if (GUI.Button(rRect(0.5f, 0.65f, 0.375f, 0.05f), "CANCEL", customHighlightStyle))
                {
                    CancelButtonPressed();
                }
            }
        }


        //GAME OVER
        if (displayGameOver)
        {
            gameOver = true;

            if (showAds && AdBinding.isInterstitalLoaded())
            {
                AdBinding.destroyAdBanner();
                AdBinding.showInterstitial();
            }

            GUI.DrawTextureWithTexCoords(rRect(0f, 0f, 1f, 1f), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(rRect(0.2f, 0.1f, 0.6f, 0.1f), gamelogo);

            GUI.Label(rRect(0.3f, 0.25f, 0.4f, 0.05f), "GAME OVER", customHighlightStyle);
            GUI.Label(rRect(0.3f, 0.3f, 0.4f, 0.05f), "SCORE", customButtonStyle);
            GUI.Label(rRect(0.3f, 0.35f, 0.4f, 0.05f), ((int)Camera.main.GetComponent <beeGUI>().score).ToString(), customButtonStyle);
            GUI.Label(rRect(0.3f, 0.4f, 0.4f, 0.05f), "HIGH", customButtonStyle);
            GUI.Label(rRect(0.3f, 0.45f, 0.4f, 0.05f), EncryptedPlayerPrefs.GetInt("highScoore").ToString(), customButtonStyle);

            if (GUI.Button(rRect(0.3f, 0.52f, 0.4f, 0.05f), "RATE", customHighlightStyle))
            {
                Application.OpenURL("itms-apps://itunes.apple.com/app/id875911453");
            }

            if (GUI.Button(rRect(0.3f, 0.59f, 0.4f, 0.05f), "LEADERBOARD", customHighlightStyle))
            {
                if (GameCenterBinding.isPlayerAuthenticated())
                {
                    if (_hasLeaderboardData)
                    {
                        GameCenterBinding.showGameCenterViewController(GameCenterViewControllerState.Leaderboards);
                    }
                }
                else
                {
                    GameCenterBinding.authenticateLocalPlayer();
                    GameCenterBinding.loadLeaderboardTitles();
                }
            }

            float yoffset = 0f;

            if (EncryptedPlayerPrefs.GetInt("10xtralives") != 1)
            {
                if (GUI.Button(rRect(0.3f, 0.66f, 0.4f, 0.05f), "EXTRA LIVES", customHighlightStyle))
                {
                    displayExtraLives = true;
                    displayGameOver   = false;
                }
            }
            else
            {
                yoffset -= 0.07f;
            }

            if (showAds == true)
            {
                if (GUI.Button(rRect(0.3f, 0.73f + yoffset, 0.4f, 0.05f), "REMOVE ADS", customHighlightStyle))
                {
                    displayRemoveAds = true;
                    displayGameOver  = false;
                }
            }
            else
            {
                yoffset -= 0.07f;
            }

            if (GUI.Button(rRect(0.3f, 0.80f + yoffset, 0.4f, 0.05f), "TRY AGAIN", customHighlightStyle))
            {
                displayMainMenu = false;
                displayGameOver = false;
                Camera.main.GetComponent <beeGUI>().dispMenu = true;
                Time.timeScale = 1;
                if (showAds)
                {
                    AdBinding.createAdBanner(true);
                    AdBinding.initializeInterstitial();
                }
                Application.LoadLevel("game");
            }
        }


        //REMOVE ADS PURCHASE
        if (displayRemoveAds)
        {
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);


            if (EncryptedPlayerPrefs.GetInt("removeadverts") != 1)
            {
                GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "REMOVE ADVERTS", customHighlightStyle);
                GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "Have and advert-free experience by purchasing the option below. Then experience uninterrupted gameplay!", customPaddedStyle);


                if (GUI.Button(rRect(0.125f, 0.6f, 0.25f, 0.05f), "NO ADS!", customHighlightStyle))
                {
                    BuyRemoveAds();
                }

                if (GUI.Button(rRect(0.375f, 0.6f, 0.25f, 0.05f), "RESTORE", customHighlightStyle))
                {
                    RestoreButtonPressed();
                }

                if (GUI.Button(rRect(0.625f, 0.6f, 0.25f, 0.05f), "CANCEL", customHighlightStyle))
                {
                    CancelButtonPressed();
                }
            }
        }


        //PROBLEM WITH IN-APP PURCHASE
        if (displayProblem)
        {
            GUI.DrawTextureWithTexCoords(new Rect(0f, 0f, sW, sH), mainMenuBackground, new Rect(0f, 0f, 5f, 5f));
            GUI.DrawTexture(new Rect(sW * 0.2f, sH * 0.1f, sW * 0.6f, sH * 0.1f), gamelogo);

            GUI.Label(rRect(0.25f, 0.3f, 0.5f, 0.05f), "PROBLEM", customHighlightStyle);
            GUI.Label(rRect(0.125f, 0.35f, 0.75f, 0.25f), "There appears to be a problem in doing that action. Please can you try again later?", customPaddedStyle);


            if (GUI.Button(rRect(0.375f, 0.6f, 0.25f, 0.05f), "HOME", customHighlightStyle))
            {
                if (gameOver)
                {
                    displayGameOver = true;
                }
                else
                {
                    displayMainMenu = true;
                }
                displayProblem = false;
            }
        }
    }
    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");
        }
    }
Пример #4
0
 // iOS 6+ only! Shows a specific Game Center view controller. timeScope and leaderboardId are only valid for GameCenterViewControllerState.Leaderboards
 public void ShowGameCenterViewController(GameCenterViewControllerState viewState)
 {
     GameCenterBinding.showGameCenterViewController(viewState);
 }
Пример #5
0
 public void ShowGameCenterViewController(GameCenterViewControllerState viewState, GameCenterLeaderboardTimeScope timeScope, string leaderboardId)
 {
     GameCenterBinding.showGameCenterViewController(viewState, timeScope, leaderboardId);
 }