Ejemplo n.º 1
0
    public void OnStartGameFrameUpdate(object arg)
    {
        float process;

        if (isLoadScene)
        {
            float sceneProcess = GameSceneManager.LoadSceneProcess;
            if (sceneProcess < 0)
            {
                EventManager.Unregister(GameEvent.Type.FrameUpdate, OnStartGameFrameUpdate);
                return;
            }
            process = (GameConfig.StartGameLoadTime + sceneProcess - 1) / GameConfig.StartGameLoadTime;
        }
        else
        {
            float passTime         = Time.time - m_startTime;
            bool  isStartLoadScene = passTime > GameConfig.StartGameLoadTime - 1;
            if (isStartLoadScene)
            {
                EventManager.Dispatch(GameEvent.Type.ChangeScene, GameScene.SelectScene);
                isLoadScene = true;
            }
            process = passTime / GameConfig.StartGameLoadTime;
        }
        if (process >= 1)
        {
            m_loadingView.UpdateLoadingProcess(1);
            EventManager.Unregister(GameEvent.Type.FrameUpdate, OnStartGameFrameUpdate);
            EventManager.Dispatch(GameMoudle.Loading, GameEvent.Type.CloseMainView);
        }
        else
        {
            m_loadingView.UpdateLoadingProcess(process);
        }
    }