public void StartLeaderboard(bool autoStart = false) { if (!Network.IsInternetConnection() && !autoStart) { Core.Utility.Popup.PopupMessages.Me.InternetConnectionMessgae(); return; } #if UNITY_IOS && GAMECENTER if (!GameCenterBinding.isPlayerAuthenticated()) { GameCenterBinding.authenticateLocalPlayer(); } #endif #if UNITY_ANDROID #if GPGSERVIES && !AMAZONSTORE GPGManager.authenticationFailedEvent += (string error) => { MyDebug.Log("Prime[31] Google Play service authenticate fail with error:\n" + error); }; GPGManager.authenticationSucceededEvent += (string data) => { MyDebug.Log("Prime[31] Google Play service authenticate compelete with data:\n" + data); }; if (!PlayGameServices.isSignedIn()) { #if MYDEBUG PlayGameServices.enableDebugLog(true); #endif PlayGameServices.authenticate(); } #endif #endif }
public static void TryAuthentication(bool forceMode = false) { if (instanceExists && instance.debugMode) { Debug.LogFormat("PlayGameCenterManager:TryAuthentication({0}) - isAuthenticated={1}, isLastAuthenticationFailed={2}", forceMode, isAuthenticated, isLastAuthenticationFailed); } if (IsSingedIn()) // If already logined, skip here { return; } if (isLastAuthenticationFailed && !forceMode) // If last login failed, don't do it again (unless in forceMode) { return; } _isForcingAuthentication = forceMode; #if UNITY_IOS GameCenterBinding.authenticateLocalPlayer(forceMode); // Authenticate the player #elif UNITY_ANDROID && !CHS if (forceMode) { PlayGameServices.authenticate(); // Authenticate with UI } else { PlayGameServices.attemptSilentAuthentication(); // Authenticate Silently (with no UI) } #endif }
void Start() { // use anonymous delegates for this simple example for gathering data from GameCenter. In production you would want to // add and remove your event listeners in OnEnable/OnDisable! GameCenterManager.categoriesLoaded += delegate(List <GameCenterLeaderboard> leaderboards) { _leaderboards = leaderboards; _hasLeaderboardData = _leaderboards != null && _leaderboards.Count > 0; }; GameCenterManager.achievementMetadataLoaded += delegate(List <GameCenterAchievementMetadata> achievementMetadata) { _achievementMetadata = achievementMetadata; _hasAchievementData = _achievementMetadata != null && _achievementMetadata.Count > 0; }; // after authenticating grab the players profile image GameCenterManager.playerAuthenticated += () => { GameCenterBinding.loadProfilePhotoForLocalPlayer(); loadFriends(); }; // always authenticate at every launch GameCenterBinding.authenticateLocalPlayer(); }
// Authenticates the player. This needs to be called before using anything in GameCenter and should // preferalbly be called shortly after application launch. public void AuthenticatePlayer() { //Debug.Log ("GameCenter::AuthenticatePlayer"); if (!IsPlayerAuthenticated()) { GameCenterBinding.authenticateLocalPlayer(); } }
void Start() { if (Instance == null) { Instance = this; } displayMainMenu = false; displayGameOver = false; displayMainMenuPaused = false; sW = Screen.width; sH = Screen.height; buttonWidth = sW * 0.6f; buttonHeight = sH / 20.0f; storeKitController = GetComponent <StoreKitController>(); // always authenticate at every launch GameCenterBinding.authenticateLocalPlayer(); GameCenterBinding.loadLeaderboardTitles(); //Get in-app purchase product data storeKitController.RequestProductData(); showAds = true; int Ads = EncryptedPlayerPrefs.GetInt("removeadverts"); if (Ads == 1) { if (EncryptedPlayerPrefs.CheckEncryption("removeadverts", "int", "1")) { showAds = false; } } else { //start loading ad AdBinding.initializeInterstitial(); //start iAd AdBinding.createAdBanner(true); } // hack to detect iPad 3 until Unity adds official support this.isPad = (Screen.width >= 1536 || Screen.height >= 1536); if (isPad) { customButtonStyle.fontSize = 64; customHighlightStyle.fontSize = 64; customPaddedStyle.fontSize = 64; } //keep this object in memory DontDestroyOnLoad(transform.gameObject); }
public void Login() { #if UNITY_IPHONE && API_SCORE_GAMECENTER if (!GameCenterBinding.isPlayerAuthenticated()) { ZedLogger.Log("trying to authenticate local player"); GameCenterBinding.authenticateLocalPlayer(false); GameCenterBinding.showCompletionBannerForAchievements(); } #endif }
// Tenta autenticar o usuario com a Apple e instancia a Prefab GameCenterManager (caso necessario) public static void AuthenticateUser() { Setup(); if (!GameCenterAvailable() || UserIsAuthenticated()) { return; } #if UNITY_IPHONE GameCenterBinding.authenticateLocalPlayer(); #endif }
//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(); }
void ReportAchievement(string achievementID) { #if UNITY_IOS && GAMECENTER if (!GameCenterBinding.isPlayerAuthenticated()) { GameCenterBinding.authenticateLocalPlayer(); } GameCenterBinding.reportAchievement(achievementID, 100f); GameCenterBinding.showCompletionBannerForAchievements(); #endif #if UNITY_ANDROID #if GPGSERVIES && !AMAZONSTORE PlayGameServices.unlockAchievement(achievementID, true); #endif #endif }
public override void Init() { PRODUCT_IDENTIFIERS[0] = GOLD_200; PRODUCT_IDENTIFIERS[1] = GOLD_500; PRODUCT_IDENTIFIERS[2] = GOLD_4000; Application.targetFrameRate = 45; GameObject gcm; GameObject skm; GameObject etcm; GameObject etcl; GameObject cbm; if (GameObject.Find("GameCenterManager") == null && GameObject.Find("GameCenterManager(Clone)") == null) { gcm = (GameObject)Instantiate(Resources.Load(PRIME31_DIRECTORY + "GameCenterManager")); } if (GameObject.Find("StoreKitManager") == null && GameObject.Find("StoreKitManager(Clone)") == null) { skm = (GameObject)Instantiate(Resources.Load(PRIME31_DIRECTORY + "StoreKitManager")); } if (GameObject.Find("EtceteraManager") == null && GameObject.Find("EtceteraManager(Clone)") == null) { etcm = (GameObject)Instantiate(Resources.Load(PRIME31_DIRECTORY + "EtceteraManager")); } if (GameObject.Find("EtceteraEventListener") == null && GameObject.Find("EtceteraEventListener(Clone)") == null) { etcl = (GameObject)Instantiate(Resources.Load(PRIME31_DIRECTORY + "EtceteraEventListener")); } if (GameObject.Find("ChartBoostManager") == null && GameObject.Find("ChartBoostManager(Clone)") == null) { cbm = (GameObject)Instantiate(Resources.Load(PRIME31_DIRECTORY + "ChartBoostManager")); } #if UNITY_IPHONE ChartBoostBinding.init(CHARTBOOST_APPID, CHARTBOOST_SIGNATURE); StoreKitBinding.requestProductData(PRODUCT_IDENTIFIERS); if (GameCenterBinding.isGameCenterAvailable()) { GameCenterBinding.authenticateLocalPlayer(); } #endif }
void Start() { // always authenticate at every launch GameCenterBinding.authenticateLocalPlayer(); // listen for when the match data gets loaded GameCenterTurnBasedManager.loadMatchDataEvent += (bytes) => { _matchDataString = System.Text.UTF8Encoding.UTF8.GetString(bytes); textLabel.text = "match data: " + _matchDataString; }; GameCenterManager.playerAuthenticated += () => { Debug.Log("local player authenticated"); }; GameCenterTurnBasedManager.turnBasedMatchmakerViewControllerDidFindMatchEvent += currentMatchChanged; GameCenterTurnBasedManager.handleTurnEventEvent += currentMatchChanged; GameCenterTurnBasedManager.handleMatchEndedEvent += currentMatchChanged; }
//============================================================================= public void Login() { #if UNITY_IPHONE if ((IsLoggedIn() == false) && (m_ManagerState == eManagerState.Idle)) { GameCenterBinding.authenticateLocalPlayer(); m_ManagerState = eManagerState.Login; } else { if (LoginFailEvent != null) { LoginFailEvent("Error - Already logged in or manager busy"); } } #endif #if UNITY_ANDROID if ((IsLoggedIn() == false) && (m_ManagerState == eManagerState.Idle)) { if (PlayerPrefs.GetInt("GCGPAutoLogin", 0) > 0) { PlayGameServices.attemptSilentAuthentication(); } else { PlayGameServices.authenticate(); } m_ManagerState = eManagerState.Login; } else { if (LoginFailEvent != null) { LoginFailEvent("Error - Already logged in or manager busy"); } } #endif }
// Use this for initialization void Start() { return; #if UNITY_ANDROID if (UserPrefs.isAmazonBuild) { bool isServiceReady = AGSClient.IsServiceReady(); if (!isServiceReady) { AGSClient.ServiceReadyEvent += serviceReadyHandler; AGSClient.ServiceNotReadyEvent += serviceNotReadyHandler; AGSClient.Init(true, true, false); //usesLeaderboards, usesAchievements, usesWhispersync } } #endif #if UNITY_IPHONE GameCenterBinding.authenticateLocalPlayer(); #endif }
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() { //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; } } }
public void Authenticate() { GameCenterBinding.authenticateLocalPlayer(); }