public void FinishLevel(LevelEnum level, int score = 100, bool doSave = true) { Level lvl = this.levels [level]; if (lvl.score < score) { lvl.score = score; } this.playerData.setScore(level, score); // Update Google Play Games Leaderboard if (doSave) { int totalScore = GetTotalScore(); PlayGamesScript.AddScoreToLeaderboard(Config.LEADERBOARD_OVERALL_SCORE, totalScore); } // If level is a story, unlock the next world if (lvl.isStory) { UnlockWorld(this.levels [lvl.nextLevel].world.id); } if (doSave) { Save(); } }
IEnumerator DestroyRope() { SpriteRenderer[] sprites = rope.GetComponentsInChildren <SpriteRenderer> (); Color newColor; for (float t = 0.0f; t <= 1.0f; t += Time.deltaTime / 1f) { foreach (SpriteRenderer sprite in sprites) { newColor = sprite.color; newColor.a = Mathf.Lerp(1, 0, t); sprite.color = newColor; } yield return(null); } Destroy(rope.gameObject); yield return(new WaitForSeconds(1f)); guic.DisplayDialog(DialogEnum.rat_thanks_cat); yield return(new WaitForSeconds(.5f)); RatFlip(); rat.GetComponent <Rigidbody2D> ().isKinematic = true; ratLiberated = true; // Achievement "free Croc" PlayGamesScript.UnlockAchievement(Config.IM_FREE); }
// Use this for initialization void Start() { motor = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMotor> (); sm = GameObject.FindGameObjectWithTag("SM").GetComponent <SpawnManager> (); am = GameObject.FindGameObjectWithTag("AM").GetComponent <AudioManager> (); pg = GameObject.FindGameObjectWithTag("PG").GetComponent <PlayGamesScript> (); highScoreText.text = PlayerPrefs.GetInt("score").ToString(); highScore = PlayerPrefs.GetInt("score"); if (am.reloadScore == false) { tempScore = highScore; } else if (am.reloadScore == true) { tempScore = am.tempScore; motor.buttonEnabled = false; Time.timeScale = 0.5f; StartCoroutine(endSlomo(0.5f)); } if (highScore == 0) { tempScore = 1; } currentAmount = startingAmount; }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { // A consumable product has been purchased by this user. if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_9999_PAW, StringComparison.Ordinal)) { // The consumable item has been successfully purchased, add 100 coins to the player's in-game score. CoinsManager.Coins += 14999; CoinsManager.instance.IncrementBy14999(); PlayGamesScript.UnlockAchievement(PGPS.achievement_bling_bling); } // Or ... a non-consumable product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_14999_PAW, StringComparison.Ordinal)) { CoinsManager.Coins += 19999; CoinsManager.instance.IncrementBy19999(); PlayGamesScript.UnlockAchievement(PGPS.achievement_bling_bling_vol_2); } // Or ... a subscription product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, PRODUCT_NO_ADS, StringComparison.Ordinal)) { Debug.Log("No ads"); } // Or ... an unknown product has been purchased by this user. Fill in additional products here.... else { Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); } // Return a flag indicating whether this product has completely been received, or if the application needs // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still // saving purchased products to the cloud, and when that save is delayed. return(PurchaseProcessingResult.Complete); }
void Start() { Instance = this; if (!PlayerPrefs.HasKey(SAVE_NAME)) { PlayerPrefs.SetString(SAVE_NAME, string.Empty); } if (!PlayerPrefs.HasKey("IsFirstTime")) { PlayerPrefs.SetInt("IsFirstTime", 1); } if (PlayerPrefs.GetInt("IsFirstTime") == 1) { PlayerPrefs.SetInt("IsFirstTime", 0); CloudVariables.SetImportantValues(0, 1); CloudVariables.SetImportantValues(1, 0); } LoadLocal(); PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().EnableSavedGames().Build(); PlayGamesPlatform.InitializeInstance(config); PlayGamesPlatform.Activate(); SignIn(); }
// Called when opening the help panel to check if we need to track the "Nosy" achievement public void TrackHelpAchievement() { if (PlayGamesScript.IsAchievementUnlocked(Config.NOSY) == 0) { trackHelpAchievement = true; } }
public void IncrementAchievementOne() { PlayGamesScript.IncrementAchievement(GPGSIds.achievement_power_master, 1); scoreIncrementGo.SetActive(true); power.Play(); StartCoroutine(DisableBonusOne(1f)); }
public void OnDestroy() { PlayerPrefs.SetInt("finalScore", score); PlayerPrefs.SetInt("currentRank", gemIcon.GetRank()); //First time playing if (!PlayerPrefs.HasKey("highestScore")) { PlayerPrefs.SetInt("highestScore", score); PlayGamesScript.AddScoreToLeaderboard(Scoreboard.leaderboard_maiores_scores, score); PlayerPrefs.SetInt("highestRank", gemIcon.GetRank()); //Set rank first time } if (PlayerPrefs.HasKey("highestScore") && score > PlayerPrefs.GetInt("highestScore")) { PlayerPrefs.SetInt("highestScore", score); PlayGamesScript.AddScoreToLeaderboard(Scoreboard.leaderboard_maiores_scores, score); } if (PlayerPrefs.HasKey("highestRank") && gemIcon.GetRank() > PlayerPrefs.GetInt("highestRank")) { PlayerPrefs.SetInt("highestRank", gemIcon.GetRank()); } }
IEnumerator ActivateHalo() { yield return(new WaitForSeconds(2f)); TT1Halo.SetActive(true); TT2Halo.SetActive(true); DeathScoreText.text = ScoreText.text; DeathPanel.GetComponent <Image>().CrossFadeAlpha(0f, 0f, true); Score.SetActive(false); DeathPanel.SetActive(true); DeathPanel.GetComponent <Image>().CrossFadeAlpha(0.8f, 0.15f, true); if (PlayerPrefs.GetInt("Invited") == 1) { StartCoroutine(DoublifyScore()); } else { if (PlayerPrefs.GetInt("Score") < GameController.GetComponent <GameControl>().score) { PlayerPrefs.SetInt("Score", GameController.GetComponent <GameControl>().score); PlayGamesScript.AddScoreToLeaderboard(GPGSIds.leaderboard_leaderboard, GameController.GetComponent <GameControl>().score); HighScore.SetActive(true); } } }
public void OnEndDrag(PointerEventData ped) { if (overButton) { nowOver.GetComponent <RectTransform>().sizeDelta = new Vector2(zoomed_button.x / zoomValue, zoomed_button.y / zoomValue); if (nowOver.name == "Play") { nowOver.GetComponent <RectTransform>().anchoredPosition = new Vector2(200f, 0); Camera.main.GetComponent <CameraScript>().Right = true; manager.StartGame(); } if (nowOver.name == "Custom") { nowOver.GetComponent <RectTransform>().anchoredPosition = new Vector2(-200f, 0); Camera.main.GetComponent <CameraScript>().Left = true; } if (nowOver.name == "Leaderboard") { PlayGamesScript.ShowLeaderBoard(); nowOver.GetComponent <RectTransform>().anchoredPosition = new Vector2(0, -200f); } GameManager.PlaySound(manager.GetComponent <AudioSource>(), 0f); } dragging = false; }
/// <summary> /// A method to handle checking for "Finish All Levels with 3 Stars" Achievement /// </summary> private void CheckThreeStarAchievement() { if (GameData.Instance.saveData.ThreeStarLevels >= 60) { PlayGamesScript.UnlockAchievement("CgkIscHpwIUZEAIQEQ"); } }
private void OnInedibleItemPickup() { GlobalData.Lives--; if (GlobalData.Lives < 0) { if (PlayGamesScript.SuccessAuth) { PlayGamesScript.AddScoreToLeaderboard(GPGSIds.leaderboard_score, GlobalData.Score); } else { PlayGamesScript.Auth(); } //AdRequest if (!m_AdWasShown) { m_AdPopup.Open(); OnPause(); } else { LevelChanger.FadeToLevel(GameLevels.THE_END); } } else { m_TextLives.text = $"Lives: {GlobalData.Lives}"; } }
void GameOver() { GetComponent <Rigidbody2D>().drag = 9999; // Makes the ball unable to move GetComponent <Rigidbody2D>().isKinematic = true; PlayerPrefs.SetInt("Score", score); if (score > bestScore) { PlayerPrefs.SetInt("Best Score", score); } if (!usedRevived && credits > 25) { StartCoroutine(ReviveTimer(0f, 5f)); } gameOverMenu.SetActive(true); gameOverMenu.GetComponent <GameOverScript>().StartGameOverSequence(); Button pauseButton = GameObject.Find("PauseButton").GetComponent <Button>(); pauseButton.interactable = false; #if !UNITY_EDITOR PlayGamesScript.AddScordToLeaderboard(GPGSIds.leaderboard_leaderboard_for_golf_pads, score); #endif }
// Update is called once per frame void Update() { number = Jumper.position.y; scoreText2D.text = number.ToString("0"); if (number > 200) { PlayGamesScript.UnlockAchievement(PGPS.achievement_get_a_high_score_of_200_in_coins_mode); } if (number > 500) { PlayGamesScript.UnlockAchievement(PGPS.achievement_500_in_coins_mode); } if (number > 1000) { PlayGamesScript.UnlockAchievement(PGPS.achievement_1000_in_coins_mode); } if (number > PlayerPrefs.GetFloat("HighScore", 0)) { PlayGamesScript.AddScoreToLeaderboard(PGPS.leaderboard_jumping_leaderboard, (long)number); PlayerPrefs.SetFloat("HighScore", number); highScore.text = number.ToString("0"); PlayGamesScript.instance.SaveData(); } }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { // A consumable product has been purchased by this user. if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // The consumable item has been successfully purchased, add 100 coins to the player's in-game score. //ScoreManager.score += 100; ApplicationController.ac.playerData.updateKittys(500, kittyzText, true); // Achievement PlayGamesScript.UnlockAchievement(Config.ANIMAL_CAUSE); } // Or ... a non-consumable product has been purchased by this user. /* else if (String.Equals (args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal)) { * Debug.Log (string.Format ("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); * // TODO: The non-consumable item has been successfully purchased, grant this item to the player. * } * // Or ... a subscription product has been purchased by this user. * else if (String.Equals (args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal)) { * Debug.Log (string.Format ("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); * // TODO: The subscription item has been successfully purchased, grant this to the player. * }*/ // Or ... an unknown product has been purchased by this user. Fill in additional products here.... else { Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); } // Return a flag indicating whether this product has completely been received, or if the application needs // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still // saving purchased products to the cloud, and when that save is delayed. return(PurchaseProcessingResult.Complete); }
//public Text authStatus; // Use this for initialization void Start() { Instance = this; //setting default value, if the game is played for the first time if (!PlayerPrefs.HasKey(SAVE_NAME)) { PlayerPrefs.SetString(SAVE_NAME, string.Empty); } //tells us if it's the first time that this game has been launched after install - 0 = no, 1 = yes if (!PlayerPrefs.HasKey("IsFirstTime")) { PlayerPrefs.SetInt("IsFirstTime", 1); } //LoadLocal(); //we want to load local data first because loading from cloud can take quite a while, if user progresses while using local data, it will all //sync in our comparating loop in StringToGameData(string, string) PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() .EnableSavedGames().Build(); // Enable debugging output (recommended) PlayGamesPlatform.DebugLogEnabled = true; PlayGamesPlatform.InitializeInstance(config); PlayGamesPlatform.Activate(); SignIn(); }
public void OpenScene(int index) { if (index == 1) { PlayGamesScript.UnlockAchievement(GPGSIds.achievement_welcome); } SceneManager.LoadScene(index); }
private void OnTriggerEnter() { PlayGamesScript.UnlockAchievement(PGPS.achievement_complete_level_9); CoinsManager.Coins += 60; CoinsManager.instance.IncrementBySixty(); PlayerPrefs.SetInt("coins", CoinsManager.Coins); PlayerPrefs.Save(); }
public void EndGame() { FindObjectOfType <ScoreText>().Game = false; PlayGamesScript.AddScoreToLeaderboard(GPGSIds.leaderboard_best_players, FindObjectOfType <ScoreText>().score); AdScript.instance.ShowFullscreenAd(); changer.ChangeBoxToBlack(); StartCoroutine(RestartLevel()); }
void Start() { PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().Build(); PlayGamesPlatform.InitializeInstance(config); //PlayGamesPlatform.DebugLogEnabled = true; PlayGamesPlatform.Activate(); PlayGamesScript.SignIn(); }
//public GameObject disconnectedMenu; // Use this for initialization public void Awake() { instance = this; PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder() .EnableSavedGames().Build(); PlayGamesPlatform.InitializeInstance(config); PlayGamesPlatform.Activate(); }
void Awake() { Messenger.AddListener(GameEvent.SKEWER_OVERFLOW, OnSkewerOverflow); Messenger.AddListener(GameEvent.INEDIBLE_ITEM_PICKUP, OnInedibleItemPickup); Messenger.AddListener(GameEvent.AD_REQUEST, RequestRewardBasedVideo); Messenger.AddListener(GameEvent.SPEED_CHANGE, SpeedChange); PlayGamesScript.GetUserMaxScore(); }
private void OnTriggerEnter() { PlayGamesScript.UnlockAchievement(PGPS.achievement_complete_level_1); CoinsManager.Coins += 5; CoinsManager.instance.IncrementByFive(); Debug.Log("+5 coins"); PlayerPrefs.SetInt("coins", CoinsManager.Coins); PlayerPrefs.Save(); }
public void CollectKittyz(int amount = 1) { kittyzCollected += amount; ApplicationController.ac.playerData.updateKittys(1); PlayGamesScript.IncrementAchievement(Config.KITTYZ_RUSH_10, amount); PlayGamesScript.IncrementAchievement(Config.KITTYZ_RUSH_100, amount); PlayGamesScript.IncrementAchievement(Config.KITTYZ_RUSH_500, amount); PlayGamesScript.IncrementAchievement(Config.KITTYZ_RUSH_1000, amount); }
public void IncrementAchievementTwo() { PlayGamesScript.IncrementAchievement(GPGSIds.achievement_perfect_master, 1); scoreIncrementGo2.SetActive(true); Time.timeScale = 0.5f; Time.fixedDeltaTime = 0.02f * Time.timeScale; perfect.Play(); xMark--; StartCoroutine(DisableBonusTwo(0.5f)); }
// Use this for initialization void Start() { am = GameObject.FindGameObjectWithTag("AM").GetComponent <AudioManager> (); pg = GameObject.FindGameObjectWithTag("PG").GetComponent <PlayGamesScript> (); if (am.askedOnce == false) { pg.ToActivate(); } }
public void Win() { pauseButton.interactable = false; soundEffector.PlayWinSound(); Time.timeScale = 0f; player.enabled = false; winScreen.SetActive(true); if (!PlayerPrefs.HasKey(Level) || PlayerPrefs.GetInt(Level) < levelNumber) { if (levelNumber == 1) { PlayGamesScript.UnlockAchievement(GPGSIds.achievement_first_step); } if (levelNumber == 10) { PlayGamesScript.UnlockAchievement(GPGSIds.achievement_runner); } PlayerPrefs.SetInt(Level, SceneManager.GetActiveScene().buildIndex); } if (GetComponent <Inventory>().AreAllGemsCollected()) { bonusPanel.SetActive(true); bonusReward = 500; PlayGamesScript.UnlockAchievement(GPGSIds.achievement_collector); } if (PlayerPrefs.HasKey(Coins)) { PlayerPrefs.SetInt(Coins, PlayerPrefs.GetInt(Coins) + player.GetCoins() + bonusReward); } else { PlayerPrefs.SetInt(Coins, player.GetCoins() + bonusReward); } GetComponent <Inventory>().RecountItems(); if (AchievementHelper.AreAllGemsCollected()) { PlayGamesScript.UnlockAchievement(GPGSIds.achievement_explorer); } if (PlayerPrefs.HasKey(Constants.Timer + levelNumber)) { var bestTime = PlayerPrefs.GetFloat(Constants.Timer + levelNumber); if (bestTime > timer) { SetRecordAndCheckAchievements(); } } else { SetRecordAndCheckAchievements(); } }
public void ShowAchievements() { if (am.isSignedIn == true) { PlayGamesScript.ShowAchievementsUI(); } else { pg.ToActivate(); } }
public void ShowLeaderboards() { if (am.isSignedIn == true) { PlayGamesScript.ShowLeaderboardsUI(); } else { pg.ToActivate(); } }
void SaveHighScore() { PlayerPrefs.SetInt("Most Chicken", highScore.highestChicken); PlayerPrefs.SetInt("Most Penguin", highScore.highestPenguin); #if UNITY_ANDROID PlayGamesScript.AddScoreToLeaderboard(GPGSIds.leaderboard_chicky_master, highScore.highestChicken); PlayGamesScript.AddScoreToLeaderboard(GPGSIds.leaderboard_pengi_master, highScore.highestPenguin); #endif GameDataManager.instance.SaveGame(); }