Commit aa0acd55 authored by JiangWanZhi's avatar JiangWanZhi

解压文件出来的地方改个位置

parent a0171998
......@@ -523,22 +523,25 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
if (utilsTools.IsWin == true)
zpath = zpath.Replace("/", "\\");
gameScenUser.createWorkDirectory();
string outPath = GameScenUserInfo.getAllRoot();
if(utilsTools.IsWin == true)
{
outPath = outPath.Replace("/", "\\");
}
if (utilsTools.IsExistIO(gameScenUser.getColorImgLocalPath()) == false)
string outPath = Application.persistentDataPath + $"/Test_MyPic/{gameScenUser.id}";//GameScenUserInfo.getAllRoot(); //这里记得后面Test_MyPic改成MyPic
if (!Directory.Exists(outPath)) //没有这个路径说明是第一次下载解压的
{
Directory.CreateDirectory(outPath);
if (utilsTools.IsWin == true)
{
outPath = outPath.Replace("/", "\\");
}
utilsTools.setGDataByKey("beginUnZip", utilsTools.getTotalMillisecond());
ZipUtility.UnzipFile(zpath, outPath, "tuse" + gameScenUser.id);
utilsTools.setGDataByKey("endUnZip", utilsTools.getTotalMillisecond());
}
utilsTools.setGDataByKey(EventName.DataName.Data_nowSelectUseData, gameScenUser);
string lineImg = gameScenUser.getLineImgLocalPath();
utilsTools.setGDataByKey("downGaoQing", utilsTools.getTotalMillisecond());
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange, 0.3f); //解压完成,或者原先本地就有了,开始加载本地文件,这儿给个0.3f
gameShowView.GetComponent<mainGameView>().loadGameImgId();
}
......@@ -592,11 +595,14 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
{
if (isOk)
{
utilsTools.addTimer_Update(gameObject, "unZipNext", (String _) =>{
utilsTools.setGDataByKey("downZipEnd", utilsTools.getTotalMillisecond());
onZipFileHandler(gameScenUser);
return false;
});
//utilsTools.addTimer_Update(gameObject, "unZipNext", (String _) =>{
// utilsTools.setGDataByKey("downZipEnd", utilsTools.getTotalMillisecond());
// onZipFileHandler(gameScenUser);
// return false;
//});
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange, 0.2f); //下载完成,这儿给个0.2f
onZipFileHandler(gameScenUser);
}
}));
}
......@@ -608,12 +614,9 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
}
IEnumerator LoadAndBytesUnzipWithWeb(string url, string exportPath,NotifyBoolParam back)
{
Debug.Log("exportPath : " + exportPath);
using (UnityWebRequest uwr = UnityWebRequest.Get(url))
{
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange,0.2f); //开始下载,进度条这儿给个0.1
yield return uwr.SendWebRequest();
if (uwr.isHttpError == true || uwr.isNetworkError == true)
{
......@@ -625,9 +628,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
var data = uwr.downloadHandler.data;
File.WriteAllBytes(exportPath, data);
back(true);
// 酌情使用即可
//File.Delete(zipPath);
//Directory.Delete(exportPath, true);
}
}
}
......
......@@ -7,7 +7,6 @@ using UnityEngine.UI;
using System.Linq;
using DG.Tweening;
using TMPro;
using UnityEditor.ShaderGraph;
public class GroupListManager : MonoBehaviour
{
......
......@@ -777,7 +777,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
}
public virtual bool loadGameImgId(GameScenUserInfo gameUserInfo)
{
Debug.Log($"11111 加载图片{gameUserInfo.id}");
string linePath = gameUserInfo.getLineImgLocalPath();
string colorPath = gameUserInfo.getColorImgLocalPath();
string jsonPath = gameUserInfo.getJsonLocalPath();
......@@ -801,29 +800,21 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
utilsTools.setGDataByKey("loadBinBegin", utilsTools.getTotalMillisecond());
TaskManages.getInstance().insertTask(this, (System.Object[] _) =>
{
string binpath = colorPath.Substring(0, linePath.Length - 4) + ".bin";
if (utilsTools.IsWin == true)
{
binpath = binpath.Replace("/", "\\");
}
//string binpath = colorPath.Substring(0, linePath.Length - 4) + ".bin";
//if (utilsTools.IsWin == true)
//{
// binpath = binpath.Replace("/", "\\");
//}
Byte[] bytes = System.IO.File.ReadAllBytes(binpath);
bytesInitDigitMatrix(bytes);
//Byte[] bytes = System.IO.File.ReadAllBytes(binpath);
//bytesInitDigitMatrix(bytes);
Debug.Log("bin初始化完成--------------");
});
//utilsTools.setGDataByKey("loadBinEnd", utilsTools.getTotalMillisecond());
//utilsTools.setGDataByKey("downJson", utilsTools.getTotalMillisecond());
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange); //开始加载本地文件
string dicpath = Application.persistentDataPath + $"/MyPic/{gameUserInfo.id}";
CurPicName = gameUserInfo.id;
Debug.Log($"11111 本地位置{dicpath}");
if (!Directory.Exists(dicpath))
{
Directory.CreateDirectory(dicpath);
}
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange);
//loadFileInfo(gameUserInfo.json, jsonPath, 3, gameUserInfo.id);
////utilsTools.setGDataByKey("loadGaoQing", utilsTools.getTotalMillisecond());
......@@ -1769,7 +1760,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
public void StartGame()
{
Debug.Log("11111 StartGame");
GameMgr obj = Resources.Load<GameMgr>("perfabs/GameMgr");
GameMgr item = Instantiate<GameMgr>(obj);
......@@ -1778,7 +1768,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
item.transform.localRotation = Quaternion.Euler(0, 0, 0);
item.transform.localScale= Vector3.one;
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange); //开始初始化
string path = Application.persistentDataPath + $"/MyPic/{CurPicName}/";
StartCoroutine(LoadPic(path, $"{CurPicName}", item));
......@@ -1786,14 +1775,13 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
IEnumerator LoadPic(string dirpath,string name, GameMgr item)
{
Texture2D png=null;
Sprite jpg=null;
Texture2D png = null;
Sprite jpg = null;
Texture2D jpg_texture = null;
string pngpath = dirpath+$"{name}_png.png";
string jpgpath = dirpath + $"{name}_jpg.jpg";
string loadpath = "";
Debug.Log($"11111 金加载图片");
bool localflag = false;
if (File.Exists(pngpath)) //有保存过图片
{
......@@ -1813,7 +1801,10 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
}
else
{
png = Resources.Load<Texture2D>("cc2D9Z2w9k0evqUiCQ/png");
string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_png.png";
WWW www = new WWW(path);
yield return www;
png = www.texture;
}
......@@ -1835,87 +1826,57 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
}
else
{
jpg_texture = Resources.Load<Texture2D>("cc2D9Z2w9k0evqUiCQ/jpg");
//jpg = Sprite.Create(jpg_texture, new Rect(0, 0, jpg_texture.width, jpg_texture.height), new Vector2(0.5f, 0.5f));
string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_jpg.jpg";
WWW www = new WWW(path);
yield return www;
jpg_texture = www.texture;
}
string binlocalpath = Application.persistentDataPath + $"/MyPic/{name}/{name}_json.bin";
Debug.Log($"11111 不在 {binlocalpath}");
ResJsonData jsondata = null;
if (!File.Exists(binlocalpath))
{
Debug.Log($"11111 0000");
string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_json.bin";
Debug.Log($"11111 -----");
//#if UNITY_ANDROID
// path = "file://" + path;
//#endif
WWW www = new WWW(path);
Debug.Log($"11111 {path}");
while (!www.isDone)
{
}
Debug.Log($"11111 222");
MemoryStream stream = new MemoryStream(www.bytes);
//二进制反序列化
Debug.Log($"11111 3333");
BinaryFormatter bf = new BinaryFormatter();
Debug.Log($"11111 444");
jsondata = (ResJsonData)bf.Deserialize(stream);
Debug.Log($"11111 555 {jsondata.allPos.Count}");
}
else
{
Debug.Log($"11111 在");
jsondata = getdata("cc2D9Z2w9k0evqUiCQ");
}
string bindynamiclocalpath = Application.persistentDataPath + $"/MyPic/{name}/{name}_dynamic.bin";
Debug.Log($"11111 不在 {binlocalpath}");
DynamicData dynamic = null;
if (!File.Exists(bindynamiclocalpath))
{
Debug.Log($"11111 0000");
string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_dynamic.bin";
Debug.Log($"11111 -----");
//#if UNITY_ANDROID
// path = "file://" + path;
//#endif
WWW www = new WWW(path);
Debug.Log($"11111 {path}");
while (!www.isDone)
{
}
Debug.Log($"11111 222");
MemoryStream stream = new MemoryStream(www.bytes);
//二进制反序列化
Debug.Log($"11111 3333");
BinaryFormatter bf = new BinaryFormatter();
Debug.Log($"11111 444");
dynamic = (DynamicData)bf.Deserialize(stream);
Debug.Log($"11111 555 {dynamic.step.Count}");
}
else
{
Debug.Log($"11111 在");
dynamic = getdynamicdata("cc2D9Z2w9k0evqUiCQ");
}
if (localflag) //加载本地的到这里就回去了,下面是第一次
if (localflag) //加载本地的到这里就回去了,下面是加载工程;里面的后续跑的
{
Debug.Log($"111111 11初始化");
item.Init("cc2D9Z2w9k0evqUiCQ", png, jpg, jsondata, dynamic);
yield break;
}
Debug.Log($"11111 开始保存");
SaveManager.Instance.SaveRes("cc2D9Z2w9k0evqUiCQ", dynamic, png);
SaveManager.Instance.SaveJPG("cc2D9Z2w9k0evqUiCQ", jpg_texture);
SaveManager.Instance.SaveJson("cc2D9Z2w9k0evqUiCQ", jsondata);
......@@ -1924,15 +1885,9 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
{
yield return null;
}
Debug.Log($"11111 保存完成");
//UnityWebRequest request = UnityWebRequestTexture.GetTexture(pngpath);
//yield return request.SendWebRequest();
//Debug.Log($"11111 Png图 {pngpath} done {request.isDone} error{request.error}");
//if (request.isDone)
//{
// png = DownloadHandlerTexture.GetContent(request);
//}
//加载本地的
loadpath = pngpath;
#if UNITY_ANDROID
loadpath = "file://" + pngpath;
......@@ -1955,19 +1910,7 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
jpg_texture = www_jpg.texture;
jpg = Sprite.Create(jpg_texture, new Rect(0, 0, jpg_texture.width, jpg_texture.height), new Vector2(0.5f, 0.5f));
}
//request = UnityWebRequestTexture.GetTexture(jpgpath);
//yield return request.SendWebRequest();
//Debug.Log($"11111 jpg图 {jpgpath} done {request.isDone} error{request.error}");
//if (request.isDone)
//{
// jpg_texture = DownloadHandlerTexture.GetContent(request);
// jpg = Sprite.Create(jpg_texture, new Rect(0, 0, jpg_texture.width, jpg_texture.height), new Vector2(0.5f, 0.5f));
//}
jsondata = getdata("cc2D9Z2w9k0evqUiCQ");
Debug.Log($"11111 开始初始化{jsondata.allPos.Count}");
item.Init("cc2D9Z2w9k0evqUiCQ", png, jpg, jsondata, dynamic);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment