Beispiel #1
0
        void OnFinishGame()
        {
            isVerify     = false;
            isFinishInit = false;
            isGame       = false;
            isLaunchGame = false;
            isPlay       = false;
            isStartGame  = false;

            if (JavaInterface.Java())
            {
                if (JavaInterface.GetScorePlayer() >= 10)
                {
                    JavaInterface.AddScorePlayer(-10);
                    isResetGame = true;
                }
                else
                {
                    isResetGame = false;
                }
            }
            else
            {
                isResetGame = true;
            }
            if (isResetGame)
            {
                SwitchScene(true);
            }
            else
            {
                SwitchScene(false);
            }
        }
Beispiel #2
0
 void Start()
 {
     if (JavaInterface.Java())
     {
         InputPort.onChangeScoreEvent += (int value) =>
         {
             Debug.Log(value);
         };
         InputPort.onKeyDownEventList[0] += () =>
         {
             Debug.Log("0 键被按下");
         };
         InputPort.onKeyDownEvent += () =>
         {
             Debug.Log("按键被按下");
         };
         //获取玩家分数
         Debug.Log(JavaInterface.GetScorePlayer());
         //设置玩家分数
         JavaInterface.SetInt("ScorePlayer", 100);
         Debug.Log(JavaInterface.GetScorePlayer());
         //添加玩家分数
         JavaInterface.AddScorePlayer(100);
         Debug.Log(JavaInterface.GetScorePlayer());
         //JavaInterface.PlayVideo();
         Debug.Log(JavaInterface.GetInt("ScorePlayer"));
     }
 }
Beispiel #3
0
        IEnumerator UpdateStatus()
        {
            //临时变量
            int temp;

            WaitForSeconds wait = new WaitForSeconds(0.1f);

            //判断循环
            while (true)
            {
                //Debug.Log("启动游戏周期");
                //等待直到游戏初始化完成
                while (!isFinishInit)
                {
                    yield return(wait);
                }
                //Debug.Log("完成初始化");
                //等待直到游戏进程启动
                while (!isLaunchGame)
                {
                    //街机模式下自动启动游戏进程
                    if (JavaInterface.Java())
                    {
                        //退币完成才能开始游戏
                        while (isOutCoin)
                        {
                            isOutCoin = JavaInterface.GetCoinOutFlag();
                            //Debug.Log(isOutCoin);
                            yield return(wait);
                        }
                        if (JavaInterface.GetScorePlayer() >= 10)
                        {
                            JavaInterface.AddScorePlayer(-10);
                            isLaunchGame = true;
                        }
                    }
                    yield return(wait);
                }
                //Debug.Log("启动游戏进程");
                GameEvent.OnLaunchGame();
                //等待直到倒计时完毕
                temp = 4;
                while (temp-- > 0)
                {
                    GameEvent.WaitStartGame(temp);
                    yield return(new WaitForSeconds(0.375f));
                }
                GameEvent.OnPlayGame();
                //Debug.Log("完成倒计时");
                //等待直到正式开始游戏
                overtime = 100;
                while (!isPlay && overtime-- > 0)
                {
                    yield return(wait);
                }
                if (overtime <= 0)
                {
                    //Debug.Log("等待超时");
                    isPlay = true;
                }
                //Debug.Log("开始游戏进程");
                GameEvent.OnStartGame();
                //等待直到验证完成
                while (!isVerify)
                {
                    yield return(wait);
                }
                //Debug.Log("验证游戏结果");
                //等待直到完成游戏进程
                while (isGame)
                {
                    yield return(wait);
                }
                //Debug.Log("完成游戏进程");
                //完成后执行清理工作
                GameEvent.OnFinishGame();
                //检测间隔(默认0.1秒)
                yield return(wait);
                //Debug.Log("完成整个周期");
            }
        }
Beispiel #4
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);
            }
        }