public static void GetLeaderboardRank(string leaderboardId) { int rank = 0; int oldRank = PlayerPrefs.GetInt(leaderboardId, 0); PlayGamesPlatform.Instance.LoadScores( leaderboardId, LeaderboardStart.PlayerCentered, 1, LeaderboardCollection.Public, LeaderboardTimeSpan.AllTime, (LeaderboardScoreData data) => { rank = data.PlayerScore.rank; switch (rank) { case 1: GooglePlayActions.UnlockAchievement(GooglePlayActions.doingSomethingAchiev); break; case 2: GooglePlayActions.UnlockAchievement(GooglePlayActions.bitNotEnoughAchiev); break; case 3: GooglePlayActions.UnlockAchievement(GooglePlayActions.prettyGoodAchiev); break; } if (oldRank - rank >= 99) { GooglePlayActions.UnlockAchievement(GooglePlayActions.climberAchiev); } PlayerPrefs.SetInt(leaderboardId, rank); }); }
private void SavePhoto() { string _path = Application.persistentDataPath; //const string _path = "/storage/emulated/0/DCIM/bubbles_gallery"; //string _path = "/Users/ligross/Projects/Unity/bubbles_gallery"; Directory.CreateDirectory(_path); File.WriteAllBytes(_path + string.Format("/{0}.png", DateTime.Now.ToString("yyyyMMddHHmmss")), _bytes); //ачивка за первое фото switch (Directory.GetFiles(_path, "*.png").Length) { case 1: GooglePlayActions.UnlockAchievement(GooglePlayActions.narcissistAchiev); PlayerPrefs.SetInt("PinkFrame", 1); break; case 5: GooglePlayActions.UnlockAchievement(GooglePlayActions.discordantAchiev); break; case 8: GooglePlayActions.UnlockAchievement(GooglePlayActions.tetractisAchiev); break; } }
public static void UpdatePrefs(string prefName, int value) { int updatedValue = PlayerPrefs.GetInt(prefName, 0) + value; PlayerPrefs.SetInt(prefName, updatedValue); switch (updatedValue) { case 10: GooglePlayActions.UnlockAchievement(GooglePlayActions.beginnerAdsAchiev); PlayerPrefs.SetInt("MetallFrame", 1); break; case 20: GooglePlayActions.UnlockAchievement(GooglePlayActions.intermAdsAchiev); PlayerPrefs.SetInt("RainbowFrame", 1); break; case 30: GooglePlayActions.UnlockAchievement(GooglePlayActions.advancedAdsAchiev); PlayerPrefs.SetInt("GotFrame", 1); break; case 40: GooglePlayActions.UnlockAchievement(GooglePlayActions.superAdvancedAdsAchiev); PlayerPrefs.SetInt("GotFrame", 1); break; case 50: GooglePlayActions.UnlockAchievement(GooglePlayActions.mindBlowingAdsAchiev); PlayerPrefs.SetInt("GotFrame", 1); break; } }
public void OnClick() { //this.GetComponent<GameObject>().SetActive(true); helpBackground.Show(false); helpBody.Show(false); if (!PlayerPrefs.HasKey("HelpSeen")) { GooglePlayActions.UnlockAchievement(GooglePlayActions.goodPupilAchiev); PlayerPrefs.SetInt("HelpSeen", 1); } }
public void BurstBadBubble(GameObject obj) { Destroy(obj.GetComponent <Animator>()); obj.GetComponent <SpriteRenderer> ().sprite = badBubblesSprites[badBubblesSprites.Length - 1]; if (!bool.Parse(PlayerPrefs.GetString("isSoundOff", "false"))) { obj.GetComponent <AudioSource>().clip = badBubbleSounds[UnityEngine.Random.Range(0, 2)]; obj.GetComponent <AudioSource>().Play(); } Destroy(obj.GetComponent <EventTrigger>()); _timeLastFail = startTime; _badBubblesBurst += 1; if (_badBubblesBurst == 1 && !PlayerPrefs.HasKey("FirstBadBubble")) { PlayerPrefs.SetString("FirstBadBubble", "false"); GooglePlayActions.UnlockAchievement(GooglePlayActions.scrapThisAchiev); } }
public void MouseDown() { GameManager.Instance.SetCarma(-5); #if UNITY_EDITOR if (Time.timeScale != 0 && EventSystem.current.IsPointerOverGameObject() && GameManager.Instance.started) { if (!GetComponent <RandomFlying> ().enabled) { GameManager.Instance.FrightenFly(gameObject); } else { this.GetComponent <Animator> ().SetTrigger("Clicked"); } } #elif UNITY_ANDROID if (Time.timeScale != 0 && EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId) && GameManager.Instance.started) { if (!GetComponent <RandomFlying> ().enabled) { GameManager.Instance.FrightenFly(gameObject); } else { this.GetComponent <Animator> ().SetTrigger("Clicked"); } } #endif _touchesCount += 1; //разблокировать мухобойку if (_touchesCount >= 5) { GooglePlayActions.UnlockAchievement(GooglePlayActions.flySwatAchiev); } }
public void FrightenFly(GameObject obj) { if (starting) { return; } _timeLastFail = startTime; _fliesCount += 1; if (!bool.Parse(PlayerPrefs.GetString("isSoundOff", "false"))) { obj.GetComponent <AudioSource>().clip = flySound; obj.GetComponent <AudioSource>().Play(); } // разблокирование достижений на количество мух switch (_fliesCount) { case 13: GooglePlayActions.UnlockAchievement(GooglePlayActions.lordAchiev); break; case 21: GooglePlayActions.UnlockAchievement(GooglePlayActions.flyBaronAchiev); break; case 34: GooglePlayActions.UnlockAchievement(GooglePlayActions.flyOnTheWallAchiev); break; } obj.GetComponent <Animator> ().SetTrigger("Clicked"); obj.GetComponent <RandomFlying> ().enabled = true; if (_fliesCount == 1 && !PlayerPrefs.HasKey("FirstFly")) { PlayerPrefs.SetString("FirstFly", "false"); GooglePlayActions.UnlockAchievement(GooglePlayActions.soLovelyAchiev); } }
public void BurstGoodBubble(GameObject obj, Sprite[] burstSprites = null) { //set on of the "bursted" sprites to good bubble if (starting) { return; } if (burstSprites == null) { int spriteNumber = UnityEngine.Random.Range(0, goodBubblesSprites.Length); obj.GetComponent <SpriteRenderer>().sprite = goodBubblesSprites[spriteNumber]; if (spriteNumber == 0) { _vangaCookiesBursted += 1; //Debug.Log(_vangaCookiesBursted); } if (_vangaCookiesBursted == 12) { GooglePlayActions.UnlockAchievement(GooglePlayActions.vangaCookiesAchiev); } } else { obj.GetComponent <SpriteRenderer>().sprite = burstSprites[UnityEngine.Random.Range(0, burstSprites.Length)]; } //obj.GetComponent<SpriteRenderer> ().sprite = (burstSprites == null) ? goodBubblesSprites[UnityEngine.Random.Range(0, goodBubblesSprites.Length)] : burstSprites[UnityEngine.Random.Range (0, burstSprites.Length)] ; if (!bool.Parse(PlayerPrefs.GetString("isSoundOff", "false"))) { obj.GetComponent <AudioSource> ().clip = goodBubbleSounds [UnityEngine.Random.Range(0, goodBubbleSounds.Length)]; obj.GetComponent <AudioSource> ().Play(); } if (burstSprites == null) { Destroy(obj.GetComponent("GoodBubbleClick")); } else { Destroy(obj.GetComponent("BonusBubbleClick")); } ChangeScore(obj.transform.position); ChangeCarma(); if ((Time.time - _timeLastBursted) < 0.5) { _burstedInMultiTouch += 1; } else { _burstedInMultiTouch = 0; } // открыть достижение ловкач if (_burstedInMultiTouch > 2) { GooglePlayActions.UnlockAchievement(GooglePlayActions.tricksterAchiev); } _goodBubblesBurst += 1; _timeLastBursted = Time.time; if (obj.GetComponentInChildren <CloseHelp>()) { obj.GetComponentInChildren <CloseHelp>().onHelpClose(); } }
IEnumerator FinishGame() { finished = true; isRecord = false; List <string> recordAnnotation = new List <string>(); try { if (GetScore() > PlayerPrefs.GetInt("Score", 0)) { isRecord = true; PlayerPrefs.SetInt("Score", GetScore()); recordAnnotation.Add("Score: " + GetScore()); ActivateRecordScreen(); GooglePlayActions.ReportResult(GooglePlayActions.scoreLeaderboardId, GetScore()); } if (startTime - 3 > PlayerPrefs.GetInt("Time", 0)) { isRecord = true; PlayerPrefs.SetInt("Time", (int)(Time.timeSinceLevelLoad - 3)); recordAnnotation.Add("Time: " + minutes.ToString("00") + ":" + seconds.ToString("00")); ActivateRecordScreen(); GooglePlayActions.ReportResult(GooglePlayActions.timeLeaderboardId, (long)(Time.timeSinceLevelLoad - 3) * 1000); } if (_badBubblesBurst > PlayerPrefs.GetInt("BadBubblesCount", 0)) { isRecord = true; PlayerPrefs.SetInt("BadBubblesCount", _badBubblesBurst); recordAnnotation.Add("Bad bubbles: " + _badBubblesBurst); ActivateRecordScreen(); GooglePlayActions.ReportResult(GooglePlayActions.bubblesCountLeaderboardId, _badBubblesBurst); } // достижение за прохождение первой трассы if (!PlayerPrefs.HasKey("Score")) { GooglePlayActions.UnlockAchievement(GooglePlayActions.pioneerAchiev); PlayerPrefs.SetInt("PinkFrame", 1); } // достижение за скоростной слив игры if (startTime - 3 <= 19) { GooglePlayActions.UnlockAchievement(GooglePlayActions.destrudoAchiev); } // достижение за 3000 очков if (GetScore() >= 3000) { GooglePlayActions.UnlockAchievement(GooglePlayActions.longLiveAchiev); PlayerPrefs.SetInt("KingFrame", 1); } //достижения за позицию в лидерборде GooglePlayActions.GetLeaderboardRank(GooglePlayActions.scoreLeaderboardId); GooglePlayActions.GetLeaderboardRank(GooglePlayActions.timeLeaderboardId); GooglePlayActions.GetLeaderboardRank(GooglePlayActions.bubblesCountLeaderboardId); } catch (Exception e) { Debug.Log(e); } menuPanel.SetActive(true); backButtonIngame.SetActive(false); menuBackground.GetComponent <UIElement>().Show(false); menuPanel.GetComponent <UIElement>().Show(false); nextButton.SetActive(true); audioSource.volume = 0.1f; badCarmaAlert.GetComponent <Animator>().enabled = false; pauseButton.GetComponent <Button>().interactable = false; finishPanel.SetActive(true); buttonsPanel.SetActive(true); scoresText.text = GetScore().ToString(); goodBubblesText.text = _goodBubblesBurst.ToString(); badBubblesText.text = _badBubblesBurst.ToString(); finishTimeText.text = minutes.ToString("00") + ":" + seconds.ToString("00"); finishText.text = "the end"; if (!isRecord) { //bool showAds = (UnityEngine.Random.Range(1, 5) == 1) ? true : false; //if (showAds) //{ // RequestInterstitialAds(); // Utilities.UpdatePrefs("WatchAdsCounter", 1); //} Utilities.UpdatePrefs("IsRecord", 0); } else { this.ActivateRecordScreen(); Utilities.UpdatePrefs("IsRecord", 1); yield return(new WaitForSeconds(1f)); if (Permission.HasUserAuthorizedPermission(Permission.Camera)) { SceneManager.LoadScene("PhotoScene"); } else { AndroidRuntimePermissions.Permission result = AndroidRuntimePermissions.RequestPermission("android.permission.CAMERA"); if (result == AndroidRuntimePermissions.Permission.Granted) { SceneManager.LoadScene("PhotoScene"); } } } if (recordAnnotation.Count > 0) { PlayerPrefs.SetString("RecordAnnotation", String.Join("\n", recordAnnotation.ToArray())); } }
void Update() { if (started) { startTime += Time.deltaTime; if (starting) { player.transform.Translate(moveUnitsPerSecond * startTime * 0.009f); return; } if (!finished) { minutes = (int)Mathf.Floor((startTime - 4) / 60); seconds = (int)((startTime - 4) % 60); timeText.text = minutes.ToString("00") + ":" + seconds.ToString("00"); //изменение скорости с количеством очков float speed = (GetScore() / 1000f) + 2f; float speedBonus = (bonus.isSpeedBonus() && bonus.IsActive()) ? speed * bonus.Multiplier : 0; speedBonus = (bonus.Name.Equals(BonusType.Fast)) ? speedBonus : -speedBonus; player.transform.Translate((speed + speedBonus) * moveUnitsPerSecond * Time.deltaTime); if (Time.time >= _nextTime) { SetCarmaOnUpdate(-1.2f); // we need constantly decrease the carma with time _nextTime += 0.5f / speed; } if (!_isBadCarma && GetCarmaState().Equals(CarmaStates.Bad)) { _isBadCarma = true; badCarmaAlert.GetComponent <Animator>().enabled = true; } if (_isBadCarma && !GetCarmaState().Equals(CarmaStates.Bad)) { _isBadCarma = false; badCarmaAlert.GetComponent <Animator>().enabled = false; badCarmaAlert.GetComponent <Image>().color = new Color(1, 1, 1, 0); } // разблокрирование сверхчеловека if (startTime - _timeLastFail >= 603) { if (_pauseScript.pauseCount < 1) { GooglePlayActions.UnlockAchievement(GooglePlayActions.superhumanAchiev); PlayerPrefs.SetInt("HeroFrame", 1); } else { GooglePlayActions.UnlockAchievement(GooglePlayActions.davidBlaineAchiev); PlayerPrefs.SetInt("DragonFrame", 1); } } // spawn help text if ((Time.time - _timeLastBursted > 10) && (Time.time - _timeLastHelpSpawn > 5)) { StartCoroutine(_gridManager.SpawnHelpText()); _timeLastHelpSpawn = Time.time; } // разблокирование апатии if (startTime - _timeLastFail >= 30 && startTime - _timeLastBursted >= 30) { GooglePlayActions.UnlockAchievement(GooglePlayActions.apathyAchiev); } } } if (Input.GetKeyDown(KeyCode.Escape)) { if (helpButton.GetComponent <OpenHelp>().IsOpened()) { helpButton.GetComponent <OpenHelp>().OnClick(); } else if (menuController.IsOpened()) { backButtonIngame.GetComponent <UIButton>().OnClick.Invoke(); } else { Application.Quit(); } } }