コード例 #1
0
ファイル: GameApp.cs プロジェクト: zuojiashun/src
    /// <summary>
    /// 构建游戏初始化数据
    /// </summary>
    private void StructGameInitData(GameObject root)
    {
        if (null == m_lstGameInitDatas)
        {
            m_lstGameInitDatas = new List <GameInitData>();
        }
        m_lstGameInitDatas.Clear();

        //1、网络初始化
        GameInitData gameInitData = GameInitData.Create(GameInitDataType.Net, "网络初始化", (progressCallback, data) =>
        {
            //网络初始化
            NetService.Instance.Init();
            progressCallback.Invoke(data, 1);
        });

        m_lstGameInitDatas.Add(gameInitData);

        //2、品质设置

        gameInitData = GameInitData.Create(GameInitDataType.Quality, "品质设置", (progressCallback, data) =>
        {
            //品质设置
            QualitySettings.pixelLightCount = 3;
            QualitySettings.SetQualityLevel((int)QualityLevel.Good);
            progressCallback.Invoke(data, 1f);

            if (SystemInfo.systemMemorySize < 1024)
            {
                QualitySettings.shadows = ShadowQuality.Disable;
            }
        }, 30);
        m_lstGameInitDatas.Add(gameInitData);



        //3、配置表设置
        gameInitData = GameInitData.Create(GameInitDataType.Table, "配置表设置", (progressCallback, data) =>
        {
            // 配置表路径设置
            Table.SetDataPath("common/tab/");
            float totalSubProgress   = 0;
            Action <float> subAction = (subProgress) =>
            {
                totalSubProgress = 0.8f * subProgress;
                progressCallback.Invoke(data, totalSubProgress);
            };
            // 加载配置表
            GameTableManager.Instance.LoadTable(subAction);
            GameTableManager.Instance.LoadGloabalConst();
            progressCallback.Invoke(data, 1);
        }, 50);
        m_lstGameInitDatas.Add(gameInitData);



        //5、游戏环境初始化
        gameInitData = GameInitData.Create(GameInitDataType.GameEnvironment, "游戏环境初始化", (progressCallback, data) =>
        {
            // 设置特效加载回调
            EffectLoad effectLoad = new EffectLoad();
            Engine.RareEngine.Instance().SetEffectLoad(effectLoad);
            // 镜头bloom效果
            CameraBloomEffect cameraBloom = new CameraBloomEffect();
            Engine.RareEngine.Instance().SetCameraBloom(cameraBloom);

            progressCallback.Invoke(data, 0.2f);
            //剧情
            SequencerManager.Instance().Init();
            AppleSceneMaterial.Instance();

            progressCallback.Invoke(data, 0.4f);
            // 实体消息缓存
            EntityCreator.Instance().Init();
            progressCallback.Invoke(data, 0.6f);
            // 游戏逻辑初始化
            ClientGlobal.Instance().Init();
            progressCallback.Invoke(data, 0.8f);
            ////生成数据管理器
            //DataManager.Instance.Create();
            //TipsManager.Instance.Initialize();


            progressCallback.Invoke(data, 1);
        }, 20);
        m_lstGameInitDatas.Add(gameInitData);

        //6、本地数据初始化
        gameInitData = GameInitData.Create(GameInitDataType.DataManager, "本地数据初始化", (progressCallback, data) =>
        {
            //本地数据初始化
            float totalSubProgress   = 0;
            Action <float> subAction = (subProgress) =>
            {
                totalSubProgress = 0.99f * subProgress;
                progressCallback.Invoke(data, totalSubProgress);
            };
            DataManager.Instance.Create(subAction);
            TipsManager.Instance.Initialize();

            progressCallback.Invoke(data, 1);
        }, 30);
        m_lstGameInitDatas.Add(gameInitData);

        //4、GVoice初始化
        gameInitData = GameInitData.Create(GameInitDataType.GVoice, "GVoice初始化", (progressCallback, data) =>
        {
            //GVoice初始化
            GVoiceManger.Instance.InitGvoice();
            progressCallback.Invoke(data, 1);
        });
        m_lstGameInitDatas.Add(gameInitData);
    }