Пример #1
0
    void OnCollisionEnter(Collision col)
    {
        if (mbInput == false)
        {
            // 볼 소리는 넣자.
            if (col.gameObject.CompareTag("Earth"))
            {
                mAudioBounce.Play();
            }
            return;
        }

        if (col.gameObject.CompareTag("Wall"))
        {
            mbInput = false;
            GetComponent <Rigidbody> ().AddExplosionForce(100f, col.transform.position, 360f);
            mWallPool.Stop();

            nBestScore = PlayerPrefs.GetInt("BestScore", 0);
            if (nScore > nBestScore)
            {
                PlayerPrefs.SetInt("BestScore", nScore);
                nBestScore = nScore;
                mRanking.ReportScore(nBestScore);                       // 랭킹등록
                mRanking.UnlockAchievement(nBestScore);                 // 업적등록
            }

            mResultPoint.text   = string.Format("<size=70>{0}</size>\nBest <color=#ff0000>{1}</color>", nScore, nBestScore);
            mResultSlider.value = nScore >= 10 ? 1f : (nScore / 10f) + 0.05f;
            mPoint.text         = string.Empty;
            mResultPop.SetActive(true);

            if (nScore >= 10)
            {
                // 상자 클릭가능... 엔딩보여주기.
                mEndingPop.SetActive(true);
                mSpike.Play();
                mAudioEnding.Play();
            }
            else
            {
                mAudioLose.Play();
            }

            nDead += 1;
            if (nDead >= 3)
            {
                nDead = 0;
                mAdmob.ShowInterstitialAd();                    // 전면광고
            }
            PlayerPrefs.SetInt("GrrPuding_BounceBall_Die", nDead);
        }
        else if (col.gameObject.CompareTag("Earth"))
        {
            mAudioBounce.Play();

            if (fPower >= 25f)
            {
                mSmoke.transform.localPosition = transform.localPosition + Vector3.down;
                mSmoke.Play();
            }
            fPower = 0f;
        }
    }