示例#1
0
    /** 执行版本更新下一步 */
    protected void doVersionNext(bool needAlert, Action overFunc)
    {
        int size = ResourceInfoControl.preDownLoad();

        //需要下载
        if (size > 0)
        {
            //不是wifi或者是wifi但是需要弹出
            if (needAlert && ShineSetting.isRelease)
            {
                _downloadSize = StringUtils.toMBString(size);

                //更新资源选择
                showAlertInWifi(Alert_GetNewResourceMust, () =>
                {
                    startVersionDownload(overFunc);
                }, exitGame);
            }
            else
            {
                startVersionDownload(overFunc);
            }
        }
        else
        {
            if (overFunc != null)
            {
                overFunc();
            }
        }
    }
示例#2
0
    /** 继续使用当前的app版本 */
    private void continueCurrentApp(VersionSaveData localVersionData)
    {
        //当前版本够
        if (localVersionData.resourceVersion >= _versionData.currentResourceVersion)
        {
            doVersionNext(true);
        }
        else
        {
            //读取cdn版本
            ResourceInfoControl.loadCDNVersion(_versionData.currentResourceVersion, cdnVersion =>
            {
                //需要强制资源更新或之前未完全更完
                if (localVersionData.resourceVersion < _versionData.leastResourceVersion || !ResourceInfoControl.isVersionDataReady())
                {
                    ResourceInfoControl.mergeVersion(cdnVersion);
                    doVersionNext(true);
                    return;
                }

                //计算更新量
                ResourceInfoControl.countNewVersionSize(cdnVersion, _versionRe);

                _downloadSize = StringUtils.toMBString(_versionRe.size);

                //更新资源选择
                showAlertInWifi(Alert_GetNewResource, () =>
                {
                    ResourceInfoControl.mergeVersion(cdnVersion);
                    doVersionNext(false);
                }, versionUpdateOver);
            });
        }
    }
示例#3
0
    /** 获取新版本链接 */
    protected virtual void toGetNewApp()
    {
        //下载路径
        string path = ResourceInfoControl.getAppPath(_versionData.currentAppVersion);

        //TODO:跳到appStore的api
    }
示例#4
0
    /** 连接游戏服成功 */
    public void connectGameSuccess()
    {
        if (!_running)
        {
            return;
        }

        _connectGaming.unlock();
        Ctrl.debugLog("连接game成功");

        if (_isSwitching)
        {
            _isSwitching = false;
            PlayerSwitchGameRequest.create(_gameInfo.token).send();
        }
        else
        {
            //可以停了
            _httpLoginAffair.stop();

            VersionSaveData versionSaveData = ResourceInfoControl.getVersion();
            int             resourceVersion = versionSaveData != null ? versionSaveData.resourceVersion : 100000;
            LoginGameRequest.create(_gameInfo.token, CodeCheckRecord.msgDataVersion, BaseC.config.getMsgDataVersion(), resourceVersion).send();
        }
    }
示例#5
0
    public virtual void makeClientLoginData(ClientLoginData data)
    {
        //游客
        if (platform == PlatformType.Visitor)
        {
            uid = getVisitorUID();
        }

        data.uid                    = uid;
        data.countryID              = countryID;
        data.platform               = platform;
        data.clientPlatformType     = SystemControl.clientPlatform;
        data.deviceType             = SystemInfo.deviceType.ToString();
        data.deviceUniqueIdentifier = SystemInfo.deviceUniqueIdentifier;
        data.visitorUID             = "";

        VersionSaveData localVersionData = ResourceInfoControl.getVersion();

        data.appVersion      = localVersionData.appVersion;
        data.resourceVersion = localVersionData.resourceVersion;

        ClientLoginCacheData loginCacheData = GameC.save.loadLoginCache();

        //游客平台,为自动绑定
        if (loginCacheData != null && loginCacheData.platform == PlatformType.Visitor && data.platform != PlatformType.Visitor)
        {
            data.visitorUID = loginCacheData.uid;
        }
    }
示例#6
0
    /** 开始资源下载 */
    protected virtual void startVersionDownload(Action overFunc)
    {
        //UI显示
        ResourceInfoControl.doDownload(overFunc);

        //期间可以通过ResourceInfoControl.getCurrentLoadSize和getNeedLoadSize获取下载的资源进度
        //再通过StringUtils.toMBString转字符串显示
    }
示例#7
0
    protected virtual void doSendGetVersion()
    {
        //本地版本数据
        VersionSaveData localVersionData = ResourceInfoControl.getVersion();

        //发送当前的本地版本
        ClientGetVersionHttpRequest.create(SystemControl.clientPlatform, localVersionData.resourceVersion).send();
    }
示例#8
0
    //initUIs


    /** 初始化 */
    public void init()
    {
        TimeDriver.instance.setInterval(onSecond, 1000);

        ResourceInfoControl.setIsCommonResourceFunc(isResourceNeedPlatform);

        initStep();
    }
示例#9
0
 /** 获取客户端版本号 */
 protected virtual void stepGetVersion()
 {
     if (ShineSetting.isWholeClient)
     {
         //读取本地版本
         ResourceInfoControl.loadVersion(() => { preGetVersion(); });
     }
     else
     {
         preGetVersion();
     }
 }
示例#10
0
    /** 客户端版本更新(true:为不需要更新) */
    public bool clientHotfix(ClientVersionData vData)
    {
        if (ShineSetting.debugJumpResourceVersion || ShineSetting.localLoadWithOutBundle)
        {
            return(true);
        }

        //已处理过
        if (_versionData != null && vData != null && _versionData.currentResourceVersion >= vData.currentResourceVersion)
        {
            return(true);
        }

        VersionSaveData localVersionData = ResourceInfoControl.getVersion();

        if (vData == null)
        {
            Ctrl.log("离线游戏 或 服务器无此版本2");

            vData                   = new ClientVersionData();
            vData.version           = localVersionData.version;
            vData.currentAppVersion = localVersionData.appVersion;
            // _versionData.leastAppVersion=localVersionData.currentAppVersion;
            vData.currentResourceVersion = localVersionData.resourceVersion;
        }

        _versionData = vData;

        if (!ShineSetting.isRelease)
        {
            return(true);
        }
        else
        {
            //最低app版本不足
            if (localVersionData.appVersion < _versionData.leastAppVersion)
            {
                showAlert(Alert_GetNewAppMust, toGetNewApp, exitGame);
                return(false);
            }

            //有新的app
            if (localVersionData.appVersion < _versionData.currentAppVersion)
            {
                showAlert(Alert_GetNewApp, toGetNewApp, () => { hotfixNext(vData); });
                return(false);
            }

            hotfixNext(vData);
            return(false);
        }
    }
示例#11
0
    private void hotfixNext(ClientVersionData vData)
    {
        //读取cdn版本
        ResourceInfoControl.loadCDNVersion(vData.currentResourceVersion, sData =>
        {
            //计算更新量
            ResourceInfoControl.countNewVersionSize(sData, _versionRe);

            //只有配置
            if (_versionRe.isOnlyConfig)
            {
                ResourceInfoControl.mergeVersion(sData);
                doVersionNext(false, () =>
                {
                    if (GameC.main != null)
                    {
                        //热更配置
                        GameC.main.reloadConfig();
                        GameC.main.hotfixOver();
                    }
                });
            }
            //返回登录界面开始热更
            else
            {
                VersionSaveData localVersionData = ResourceInfoControl.getVersion();

                _downloadSize = StringUtils.toMBString(_versionRe.size);

                //需要强制更新
                if (localVersionData.resourceVersion < vData.leastResourceVersion)
                {
                    //更新资源选择,这里是在游戏内,必须弹窗确认
                    showAlert(Alert_GetNewResourceMust, () =>
                    {
                        doHotFix(sData);
                    }, exitGame);
                }
                else
                {
                    //更新资源选择,这里是在游戏内,必须弹窗确认
                    showAlert(Alert_GetNewResource, () => { doHotFix(sData); }, () =>
                    {
                        if (GameC.main != null)
                        {
                            GameC.main.hotfixOver();
                        }
                    });
                }
            }
        });
    }
示例#12
0
    //steps

    protected virtual void stepLoadBundleInfo()
    {
        if (ShineSetting.localLoadWithOutBundle)
        {
            //直接标记完成
            LoadControl.registBundleOver();
            _stepTool.completeStep(LoadBundleInfo);
        }
        else
        {
            ResourceInfoControl.loadBundleInfo(() => { _stepTool.completeStep(LoadBundleInfo); });
        }
    }
示例#13
0
    /** 同步加载全部配置(Editor用)(场景编辑器) */
    public void loadSyncForEditorAll()
    {
        string path = ResourceInfoControl.getStreamingAssetsPath(ShineGlobal.configPath, false);

        BytesReadStream stream = FileUtils.readFileForBytesReadStream(path);

        if (stream == null)
        {
            Ctrl.throwError("未找到" + ShineGlobal.configPath + ",需要执行configExport");
        }
        else
        {
            afterReadConfig(toRead(stream));
        }
    }
示例#14
0
    protected virtual void stepLoadResource()
    {
        if (ShineSetting.debugJumpResourceVersion || ShineSetting.localLoadWithOutBundle)
        {
            versionUpdateOver();
            return;
        }

        //本地版本数据
        VersionSaveData localVersionData = ResourceInfoControl.getVersion();

        //离线游戏 或 服务器无此版本
        if (_versionData == null)
        {
            Ctrl.log("离线游戏 或 服务器无此版本");

            _versionData                   = new ClientVersionData();
            _versionData.version           = localVersionData.version;
            _versionData.currentAppVersion = localVersionData.appVersion;
            // _versionData.leastAppVersion=localVersionData.currentAppVersion;
            _versionData.currentResourceVersion = localVersionData.resourceVersion;
            // _versionData.leastResourceVersion=localVersionData.leastResourceVersion;

            doVersionNext(true);
            return;
        }

        //最低app版本不足
        if (localVersionData.appVersion < _versionData.leastAppVersion && ShineSetting.isRelease)
        {
            showAlert(Alert_GetNewAppMust, toGetNewApp, exitGame);
            return;
        }

        //有新的app
        if (localVersionData.appVersion < _versionData.currentAppVersion && ShineSetting.isRelease)
        {
            showAlert(Alert_GetNewApp, toGetNewApp, () => { continueCurrentApp(localVersionData); });
            return;
        }

        continueCurrentApp(localVersionData);
    }
示例#15
0
    private void doHotFix(VersionSaveData sData)
    {
        _getVersionSended = false;

        if (GameC.main != null)
        {
            //回到登录界面
            GameC.main.backForHotfix();
        }

        //清空信息
        LoadControl.clearAllResource();
        LoadControl.clearResourceInfo();

        _stepTool.clearStates();
        _stepTool.completeStepPre(UpdateResource);

        ResourceInfoControl.mergeVersion(sData);
        doVersionNext(false);
    }
示例#16
0
        /** 读取bundleInfo */
        private void readLastBundleInfo()
        {
            string bundlePath = getTargetSourcePath() + "/" + ShineGlobal.bundleInfoPath;

            //存在
            if (!File.Exists(bundlePath))
            {
                Ctrl.throwError("请先执行打包!");
            }
            else
            {
                BytesReadStream stream = FileUtils.readFileForBytesReadStream(bundlePath);

                if (!stream.checkVersion(ShineGlobal.bundleInfoVersion))
                {
                    Ctrl.throwError("请先执行打包!");
                    return;
                }

                ResourceInfoControl.readBundleInfo(stream);
            }
        }
示例#17
0
    protected void toLoadGame(bool isForEditor)
    {
        if (ShineSetting.useHotFix)
        {
            if (!ShineSetting.isRelease)
            {
                bool   useRelease = true;
                string dd         = useRelease ? "Release" : "Debug";

                //TODO:临时读取路径
                ShineGlobal.hotfixDllPath = "../../hotfix/Temp/bin/" + dd + "/hotfix.dll";
                // ShineGlobal.hotfixPDBPath="../hotfix/Temp/bin/"+dd+"/hotfix.pdb";
            }

            //android或者本地开启反射
            if (Application.platform == RuntimePlatform.Android || ShineSetting.useReflectDll)
            {
                string mName = isForEditor ? "mainForEditor" : "main";

                string dllPath;

                if (ShineSetting.isRelease)
                {
                    dllPath = ResourceInfoControl.getResourceSavePath(ShineGlobal.hotfixDllPath);
                }
                else
                {
                    dllPath = ResourceInfoControl.getStreamingAssetsPath(ShineGlobal.hotfixDllPath, false);
                }

                MethodInfo method = Assembly.LoadFrom(dllPath).GetType("HGameApp").GetMethod(mName);

                if (method == null)
                {
                    Ctrl.throwError("不能没有入口方法:HGameApp::" + mName);
                    return;
                }

                method.Invoke(null, null);

                if (!isForEditor)
                {
                    _stepTool.completeStep(LoadGame);
                }
            }
            else
            {
                if (isForEditor)
                {
                    byte[] dllBytes = FileUtils.readFileForBytes(ResourceInfoControl.getStreamingAssetsPath(ShineGlobal.hotfixDllPath, false));
                    onLogicDllLoaded(dllBytes, null, isForEditor);
                }
                else
                {
                    _loader = new ShineLoader();
                    _loader.setCompleteCall(() =>
                    {
                        byte[] dllBytes = _loader.getBytes();
                        _loader.unload();

                        onLogicDllLoaded(dllBytes, null, isForEditor);
                        //
                        //					if(!ShineSetting.isRelease)
                        //					{
                        //						_loader.setCompleteCall(()=>
                        //						{
                        //							byte[] pdbBytes=_loader.getWWW().bytes;
                        //							_loader.unload();
                        //
                        //							onLogicDllLoaded(dllBytes,pdbBytes);
                        //						});
                        //
                        //						_loader.loadFromFileWithoutPlatform(MainSetting.logicPDBPath);
                        //					}
                        //					else
                        //					{
                        //						onLogicDllLoaded(dllBytes,null);
                        //					}
                    });

                    //不是发布模式
                    if (ShineSetting.isRelease)
                    {
                        _loader.loadResource(ShineGlobal.hotfixDllPath);
                    }
                    else
                    {
                        _loader.loadStreamingAsset(ShineGlobal.hotfixDllPath);
                    }
                }
            }
        }
        else
        {
            callGAppMain(isForEditor);

            if (!isForEditor)
            {
                _stepTool.completeStep(LoadGame);
            }
        }
    }