// Use this for initialization void Start() { GetComponent <Button>().onClick.AddListener(() => { GooglePlayServicesScript.ShowLeaderboardUI(); }); }
public void CheckHighScoreWhenReplay() { if (GameController.Score > GameController.BestScore) { // store best score GameController.BestScore = GameController.Score; SaveGame.instance.saveBestScore(GameController.Score); MyFirebase.LogUserProfile(MyFirebase.UserProfile.get_new_highscore); if (Application.platform == RuntimePlatform.Android) { GooglePlayServicesScript.ReportScore(GPGSIds.leaderboard_top_best_score, GameController.BestScore); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { GooglePlayServicesScript.ReportScore(GooglePlayServicesScript.TopHighScore, GameController.BestScore); } GameController.Instance.AddMoreRotate(2); NotifyController.Instance.ShowNotify(string.Format("You have bonus {0} rotate from high score!", 2)); } SaveGame.instance.saveScore(0); }
// Update is called once per frame void Update() { Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); Vector3 dir = Vector3.zero; if (!isGameOver && isStarted) { scoreText.text = score.ToString(); } if (Input.GetMouseButtonDown(0) && !isStarted) { RaycastHit2D hit = Physics2D.Raycast(mousePos2D, dir); if (hit.transform != null) { if (hit.transform.tag == "Gotobuttons") { //Do Nothing } else if (hit.transform.tag == "PlayGame") { isStarted = true; anim.Play("GoOnPlay"); for (int i = 0; i < titleObj.Length; i++) { titleObj[i].SetActive(false); } player.bodyType = RigidbodyType2D.Dynamic; player.velocity = Vector2.zero; player.AddForce(new Vector2(0, upForce)); scoreTextObj.SetActive(true); StartCoroutine(deactive()); } } } if (isGameOver) { gameOverPanel.SetActive(true); scoreTextObj.SetActive(false); scoreTextPanel.text = score.ToString(); GameOverText.SetActive(true); if (prevHighScore < score) { PlayerPrefs.SetInt("HighScore", score); highScoreTextPanel.text = score.ToString(); GooglePlayServicesScript.OnAddScoreToLeaderBorad(score); } else { highScoreTextPanel.text = prevHighScore.ToString(); } } }
public void ShowGameoverPopup() { // Check score to bonus if (GameController.Score >= 1000) { _countGameover++; } bool isBonusHighScore = true; if (_countGameover >= 10) { int bonus = Random.Range(3, 6); GameController.Instance.AddMoreRotate(bonus); NotifyController.Instance.ShowNotify(string.Format("You have bonus {0} rotate!", bonus)); MyFirebase.LogUserProfile(MyFirebase.UserProfile.get_level_bonus); isBonusHighScore = false; } HideAll(); // Check best score if (GameController.Score > GameController.BestScore) { // store best score GameController.BestScore = GameController.Score; SaveGame.instance.saveBestScore(GameController.Score); // Show effect best score _bestScoreEffect.gameObject.SetActive(true); _newRewordEffect.SetActive(true); SoundController.Instance.PlaySoundEffect(SoundController.Instance.Firework); SoundController.Instance.PlaySoundEffect(SoundController.Instance.NewHighScore); MyFirebase.LogUserProfile(MyFirebase.UserProfile.get_new_highscore); if (isBonusHighScore) { GameController.Instance.AddMoreRotate(3); NotifyController.Instance.ShowNotify(string.Format("You have bonus {0} rotate!", 3)); } if (Application.platform == RuntimePlatform.Android) { GooglePlayServicesScript.ReportScore(GPGSIds.leaderboard_top_best_score, GameController.BestScore); } else if (Application.platform == RuntimePlatform.IPhonePlayer) { GooglePlayServicesScript.ReportScore(GooglePlayServicesScript.TopHighScore, GameController.BestScore); } } else { _bestScoreEffect.SetActive(false); _newRewordEffect.SetActive(false); //SoundController.Instance.PlaySoundEffect(SoundController.Instance.Gameover); } Show(); _gameoverPopup.Show(); SaveGame.instance.saveScore(0); }