|
@@ -37,14 +37,35 @@ namespace GFGGame
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
- public static IEnumerator Download(List<MatchingPhotoWorksData> list)
|
|
|
|
|
|
+ public static IEnumerator Download(List<MatchingPhotoWorksData> list,string targetPath)
|
|
{
|
|
{
|
|
for (int i = 0; i < list.Count; i++)
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
{
|
|
- MatchingPhotoWorksData data = list[i];
|
|
|
|
- if (data == null || data.Ntexture != null) continue;
|
|
|
|
- int count = 0;
|
|
|
|
- yield return DownloadPicture(data, count);
|
|
|
|
|
|
+ List<string> imageList = MatchingCompetitionDataManager.Instance.GetImageFileNames(targetPath);
|
|
|
|
+ string ImageName = list[i].JudgingInfo.WorksId.ToString() + ".jpg";
|
|
|
|
+ //排行榜内图片是否存在本地,否就下载,是就赋值
|
|
|
|
+ if (!MatchingCompetitionDataManager.Instance.RankIdisInLocal(ImageName, imageList))
|
|
|
|
+ {
|
|
|
|
+ MatchingPhotoWorksData data = list[i];
|
|
|
|
+ if (data == null || data.Ntexture != null) continue;
|
|
|
|
+ int count = 0;
|
|
|
|
+ yield return DownloadPicture(data, count, targetPath);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ list[i].Bytes = File.ReadAllBytes((targetPath+ "/" + ImageName));
|
|
|
|
+ list[i].Ntexture = MatchingCompetitionDataManager.Instance.GetTargetImage(ImageName,targetPath);
|
|
|
|
+ yield return null;
|
|
|
|
+ }
|
|
|
|
+ //本地图片是否存在排行榜,否就删除
|
|
|
|
+ foreach (string item in imageList)
|
|
|
|
+ {
|
|
|
|
+ string getImagePath = targetPath +"/"+ list[i].JudgingInfo.WorksId.ToString()+".jpg";
|
|
|
|
+ if (!MatchingCompetitionDataManager.Instance.ImageIdIsInRank(item))
|
|
|
|
+ {
|
|
|
|
+ MatchingCompetitionDataManager.Instance.DeleteImage(getImagePath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
ET.Log.Debug("Download finish!!!");
|
|
ET.Log.Debug("Download finish!!!");
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
@@ -61,15 +82,15 @@ namespace GFGGame
|
|
ET.Log.Debug("Download finish!!!");
|
|
ET.Log.Debug("Download finish!!!");
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
}
|
|
}
|
|
- public static IEnumerator Download(MatchingPhotoWorksData list)
|
|
|
|
|
|
+ public static IEnumerator Download(MatchingPhotoWorksData list, string targetPath)
|
|
{
|
|
{
|
|
MatchingPhotoWorksData data = list;
|
|
MatchingPhotoWorksData data = list;
|
|
- yield return DownloadPicture(data, 1);
|
|
|
|
|
|
+ yield return DownloadPicture(data, 1,targetPath);
|
|
ET.Log.Debug("Download finish!!!");
|
|
ET.Log.Debug("Download finish!!!");
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
}
|
|
}
|
|
|
|
|
|
- private static IEnumerator DownloadPicture(MatchingPhotoWorksData data, int count)
|
|
|
|
|
|
+ private static IEnumerator DownloadPicture(MatchingPhotoWorksData data, int count,string targetPath)
|
|
{
|
|
{
|
|
if (count >= 3)
|
|
if (count >= 3)
|
|
{
|
|
{
|
|
@@ -86,13 +107,14 @@ namespace GFGGame
|
|
{
|
|
{
|
|
ET.Log.Error("Download failed, error code:" + request.result, ",data:" + JsonUtility.ToJson(data));
|
|
ET.Log.Error("Download failed, error code:" + request.result, ",data:" + JsonUtility.ToJson(data));
|
|
count += 1;
|
|
count += 1;
|
|
- yield return DownloadPicture(data, count);
|
|
|
|
|
|
+ yield return DownloadPicture(data, count, targetPath);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
data.Ntexture = new NTexture(texture);
|
|
data.Ntexture = new NTexture(texture);
|
|
data.Bytes = texture.EncodeToJPG();
|
|
data.Bytes = texture.EncodeToJPG();
|
|
|
|
+ MatchingCompetitionDataManager.Instance.DownloadImageToLocal(data.Bytes,data.JudgingInfo.WorksId,targetPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -120,18 +142,18 @@ namespace GFGGame
|
|
Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
data.Ntexture = new NTexture(texture);
|
|
data.Ntexture = new NTexture(texture);
|
|
data.Bytes = texture.EncodeToJPG();
|
|
data.Bytes = texture.EncodeToJPG();
|
|
- }
|
|
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public static IEnumerator DownloadMyself(string nTextture)
|
|
|
|
|
|
+ public static IEnumerator DownloadMyself(string nTextture,string targetPath)
|
|
{
|
|
{
|
|
- yield return DownloadMyPicture(nTextture, 1);
|
|
|
|
|
|
+ yield return DownloadMyPicture(nTextture, 1,targetPath);
|
|
ET.Log.Debug("Download finish!!!");
|
|
ET.Log.Debug("Download finish!!!");
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
EventAgent.DispatchEvent(ConstMessage.DOWNLOAD_FINISH);
|
|
}
|
|
}
|
|
|
|
|
|
- private static IEnumerator DownloadMyPicture(string nTextture, int count)
|
|
|
|
|
|
+ private static IEnumerator DownloadMyPicture(string nTextture, int count,string targetPath)
|
|
{
|
|
{
|
|
if (count >= 3)
|
|
if (count >= 3)
|
|
{
|
|
{
|
|
@@ -145,13 +167,14 @@ namespace GFGGame
|
|
if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
|
|
if (request.result == UnityWebRequest.Result.ProtocolError || request.result == UnityWebRequest.Result.ConnectionError)
|
|
{
|
|
{
|
|
count += 1;
|
|
count += 1;
|
|
- yield return DownloadMyPicture(nTextture, count);
|
|
|
|
|
|
+ yield return DownloadMyPicture(nTextture, count,targetPath);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
Texture2D texture = (request.downloadHandler as DownloadHandlerTexture).texture;
|
|
MatchingCompetitionDataManager.Instance.MyNtextture = new NTexture(texture);
|
|
MatchingCompetitionDataManager.Instance.MyNtextture = new NTexture(texture);
|
|
MatchingCompetitionDataManager.Instance.MyBytes = texture.EncodeToJPG();
|
|
MatchingCompetitionDataManager.Instance.MyBytes = texture.EncodeToJPG();
|
|
|
|
+ //MatchingCompetitionDataManager.Instance.DownloadImageToLocal(MatchingCompetitionDataManager.Instance.MyBytes, MatchingCompetitionDataManager.Instance.WorksID,targetPath);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|