Browse Source

删除无用Utility。Command、Event,修改命令、事件

蓝色星空 1 year ago
parent
commit
8efc854607
30 changed files with 239 additions and 315 deletions
  1. 6 0
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs
  2. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs.meta
  3. 0 6
      Assets/Scripts/Blue/0.FrameworkDesign/Core/ICanInject.cs
  4. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IController.cs
  5. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IModel.cs
  6. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IService.cs
  7. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/Core/IUtility.cs
  8. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectRuleAttribute.cs
  9. 1 1
      Assets/Scripts/Blue/0.FrameworkDesign/IOC/TypeChecker.cs
  10. 0 24
      Assets/Scripts/Blue/Command/DownloadFileCommand.cs
  11. 0 15
      Assets/Scripts/Blue/Command/GetPointPosSuccessCommand.cs
  12. 0 15
      Assets/Scripts/Blue/Command/LoadMapFileCommand.cs
  13. 46 0
      Assets/Scripts/Blue/Command/PointFileGetUrlCommand.cs
  14. 1 1
      Assets/Scripts/Blue/Command/PointFileGetUrlCommand.cs.meta
  15. 0 97
      Assets/Scripts/Blue/Controller/DownloadPointFile.cs
  16. 0 11
      Assets/Scripts/Blue/Controller/DownloadPointFile.cs.meta
  17. 0 38
      Assets/Scripts/Blue/Controller/PointCouldAutoMatchController.cs
  18. 0 11
      Assets/Scripts/Blue/Controller/PointCouldAutoMatchController.cs.meta
  19. 0 8
      Assets/Scripts/Blue/Event/DownLoadMapFileEvent.cs
  20. 0 11
      Assets/Scripts/Blue/Event/DownLoadMapFileEvent.cs.meta
  21. 0 7
      Assets/Scripts/Blue/Event/GetPointPosSuccessEvent.cs
  22. 0 11
      Assets/Scripts/Blue/Event/GetPointPosSuccessEvent.cs.meta
  23. 5 0
      Assets/Scripts/Blue/Other/PointFileType.cs
  24. 1 1
      Assets/Scripts/Blue/Other/PointFileType.cs.meta
  25. 140 0
      Assets/Scripts/Blue/Service/IPointService.cs
  26. 0 37
      Assets/Scripts/Blue/Utility/GetAngleByTwoPointUtility.cs
  27. 0 11
      Assets/Scripts/Blue/Utility/GetAngleByTwoPointUtility.cs.meta
  28. 29 0
      Assets/Scripts/Blue/Utility/UnityWebRequestUtility.cs
  29. 1 1
      Assets/Scripts/Blue/Utility/UnityWebRequestUtility.cs.meta
  30. 3 3
      ProjectSettings/ProjectSettings.asset

+ 6 - 0
Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs

@@ -0,0 +1,6 @@
+namespace Blue
+{
+    public interface IAuto
+    {
+    }
+}

+ 1 - 1
Assets/Scripts/Blue/Command/GetPointPosSuccessCommand.cs.meta → Assets/Scripts/Blue/0.FrameworkDesign/Core/IAuto.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: bd2c31772b1bce743af3ad289d8f0cc5
+guid: 3c1cdcc8388923a449c35bd3adcb8fcf
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 6
Assets/Scripts/Blue/0.FrameworkDesign/Core/ICanInject.cs

@@ -1,6 +0,0 @@
-namespace Blue
-{
-    public interface ICanInject
-    {
-    }
-}

+ 1 - 1
Assets/Scripts/Blue/0.FrameworkDesign/Core/IController.cs

@@ -3,7 +3,7 @@ namespace Blue
     /// <summary>
     /// Controller 层接口
     /// </summary>
-    public interface IController :ICanInject,ICanGetService,ICanGetModel,ICanGetUtility,ICanSendCommand,ICanSubscribeEvent,ICanSendQuery
+    public interface IController :IAuto,ICanGetService,ICanGetModel,ICanGetUtility,ICanSendCommand,ICanSubscribeEvent,ICanSendQuery
     {
     }
 }

