示例#1
0
        void OpenNewClientUrl()
        {
            string url = _versionUrl + "?channlname=" + ILRuntimeHelper.GetChannelName();

            Application.OpenURL(url);
        }
示例#2
0
        void DownloadPatchConfig()
        {
            string url      = _patchUrl + "patchs.txt";
            string savepath = Application.persistentDataPath + "/patchs.txt";

            Downloader.DownloadFiles(new List <DownloadFile>()
            {
                new DownloadFile(url, savepath)
            },
                                     (arg) =>
            {
                if (!File.Exists(savepath))
                {
                    object[] obj = new object[2];
                    obj[0]       = 50000;
                    obj[1]       = _versionUpdateTips;
                    _currentProgress.TotalSize = 50000;
                    ChangeCurrentUpdateState(UpdateState.DownloadNewClient, false, obj);
                }
                else
                {
                    string str         = File.ReadAllText(savepath);
                    bool find          = false;
                    int totalSize      = 50000;
                    PatchConfig config = JsonMapper.ToObject <PatchConfig>(str);
                    if (_targetVersion == (int)GetVersionValue(config.newVersion))
                    {
                        string channelName = ILRuntimeHelper.GetChannelName();
                        for (int i = 0; i < config.channels.Count; ++i)
                        {
                            var channel = config.channels[i];
                            if (channelName == channel.name)
                            {
                                totalSize  = channel.size_mini;
                                _targetMd5 = GameClient.Instance.BuildSettings.MiniBuild ? channel.md5_mini : channel.md5_all;
                                for (int j = 0; j < channel.patchs.Count; ++j)
                                {
                                    var patch = channel.patchs[j];
                                    if (ResourceManager.CodeVersion == GetVersionValue(patch.oldVersion))
                                    {
                                        string md5 = FileHelper.GetFileMd5(Application.dataPath);
                                        if ((GameClient.Instance.BuildSettings.MiniBuild && md5 == patch.oldmd5_mini) || (!GameClient.Instance.BuildSettings.MiniBuild && md5 == patch.oldmd5_all))
                                        {
                                            _patchFileUrl = GameClient.Instance.BuildSettings.MiniBuild ? _patchUrl + patch.patch_mini : _patchUrl + patch.patch_all;
                                            totalSize     = GameClient.Instance.BuildSettings.MiniBuild ? patch.size_mini : patch.size_all;
                                            find          = true;
                                        }

                                        break;
                                    }
                                }

                                if (find)
                                {
                                    break;
                                }
                            }
                        }
                    }

                    File.Delete(savepath);
                    _currentProgress.TotalSize = totalSize;
                    if (find)
                    {
                        object[] obj = new object[2];
                        obj[0]       = totalSize;
                        obj[1]       = _versionUpdateTips;
                        ChangeCurrentUpdateState(UpdateState.DownloadNewClientPatch, false, obj);
                    }
                    else
                    {
                        object[] obj = new object[2];
                        obj[0]       = totalSize;
                        obj[1]       = _versionUpdateTips;
                        ChangeCurrentUpdateState(UpdateState.DownloadNewClient, false, obj);
                    }
                }
            });
        }
示例#3
0
        void DownloadGateway()
        {
            GameClient.Instance.ips.Clear();
            GameClient.Instance.ports.Clear();
#if UNITY_EDITOR
            if (File.Exists(Application.dataPath + "/../gateway.txt"))
            {
                string   str  = File.ReadAllText(Application.dataPath + "/../gateway.txt");
                string[] strs = str.Split(' ');
                GameClient.Instance.ips.Add(strs[0]);
                GameClient.Instance.ports.Add(int.Parse(strs[1]));
            }
            ChangeCurrentUpdateState(UpdateState.UpdateFinish);
#else
#if ILRUNTIME_DEBUG && UNITY_STANDALONE_WIN
            if (ResourceManager.IsILRuntimeDebug)
            {
                if (File.Exists(Application.dataPath + "/gateway.txt"))
                {
                    string   str  = File.ReadAllText(Application.dataPath + "/gateway.txt");
                    string[] strs = str.Split(' ');
                    GameClient.Instance.ips.Add(strs[0]);
                    GameClient.Instance.ports.Add(int.Parse(strs[1]));
                }
                ChangeCurrentUpdateState(UpdateState.UpdateFinish);
            }
            else
            {
#endif
            string url = ILRuntimeHelper.GetGatewayUrl();
            Debugger.Log("gateway url : " + url, true);
            string savepath = Application.persistentDataPath + "/gateway.txt";
            Downloader.DownloadFiles(new List <DownloadFile>()
            {
                new DownloadFile(url, savepath)
            },
                                     (obj) =>
            {
                if (!File.Exists(savepath))
                {
                    Debugger.LogError("DownloadGateway  0");
                    _onShowUpdateStepFail(0);
                    return;
                }

                string json = File.ReadAllText(savepath);
                GatewayConfig gatewayConfig = JsonMapper.ToObject <GatewayConfig>(json);
                _resourceUpdateTips         = gatewayConfig.resourceTips;
                _versionUpdateTips          = gatewayConfig.versionTips;
                _versionUrl = gatewayConfig.versionUrl;
                _patchUrl   = gatewayConfig.patchUrl;
                Debugger.Log("vesion url : " + _versionUrl, true);
                Debugger.Log("patch url : " + _patchUrl, true);
                string version     = ResourceManager.CodeVersion.ToString();
                string channelName = ILRuntimeHelper.GetChannelName();
                bool find          = false;
                for (int i = 0; i < gatewayConfig.gameVersions.Count; ++i)
                {
                    if (gatewayConfig.gameVersions[i].version == version)
                    {
                        for (int j = 0; j < gatewayConfig.gameVersions[i].channels.Count; ++j)
                        {
                            var channel = gatewayConfig.gameVersions[i].channels[j];
                            if (channel.channelName == channelName)
                            {
                                GameClient.Instance.isShenHe = channel.isShenHe;
                                ResourceManager.ResourceUrl  = channel.resourceUrl;
                                Debugger.Log("resource url : " + ResourceManager.ResourceUrl, true);
                                GameClient.Instance.ips.AddRange(channel.ips);
                                GameClient.Instance.ports.AddRange(channel.ports);
                                find = true;
                                break;
                            }
                        }
                    }
                }
                if (!find)
                {
                    _onShowUpdateStepFail(1);
                    return;
                }

                File.Delete(savepath);

                if (GameClient.Instance.isShenHe && !GameClient.Instance.BuildSettings.MiniBuild)
                {
                    ChangeCurrentUpdateState(UpdateState.UpdateFinish);
                }
                else
                {
                    ChangeCurrentUpdateState(UpdateState.ComparServerVersion);
                }
            });
#if ILRUNTIME_DEBUG && UNITY_STANDALONE_WIN
        }
#endif
#endif
        }