private void GameOver() { showAd = true; GameOverPanel.SetActive(true); powerPanel.SetActive(false); ProtectedPrefs.SetInt("Coins", lcoin + coin); goCoin.text = "Coins: " + coin.ToString(); goScore.text = "Score: " + Controller.Distance.ToString("f0") + "0"; if (Controller.Distance > ProtectedPrefs.GetFloat("HighScore")) { ProtectedPrefs.SetFloat("HighScore", Controller.Distance); } if (ProtectedPrefs.HasKey("HighScore")) { goBScore.text = "Best Score: " + ProtectedPrefs.GetFloat("HighScore").ToString("f0") + "0"; } else { goBScore.text = "Best Score: " + Controller.Distance.ToString("f0") + "0"; } if (FB.IsLoggedIn) { #if !UNITY_EDITOR StartCoroutine(Facebook.Unity.FBManager.SetScore()); #endif } }
void Update() { if (lifesave == true && Controller.iDie && !loadS && !SaveMe) { showAd = false; SaveLifePanel.SetActive(true); timerl += Time.deltaTime; sl.fillAmount -= Time.deltaTime / 1.8F; if (timerl >= 1.8F) { timerl = 0; sl.fillAmount = 1; SaveLifePanel.SetActive(false); Invoke("GameOver", 0.5f); loadS = true; } } if (itemAbsorb.getLamp) { GetLamp(); } coine.text = coin.ToString(); distance.text = Controller.Distance.ToString("00000000") + "0"; if (Controller.Distance > 10 && Controller.Distance > ProtectedPrefs.GetFloat("HighScore") && !changeScorecolor) { cc += Time.deltaTime; if (cc < 1) { distance.color = new Color(1, 0, 0, 1); } else if (cc > 1 && cc < 1.5f) { distance.color = new Color(1, 1, 1, 1); } else if (cc > 1.5f && cc < 2) { distance.color = new Color(1, 0, 0, 1); } else if (cc > 2 && cc < 2.5f) { distance.color = new Color(1, 1, 1, 1); } else if (cc > 2.5f) { distance.color = new Color(1f, 0.92f, 0.016f, 1f); cc = 0; changeScorecolor = true; } } if (Controller.iDie && ProtectedPrefs.GetInt("mLamp") < 1) { MainMenuPanel.SetActive(false); Invoke("GameOver", 0.5f); } else if (Controller.iDie && ProtectedPrefs.GetInt("mLamp") > 0 && !lifesave) { MainMenuPanel.SetActive(false); lifesave = true; loadS = false; } }