Beispiel #1
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("完成整个周期");
            }
        }