+ 1 - 1
Assets/Scripts/Blue/0.FrameworkDesign/Core/IModel.cs

@@ -3,7 +3,7 @@ namespace Blue
     /// <summary>
     /// Model 层接口
     /// </summary>
-    public interface IModel:ICanInject,ICanGetUtility,ICanTriggerEvent
+    public interface IModel:IAuto,ICanGetUtility,ICanTriggerEvent
     {
         void OnInit();
     }

+ 1 - 1
Assets/Scripts/Blue/0.FrameworkDesign/Core/IService.cs

@@ -3,7 +3,7 @@ namespace Blue
     /// <summary>
     /// Service 层接口
     /// </summary>
-    public interface IService : ICanInject,ICanGetService, ICanSendCommand,ICanGetModel, ICanGetUtility,ICanSubscribeEvent,ICanTriggerEvent,ICanSendQuery
+    public interface IService : IAuto,ICanGetService, ICanSendCommand,ICanGetModel, ICanGetUtility,ICanSubscribeEvent,ICanTriggerEvent,ICanSendQuery
     {
         void OnInit();
     }

+ 1 - 1
Assets/Scripts/Blue/0.FrameworkDesign/Core/IUtility.cs

@@ -3,7 +3,7 @@ namespace Blue
     /// <summary>
     /// Utility 层接口
     /// </summary>
-    public interface IUtility:ICanInject,ICanGetUtility
+    public interface IUtility:IAuto,ICanGetUtility
     {
     }
 }

+ 1 - 1
Assets/Scripts/Blue/0.FrameworkDesign/IOC/InjectRuleAttribute.cs

