コード例 #1
0
        void OnDeath(PlayerInfo player)
        {
            if (player.index == 0)
            {
                int award = 0;
                audio.clip = dieMarch;
                audio.Play();
                mScroll.gameObject.SetActive(false);
                mScrollMain.gameObject.SetActive(false);
                gameText.gameObject.SetActive(false);
                allScore    = allScore + gameScore;
                gameCounter = gameCounter + 1;
                switch (awards)
                {
                case 0: break;

                case 1:
                    award = 1;
                    //Debug.Log("铜奖");
                    break;

                case 2:
                    award = 2;
                    //Debug.Log("银奖");
                    break;

                case 3:
                    award       = 3;
                    allScore    = (int)(0.8f * allScore + gameScore);
                    gameCounter = (int)(0.8f * gameCounter + 1);
                    //Debug.Log("金奖");
                    break;

                case 4:
                    award       = 5;
                    allScore    = (int)(0.5f * allScore + gameScore);
                    gameCounter = (int)(0.5f * gameCounter + 1);
                    //Debug.Log("最高奖");
                    break;

                default: break;
                }
                if (gameScore > bestScore)
                {
                    bestScore = gameScore;
                    PlayerPrefs.SetInt("BestScore", bestScore);
                }
                if (JavaInterface.Java())
                {
                    if (award != 0 && JavaInterface.GetBonus() > (10 * award))
                    {
                        JavaInterface.AddScorePlayer(award * 10);
                        JavaInterface.CoinOut1Limit(award);
                        //开始退币检查
                        GameController.isOutCoin = true;
                        Debug.Log("退出" + award + "个币");
                    }
                    else
                    {
                        Debug.Log("奖金不足无法退出");
                    }
                }
                if (profit >= award)
                {
                    profit -= award;
                    PlayerPrefs.SetInt("Profit", profit);
                    //Debug.Log("退出"+ award + "个币");
                }
                else
                {
                    Debug.Log("奖金不足无法退出");
                }
                PlayerPrefs.SetInt("AllScore", allScore);
                PlayerPrefs.SetInt("GameCounter", gameCounter);
                PlayerPrefs.Save();
                lastScoreText.Display(gameScore, 0.05f);
                bestText.Display(bestScore);

                mMainPanel.Award(awards);
                mMainPanel.Display();

                SetGameScore(0);
                awards = 0;
                Debug.Log("利润:" + profit + " 第" + gameCounter + "局" + averageScore);
            }
        }