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
 void OnReset()
 {
     if (mMainPanel != null)
     {
         lastScoreText.Display(0, 0.1f);
     }
     if (JavaInterface.Java() && playerText != null)
     {
         playerText.Display(JavaInterface.GetScorePlayer() / 10, 0.1f);
         scoreText.Display(JavaInterface.GetScorePlayer() % 10, 0.1f);
     }
 }
Beispiel #4
0
    IEnumerator GetCoinEventList(float time)
    {
        int newInCoin1  = JavaInterface.getInCoin1();
        int newInCoin2  = JavaInterface.getInCoin2();
        int newOutCoin1 = JavaInterface.getOutCoin1();
        int newOutCoin2 = JavaInterface.getOutCoin2();

        int newScorePlayer = JavaInterface.GetScorePlayer();

        int oldInCoin1     = newInCoin1;
        int oldInCoin2     = newInCoin2;
        int oldOutCoin1    = newOutCoin1;
        int oldOutCoin2    = newOutCoin2;
        int oldScorePlayer = newScorePlayer;

        while (true)
        {
            newInCoin1  = JavaInterface.getInCoin1();
            newInCoin2  = JavaInterface.getInCoin2();
            newOutCoin1 = JavaInterface.getOutCoin1();
            newOutCoin2 = JavaInterface.getOutCoin2();

            newScorePlayer = JavaInterface.GetScorePlayer();

            if (newScorePlayer != oldScorePlayer)
            {
                oldScorePlayer = newScorePlayer; OnChangeScoreEvent(newScorePlayer);
            }

            if (newInCoin1 != oldInCoin1)
            {
                oldInCoin1 = newInCoin1; OnChangeInCoin1Event();
            }
            if (newInCoin2 != oldInCoin2)
            {
                oldInCoin2 = newInCoin2; OnChangeInCoin2Event();
            }
            if (newOutCoin1 != oldOutCoin1)
            {
                oldOutCoin1 = newOutCoin1; OnChangeOutCoin1Event();
            }
            if (newOutCoin2 != oldOutCoin2)
            {
                oldOutCoin2 = newOutCoin2; OnChangeOutCoin2Event();
            }
            yield return(new WaitForSeconds(time));
        }
    }
Beispiel #5
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("完成整个周期");
            }
        }