@@ -14,7 +14,7 @@ namespace Blue
         private Type baseInjectType;
         public InjectRuleAttribute(params Type[] canInject)
         {
-            baseInjectType = typeof(ICanInject);
+            baseInjectType = typeof(IAuto);
             canInjectList = new List<Type>(canInject.Length);
             foreach (var item in canInject)
             {

+ 1 - 1
Assets/Scripts/Blue/0.FrameworkDesign/IOC/TypeChecker.cs

@@ -18,7 +18,7 @@ namespace Blue
        // [RequiredMember]
         private TypeChecker()
         {
-            canInjectBaseType = typeof(ICanInject);
+            canInjectBaseType = typeof(IAuto);
             controllerType = typeof(IController);
             modelType = typeof(IModel);
             serviceType = typeof(IService);

+ 0 - 24
Assets/Scripts/Blue/Command/DownloadFileCommand.cs

@@ -1,24 +0,0 @@
-using Blue;
-
-public class DownloadFileCommand : ICommand
-{
-    private string url;
-    private string fileType;
-    private int projectID;
-    public DownloadFileCommand(string url,string fileType,int projectID)
-    {
-        this.url = url;
-        this.fileType = fileType;
-        this.projectID = projectID;
-    }
-
-    public void OnExcute()
-    {
-        this.TriggerEvent<DownLoadMapFileEvent>(new DownLoadMapFileEvent()
-        {
-            Url = url,
-            FileType = fileType,
-            ProjectID = projectID
-        });
-    }
-}

+ 0 - 15
Assets/Scripts/Blue/Command/GetPointPosSuccessCommand.cs

@@ -1,15 +0,0 @@
-using Blue;
-using System.Collections.Generic;
-
-public struct GetPointPosSuccessCommand : ICommand
-{
-    private List<PointJsonInfo> pointPos;
-    public GetPointPosSuccessCommand(List<PointJsonInfo> pointPos)
-    {
-        this.pointPos = pointPos;
-    }
-    public void OnExcute()
-    {
-        this.TriggerEvent<GetPointPosSuccessEvent>(new GetPointPosSuccessEvent() { pointJsonInfos = pointPos });
-    }
-}

+ 0 - 15
Assets/Scripts/Blue/Command/LoadMapFileCommand.cs

@@ -1,15 +0,0 @@
-using Blue;
-
-public class LoadMapFileCommand : ICommand
-{
-    private string mFileName;
-    public LoadMapFileCommand(string fileName)
-    {
-        mFileName = fileName;
-    }
-
-    public void OnExcute()
-    {
-        this.TriggerEvent<LoadMapFileEvent>(new LoadMapFileEvent(){fileName = mFileName});
-    }
-}

+ 46 - 0
Assets/Scripts/Blue/Command/PointFileGetUrlCommand.cs

@@ -0,0 +1,46 @@
+using Blue;
+using Newtonsoft.Json.Linq;
+using Newtonsoft.Json;
+
+/// <summary>
+/// 获取点云文件(json、bytes)的Url下载地址命令
+/// </summary>
+public class PointFileGetUrlCommand : ICommand
+{
+    private string methodName = "/project/pointcloud";
+    private int sceneID;
+    private PointFileType fileType;
+
+    /// <summary>
+    /// 获取点云文件(json、bytes)的Url下载地址命令
+    /// </summary>
+    /// <param name="sceneId">场景ID</param>
+    /// <param name="fileType">文件类型</param>
+    public PointFileGetUrlCommand(int sceneId, PointFileType fileType)
+    {
+        this.sceneID = sceneId;
+        this.fileType = fileType;
+    }
+    public void OnExcute()
+    {
+        this.GetService<IPointService>().GetPointFileDownloadUrl(methodName, sceneID.ToString(), fileType, GetPointFileUrlSuccess);
+    }
+
+    private void GetPointFileUrlSuccess(string message)
+    {
+        if (!string.IsNullOrWhiteSpace(message))
+        {
+            JObject jobject = JObject.Parse(message);
+            if (jobject["code"].ToString() == "200")
+            {
+                message = jobject["data"].ToString();
+                if (!string.IsNullOrWhiteSpace(message))
+                {
+                    PointFileData PointFile = JsonConvert.DeserializeObject<PointFileData>(message);
+
+                    this.GetService<IPointService>().DownloadPointFile(PointFile.url, fileType);
+                }
+            }
+        }
+    }
+}

+ 1 - 1
Assets/Scripts/Blue/0.FrameworkDesign/Core/ICanInject.cs.meta → Assets/Scripts/Blue/Command/PointFileGetUrlCommand.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 52f5dfcb6f5a29a4b9f316ab29445925
+guid: 1d8c533c14e76b34c97f35b6cafeb6ab
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 0 - 97
Assets/Scripts/Blue/Controller/DownloadPointFile.cs

@@ -1,97 +0,0 @@
-using System.Collections;
-using System.IO;
-using Blue;
-#if UNITY_EDITOR
-using UnityEditor;
-#endif
-using UnityEngine;
-using UnityEngine.Networking;
-
-public class DownloadPointFile : AbstractController
-{
-    private UnityWebRequest webRequestPointByte;
-    private UnityWebRequest webRequestPointJson;
-    private void Awake()
-    {
-        this.SubscribeEvent<DownLoadMapFileEvent>(Download).UnSubScribeWhenGameObjectDestroyed(gameObject);
-    }
-
-    private void Download(DownLoadMapFileEvent e)
-    {
-        if (e.FileType == "json")
-            StartCoroutine(DownLoadFile(webRequestPointJson, e.Url, "." + e.FileType, e.ProjectID.ToString()));
-        else
-            StartCoroutine(DownLoadFile(webRequestPointByte, e.Url, "." + e.FileType, e.ProjectID.ToString()));
-    }
-    private IEnumerator DownLoadFile(UnityWebRequest webRequestPoint, string downloadingUrl, string fileType, string projectId)
-    {
-        string fileName = this.GetUtility<GetFileNameUtility>().GetFileName(downloadingUrl, fileType);
-
-        if (!PlayerPrefs.HasKey(projectId+ fileType) || 
-            PlayerPrefs.GetString(projectId+ fileType) != fileName||
-            !File.Exists(Application.persistentDataPath + "/Map Data/" + fileName))
-        {
-            PlayerPrefs.SetString(projectId+ fileType, fileName);
-            Debug.LogError("文件不存在,下载文件");
-            //发送请求
-            webRequestPoint = UnityWebRequest.Get(downloadingUrl);
-            webRequestPoint.timeout = 30;//设置超时,若webRequest.SendWebRequest()连接超时会返回,且isNetworkError为true
-            yield return webRequestPoint.SendWebRequest();
-
-            if (webRequestPoint.result == UnityWebRequest.Result.ConnectionError) Debug.Log("Download Point Cloud Error:" + webRequestPoint.error);
-            else
-            {
-                if (Directory.Exists(Application.persistentDataPath + "/Map Data") == false)
-                    Directory.CreateDirectory(Application.persistentDataPath + "/Map Data");
-                if (System.IO.File.Exists(Application.persistentDataPath + "/Map Data/" + fileName))
-                    System.IO.File.Delete(Application.persistentDataPath + "/Map Data/" + fileName);
-                //获取二进制数据
-                var File = webRequestPoint.downloadHandler.data;
-                //创建文件写入对象
-                FileStream nFile = new FileStream(Application.persistentDataPath + "/Map Data/" + fileName, FileMode.Create);
-                //写入数据
-                nFile.Write(File, 0, File.Length);
-                //关闭当前流并释放与之相关联的所有系统资源
-                nFile.Close(); nFile.Dispose(); nFile = null;
-                if (fileType == ".bytes")
-                {
-#if UNITY_EDITOR
-                    AssetDatabase.Refresh();
-#endif
-                    this.SendCommand(new LoadMapFileCommand(fileName) { });
-                }
-            }
-        }
-        else
-        {
-            //Debug.LogError("文件已存在");
-            if (fileType == ".bytes")
-            {
-                this.SendCommand(new LoadMapFileCommand(fileName) { });
-            }
-        }
-    }
-
-    /// <summary>
-    /// 获取下载进度
-    /// </summary>
-    public float GetProcess(UnityWebRequest webRequestPoint)
-    {
-        if (webRequestPoint!=null)
-        {
-            return webRequestPoint.downloadProgress;
-        }
-        return 0;
-    }
-    /// <summary>
-    /// 获取当前下载内容长度
-    /// </summary>
-    public long GetCurrentLength(UnityWebRequest webRequestPoint)
-    {
-        if (webRequestPoint != null)
-        {
-            return (long)webRequestPoint.downloadedBytes;
-        }
-        return 0;
-    }
-}

+ 0 - 11
Assets/Scripts/Blue/Controller/DownloadPointFile.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 5056337c45d1c474596bb345f15bd80d
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 38
Assets/Scripts/Blue/Controller/PointCouldAutoMatchController.cs

@@ -1,38 +0,0 @@
-using Blue;
-using System;
-using UnityEngine;
-
-public class PointCouldAutoMatchController : AbstractController
-{
-    public GameObject AR_Map;
-
-    public Vector2 pos1;
-    public Vector2 pos2;
-
-    public double angle;
-
-    public Vector3 ScenePos1;
-    public Vector3 ScenePos2;
-
-    private void Awake()
-    {
-        this.SubscribeEvent<GetPointPosSuccessEvent>(GetPointPosSuccess);
-    }
-
-    private void GetPointPosSuccess(GetPointPosSuccessEvent e)
-    {
-        // 因为屏幕坐标跟普通坐标不同,所依y为-y
-        angle = this.GetUtility<IGetAngleByTwoPointUtility>().GetAngleByTwoPoint(e.pointJsonInfos[0].x, -e.pointJsonInfos[0].y, e.pointJsonInfos[1].x, -e.pointJsonInfos[1].y);
-        AR_Map.transform.localEulerAngles = new Vector3(0.0f, (float)angle, 0.0f);  //获取角度
-
-        pos1 = new Vector2(e.pointJsonInfos[0].x, e.pointJsonInfos[0].y);
-        pos2 = new Vector2(e.pointJsonInfos[1].x, e.pointJsonInfos[1].y);
-        this.UnSubscribeEvent<GetPointPosSuccessEvent>(GetPointPosSuccess);
-    }
-    public void SetPos(Vector3 pos1, Vector3 pos2)
-    {
-        AR_Map.transform.localPosition = pos1;
-        ScenePos1 = pos1;
-        ScenePos2 = pos2;
-    }
-}

+ 0 - 11
Assets/Scripts/Blue/Controller/PointCouldAutoMatchController.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: dad2dab54d73761498f3cff68b0b30d4
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 8
Assets/Scripts/Blue/Event/DownLoadMapFileEvent.cs

@@ -1,8 +0,0 @@
-using Blue;
-
-public class DownLoadMapFileEvent : IEvent
-{
-    public int ProjectID;
-    public string Url;
-    public string FileType;
-}

+ 0 - 11
Assets/Scripts/Blue/Event/DownLoadMapFileEvent.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: b8c55d97a2e85374da00ebcf3d082afd
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 7
Assets/Scripts/Blue/Event/GetPointPosSuccessEvent.cs

@@ -1,7 +0,0 @@
-using Blue;
-using System.Collections.Generic;
-
-public class GetPointPosSuccessEvent : IEvent
-{
-    public List<PointJsonInfo> pointJsonInfos;
-}

+ 0 - 11
Assets/Scripts/Blue/Event/GetPointPosSuccessEvent.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 6d5e998b473de3947a5728ce2109665e
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 5 - 0
Assets/Scripts/Blue/Other/PointFileType.cs

@@ -0,0 +1,5 @@
+public enum PointFileType
+{
+    json,
+    bytes
+}

+ 1 - 1
Assets/Scripts/Blue/Command/LoadMapFileCommand.cs.meta → Assets/Scripts/Blue/Other/PointFileType.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: e756abe00de3da34689659697ed13ba6
+guid: 3579c2d3722ce094aa463512d045c3fd
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 140 - 0
Assets/Scripts/Blue/Service/IPointService.cs

@@ -0,0 +1,140 @@
+using System;
+using System.Collections;
+using System.IO;
+using Blue;
+using UnityEngine;
+using UnityEngine.Networking;
+
+public interface IPointService:IService
+{
+    /// <summary>
+    /// 获取点坐标数据
+    /// </summary>
+    /// <param name="methodName">后缀</param>
+    void GetPoint(string methodName, Action<string> callback);
+    /// <summary>
+    /// 获取点云文件的下载链接
+    /// </summary>
+    /// <param name="methodName">后缀</param>
+    /// <param name="projectId">场景ID</param>
+    /// <param name="fileType">文件类型</param>
+    void GetPointFileDownloadUrl(string methodName, string projectId, PointFileType fileType, Action<string> callback);
+
+    /// <summary>
+    /// 根据点云文件的下载链接去下载点云文件
+    /// </summary>
+    /// <param name="downloadingUrl">点云文件的下载链接</param>
+    /// <param name="fileType">文件类型</param>
+    /// <param name="sceneID">场景ID</param>
+    void DownloadPointFile(string downloadingUrl, PointFileType fileType);
+}
+
+public class PointService : IPointService
+{
+    private string UrlPointCloud;
+    public void OnInit()
+    {
+        UrlPointCloud = "https://pro.qulivr.com/mr-navigator/v1";
+    }
+
+    public void GetPoint(string methodName, Action<string> callback)
+    {
+        CoroutineSystem.Instance.Start_Coroutine(GetPointRequest(methodName, callback));
+    }
+    public void GetPointFileDownloadUrl(string methodName, string projectId, PointFileType fileType, Action<string> callback)
+    {
+        string url = UrlPointCloud + methodName;
+        // 创建URL
+        UriBuilder uriBuilder = new UriBuilder(url);
+        // 添加查询参数
+        uriBuilder.Query = "projectId=" + projectId + "&fileType=" + fileType.ToString();
+        // 创建UnityWebRequest
+        UnityWebRequest webRequest = UnityWebRequest.Get(uriBuilder.Uri);
+        webRequest.SetRequestHeader("Authorization", HttpTool.Instance.Token);
+        // 发送请求
+        CoroutineSystem.Instance.Start_Coroutine(GetPointGetPointFileRequest(webRequest, callback));
+    }
+    public void DownloadPointFile(string downloadingUrl, PointFileType fileType)
+    {
+        CoroutineSystem.Instance.Start_Coroutine(DownloadPointFileRequest(downloadingUrl,fileType));
+    }
+
+    #region 协程
+
+    private IEnumerator GetPointRequest(string methodName, Action<string> callback)
+    {
+        string url = UrlPointCloud + methodName;
+        using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
+        {
+            webRequest.SetRequestHeader("authorization", HttpTool.Instance.Token);
+            //设置header
+            foreach (var v in HttpTool.Instance.RequestHeader)
+            {
+                webRequest.SetRequestHeader(v.Key, v.Value);
+            }
+            yield return webRequest.SendWebRequest();
+
+            if (webRequest.result == UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
+                Debug.LogError("GetPoint failed: " + webRequest.error + "\n" + webRequest.downloadHandler.text);
+            else
+                callback?.Invoke(webRequest.downloadHandler.text);
+        }
+    }
+    private IEnumerator GetPointGetPointFileRequest(UnityWebRequest webRequest, Action<string> callback)
+    {
+        yield return webRequest.SendWebRequest();
+
+        if( webRequest.result == UnityWebRequest.Result.ProtocolError || webRequest.result == UnityWebRequest.Result.ConnectionError)
+            Debug.LogError("GetPointFileDownloadUrl failed: " + webRequest.error);
+        else
+            callback?.Invoke(webRequest.downloadHandler.text);
+    }
+
+    /// <summary>
+    /// 下载点云文件 UnityWebRequest
+    /// </summary>
+    /// <param name="downloadingUrl">下载的Url</param>
+    /// <param name="fileType">文件类型</param>
+    /// <returns></returns>
+    private IEnumerator DownloadPointFileRequest(string downloadingUrl, PointFileType fileType)
+    {
+        string fileName = this.GetUtility<GetFileNameUtility>().GetFileName(downloadingUrl, fileType.ToString());
+
+        if (!File.Exists(Application.persistentDataPath + "/Map Data/" + fileName))
+        {
+            Debug.LogWarning("文件不存在,下载文件");
+            using (UnityWebRequest webRequestPoint = UnityWebRequest.Get(downloadingUrl))
+            {
+                webRequestPoint.timeout = 30;//设置超时,若webRequest.SendWebRequest()连接超时会返回,且isNetworkError为true
+
+                yield return webRequestPoint.SendWebRequest();
+
+                if (webRequestPoint.result == UnityWebRequest.Result.ProtocolError || webRequestPoint.result == UnityWebRequest.Result.ConnectionError)
+                    Debug.Log("Download Point Cloud Error:" + webRequestPoint.error);
+                else
+                {
+                    if (Directory.Exists(Application.persistentDataPath + "/Map Data") == false) // Map Data文件夹不存在
+                        Directory.CreateDirectory(Application.persistentDataPath + "/Map Data");
+                    if (System.IO.File.Exists(Application.persistentDataPath + "/Map Data/" + fileName)) // Map Data/fileName 文件存在则删除
+                        System.IO.File.Delete(Application.persistentDataPath + "/Map Data/" + fileName);
+                    
+                    var File = webRequestPoint.downloadHandler.data; //获取二进制数据
+                    FileStream nFile = new FileStream(Application.persistentDataPath + "/Map Data/" + fileName, FileMode.Create); //创建文件写入对象
+                    nFile.Write(File, 0, File.Length); //写入数据
+                    nFile.Close(); nFile.Dispose(); nFile = null;//关闭当前流并释放与之相关联的所有系统资源
+                    if (fileType == PointFileType.bytes)
+                        this.TriggerEvent(new LoadMapFileEvent() { fileName = fileName });
+                }
+            }
+               
+        }
+        else
+        {
+            Debug.LogWarning("文件已存在");
+            if (fileType == PointFileType.bytes)
+                this.TriggerEvent(new LoadMapFileEvent() { fileName = fileName });
+        }
+    }
+
+    #endregion
+}

+ 0 - 37
Assets/Scripts/Blue/Utility/GetAngleByTwoPointUtility.cs

@@ -1,37 +0,0 @@
-using System;
-using Blue;
-using UnityEngine;
-
-public interface IGetAngleByTwoPointUtility:IUtility
-{
-    double GetAngleByTwoPoint(Vector2 startPoint, Vector2 endPoint);
-    double GetAngleByTwoPoint(float startPoint_X, float startPoint_Y, float endPoint_X, float ednPoint_Y);
-}
-
-public class GetAngleByTwoPointUtility : IGetAngleByTwoPointUtility
-{
-    /// <summary>
-    /// 根据两点求角度
-    /// </summary>
-    /// <param name="startPoint">开始点坐标</param>
-    /// <param name="endPoint">结束点坐标</param>
-    /// <returns>角度</returns>
-    double IGetAngleByTwoPointUtility.GetAngleByTwoPoint(Vector2 startPoint,Vector2 endPoint)
-    {
-        return GetAngleByTwoPoint(startPoint.x,startPoint.y,endPoint.x,endPoint.y);
-    }
-
-    /// <summary>
-    /// 根据两点求角度
-    /// </summary>
-    /// <param name="startPoint_X">开始点X值</param>
-    /// <param name="startPoint_Y">开始点Y值</param>
-    /// <param name="endPoint_X">结束点X值</param>
-    /// <param name="ednPoint_Y">结束点Y值</param>
-    /// <returns>角度</returns>
-    public double GetAngleByTwoPoint(float startPoint_X,float startPoint_Y ,float endPoint_X,float ednPoint_Y)
-    {
-        return Math.Atan2(ednPoint_Y - startPoint_Y, endPoint_X - startPoint_X) * (180.0 / Math.PI);
-    }
-
-}

+ 0 - 11
Assets/Scripts/Blue/Utility/GetAngleByTwoPointUtility.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 73cb1e9a9490da64db4c6923502ca25b
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 29 - 0
Assets/Scripts/Blue/Utility/UnityWebRequestUtility.cs

@@ -0,0 +1,29 @@
+using Blue;
+using UnityEngine.Networking;
+
+public class UnityWebRequestUtility : IUtility
+{
+    /// <summary>
+    /// 获取下载进度
+    /// </summary>
+    public float GetProcess(UnityWebRequest webRequestPoint)
+    {
+        if (webRequestPoint != null)
+        {
+            return webRequestPoint.downloadProgress;
+        }
+        return 0;
+    }
+
+    /// <summary>
+    /// 获取当前下载内容长度
+    /// </summary>
+    public long GetCurrentLength(UnityWebRequest webRequestPoint)
+    {
+        if (webRequestPoint != null)
+        {
+            return (long)webRequestPoint.downloadedBytes;
+        }
+        return 0;
+    }
+}

+ 1 - 1
Assets/Scripts/Blue/Command/DownloadFileCommand.cs.meta → Assets/Scripts/Blue/Utility/UnityWebRequestUtility.cs.meta

@@ -1,5 +1,5 @@
 fileFormatVersion: 2
-guid: 047677d12c1f73b4584653298453bee5
+guid: c4bfea117eb722c4e86eba86f95eba03
 MonoImporter:
   externalObjects: {}
   serializedVersion: 2

+ 3 - 3
ProjectSettings/ProjectSettings.asset

@@ -924,6 +924,7 @@ PlayerSettings:
   metroSplashScreenUseBackgroundColor: 1
   platformCapabilities:
     WindowsStoreApps:
+      EnterpriseAuthentication: False
       OfflineMapsManagement: False
       HumanInterfaceDevice: False
       Location: False
@@ -935,7 +936,6 @@ PlayerSettings:
       PrivateNetworkClientServer: False
       InternetClientServer: False
       VideosLibrary: False
-      BackgroundMediaPlayback: False
       Objects3D: False
       RemoteSystem: False
       BlockedChatMessages: False
@@ -958,9 +958,9 @@ PlayerSettings:
       RecordedCallsFolder: False
       Contacts: False
       InternetClient: True
-      Proximity: False
       CodeGeneration: False
-      EnterpriseAuthentication: False
+      BackgroundMediaPlayback: False
+      Proximity: False
   metroTargetDeviceFamilies:
     Desktop: False
     Holographic: False