예제 #1
0
    public void GameOver(bool isGoal, int distance, int star, float time)
    {
        mIsGameOver = true;
        mHasGoal    = isGoal;

        int score = CalcScore(isGoal, distance, star, time);

        // 保存
        int bestScore;

        {
            bestScore = PlayerPrefs.GetInt("BestScore", -1);
            bool isLastSaveSucceeded = (PlayerPrefs.GetInt("LastSaveSucceeded", 1) == 1);
            if ((bestScore < 0) || (score > bestScore) || !isLastSaveSucceeded)
            {
                bestScore = score;
                PlayerPrefs.SetInt("BestScore", score);

                mRankingManager.SaveScore(score, isGoal, star, time, PlayerPrefs.GetInt("PlayNum"));
                mRankingManager.FetchRanking();
            }
        }

        iTween.ValueTo(gameObject, iTween.Hash("from", 0.0f, "to", 0.65f, "time", 0.8f, "onupdate", "SetBackgroundAlpha"));
        iTween.ValueTo(gameObject, iTween.Hash("from", 1.0f, "to", 0.0f, "time", 0.8f, "onupdate", "SetTextAlpha"));
        iTween.ValueTo(gameObject, iTween.Hash("from", 0.0f, "to", 1.0f, "time", 0.8f, "onupdate", "SetTextResultAlpha"));
        iTween.ScaleTo(mSliderLeft.gameObject, iTween.Hash("x", 0.0f, "y", 0.0f, "time", 0.4f, "easetype", "easeInBack"));
        iTween.ScaleTo(mSliderRight.gameObject, iTween.Hash("x", 0.0f, "y", 0.0f, "time", 0.4f, "easetype", "easeInBack"));

        mTextResultScore.text     = score.ToString();
        mTextResultBest.text      = "Best " + bestScore.ToString();
        mTextResultRank.text      = "World Rank " + (mRankingManager.Ranking > 0 ? mRankingManager.Ranking.ToString() : "?");
        mTextResultDistance.text  = "Sector " + distance.ToString() + " x " + cScoreDistance.ToString() + " → " + (distance * cScoreDistance).ToString();
        mTextResultStar.text      = "Gem " + star.ToString() + " x " + (isGoal ? cScoreStarGoal : cScoreStarNoGoal).ToString() + " → " + (star * (isGoal ? cScoreStarGoal : cScoreStarNoGoal)).ToString();
        mTextResultGoalBonus.text = "Goal Bonus " + time.ToString("F2") + " x " + cScoreGoalTimeBonus.ToString() + " → " + CalcGoalBonus(isGoal, time).ToString();

        // 広告
        {
            int playNum = PlayerPrefs.GetInt("PlayNum", 0);
            if (playNum > 0 && (playNum % 5 == 0) && (bestScore >= 10) && !isGoal)
            {
                GameObject.Find("UnityAds").GetComponent <UnityAds> ().ShowAd();
            }
        }
    }