Ejemplo n.º 1
0
        /// <summary>
        /// 重新检查程序版本号
        /// </summary>
        public static void RecheckAppVersion(Action <int> checkComplated)
        {
            string localVersion = FileUtility.ReadFileText(VERSION_FILENAME, PathType.Local);
            Action <string, AsyncCompletedEventArgs> complated = (fileName, e) =>
            {
                if (fileName != VERSION_FILENAME)
                {
                    return;
                }

                string remoteVersion = localVersion;
                if (e.Error != null)
                {
                    Debug.LogErrorFormat("load remote version error:[{0}]", e.Error.Message);
                    remoteVersion = localVersion;
                }
                else if (!e.Cancelled)
                {
                    remoteVersion = FileUtility.ReadFileText(VERSION_FILENAME, PathType.Cache);
                }
                if (checkComplated != null)
                {
                    checkComplated(CheckVersion(remoteVersion, localVersion));
                }
            };

            WebClientDownloader.AppendDownloadFile(VERSION_FILENAME, complated, null);
        }
Ejemplo n.º 2
0
        void DownloadAssetFile_Complated(string fileName, AsyncCompletedEventArgs e)
        {
            FileRecord record = m_NeedUpdateFileRecords.Find(temp => temp.FileName == fileName);

            if (record == null)
            {
                return;
            }

            if (e.Error != null)
            {
                Debug.LogErrorFormat("download remote file:[{0}] error[{1}]", fileName, e.Error.Message);
                WebClientDownloader.StopDownloader();
                HotfixUpdaterSwitchToFaildState(true);
            }
            else if (e.Cancelled)
            {
                HotfixUpdaterSwitchToFaildState(true);
            }
            else
            {
                m_NeedUpdateFileRecords.Remove(record);

                if (FileUtility.CopyFileByPathType(record.FileName, PathType.Cache, PathType.Local))
                {
                    complatedFileRecords.Enqueue(record);
                }
                int complatedCount = m_NeedDownCount - m_NeedUpdateFileRecords.Count;
                NotifyHotFixUpdateProgressChanged(string.Format("下载更新({0}/{1})", complatedCount, m_NeedDownCount), complatedCount * 100f / m_NeedDownCount);
                if (m_NeedUpdateFileRecords.Count == 0)
                {
                    DownloadComplatedRestore();
                    // 下载完成了
                    FileUtility.CopyFileByPathType(VERSION_FILENAME, PathType.Cache, PathType.Local);
                    HotfixUpdaterSwitchToState(HotFixUpdaterState.ClearObsoleteAssets);
                }
                else if (complatedFileRecords.Count >= ComplatedDownloadSaveCount)
                {
                    DownloadComplatedRestore();
                }
            }
        }
Ejemplo n.º 3
0
 void StartDownLoadRemoteUpdatedAssets()
 {
     m_NeedUpdateFileRecords = FilterNeedUpdateFileRecodes(m_RemoteFileRecords, m_LocalFileRecords);
     if (m_NeedUpdateFileRecords.Count > 0)
     {
         m_NeedDownCount = m_NeedUpdateFileRecords.Count;
         for (int i = m_NeedUpdateFileRecords.Count - 1; i >= 0; i--)
         {
             FileRecord record = m_NeedUpdateFileRecords[i];
             WebClientDownloader.AppendDownloadFile(record.FileName, DownloadAssetFile_Complated, null);
         }
         IsLoadedNewAsset = true;
     }
     else
     {
         // 拷贝远程版本号到本地
         FileUtility.CopyFileByPathType(VERSION_FILENAME, PathType.Cache, PathType.Local);
         HotfixUpdaterSwitchToState(HotFixUpdaterState.ValidateLocalData);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 开始加载远程的列表文件
 /// </summary>
 void StartLoadRemoteRecordFile()
 {
     WebClientDownloader.AppendDownloadFile(FILERECORD_FILENAME, DownLoadFileRecords_Complated, null);
 }
Ejemplo n.º 5
0
 public void StartLoadRemoteVersionFile()
 {
     WebClientDownloader.AppendDownloadFile(VERSION_FILENAME, DownLoadVersionFile_Complated, null);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 游戏退出接口
 /// </summary>
 private void OnApplicationQuit()
 {
     StopAllCoroutines();
     WebClientDownloader.StopDownloader();
 }