예제 #1
0
    public static string GetServerGameResPath(DownLoadFileInfo info)
    {
        string path = Path.Combine(ServerGameResAndroidPath, ResDirectoryName, info.GameName, info.fileName);

        path = path.Replace("\\", "/");
        return(path);
    }
예제 #2
0
    private void InitGameResFileInfo()
    {
        StreamReader streamReader = new StreamReader(Path.Combine(URLFactory.DownLoadHotFilePath, "AssetList.txt"));
        string       str          = null;

        while (!streamReader.EndOfStream)
        {
            str = streamReader.ReadLine();
            if (str.Contains("//"))
            {
                continue;
            }
            if (str.Contains("ApplicationVersion"))
            {
                URLFactory.NewAppVersion = str.Split('~')[0];
                continue;
            }
            else if (str.Contains("ApkUrl"))
            {
                URLFactory.NewAppVersion = str.Split('~')[0];
                continue;
            }
            DownLoadFileInfo info = new DownLoadFileInfo(str);
            if (info.IsInvalid)
            {
                continue;
            }
            if (!_gameResfileInfoDict.ContainsKey(info.GameName))
            {
                _gameResfileInfoDict[info.GameName] = new GameResFileInfo(info.GameName);
            }
            _gameResfileInfoDict[info.GameName].AddFileInfo(info);
        }
        streamReader.Close();

        foreach (string gameName in _gameResfileInfoDict.Keys)
        {
            GameVersionState state = GetGameResVersionState(gameName);
            _gameVersionStateDict[gameName] = state;
        }
        IsInited = true;
    }
예제 #3
0
    public void StartDownLoad(DownLoadFileInfo info)
    {
        if (IsDownLoading)
        {
            return;
        }
        Init();
        CurDownLoadFileInfo = info;
        Progress            = 0;
        IsDone        = false;
        IsDownLoading = true;
        string serverGameResPath = URLFactory.GetServerGameResPath(info);
        string localSavePath     = URLFactory.GetLocalGameResSavePath(info);

        if (File.Exists(localSavePath))
        {
            File.Delete(localSavePath);
        }
        _myWebClient.DownloadFileAsync(new Uri(serverGameResPath), localSavePath);
    }
예제 #4
0
    public static GameVersionState CheckOnceFileInfo(DownLoadFileInfo info)
    {
        int    gameServerVersion = info.version;
        string localTagPath      = URLFactory.GetLocalGameTagPath(info);

        if (File.Exists(localTagPath))
        {
            StreamReader streamReader = new StreamReader(localTagPath);
            string       versionStr   = streamReader.ReadToEnd();
            streamReader.Close();
            int versioni;
            if (int.TryParse(versionStr, out versioni))
            {
                if (versioni >= gameServerVersion)
                {
                    return(GameVersionState.NewestVersion);
                }
                return(GameVersionState.OldVersion);
            }
        }
        return(GameVersionState.UnLoad);
    }
예제 #5
0
 public void AddFileInfo(DownLoadFileInfo info)
 {
     infoList.Add(info);
 }
예제 #6
0
    /// <summary>
    /// 获取本地标记文件全路径
    /// </summary>
    /// <param name="info"></param>
    /// <returns></returns>
    public static string GetLocalGameTagPath(DownLoadFileInfo info)
    {
        string folderPath = GetLocalGameTagFolder(info.GameName);

        return(Path.Combine(folderPath, info.fileName + ".txt"));
    }
예제 #7
0
    /// <summary>
    /// 获取本地资源文件全路径
    /// </summary>
    /// <param name="info"></param>
    /// <returns></returns>
    public static string GetLocalGameResSavePath(DownLoadFileInfo info)
    {
        string folderPath = GetLocalGameResSaveFolder(info.GameName);

        return(Path.Combine(folderPath, info.fileName));
    }