From 9a4e646a8fcb0073d4dfba669786bb02132dff57 Mon Sep 17 00:00:00 2001 From: suntao Date: Sat, 8 May 2021 11:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=B0=E6=B9=BE=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9B=E5=8A=A0=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=B6?= =?UTF-8?q?=E9=97=B4=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Apis/UserApi.cs | 7 ++- Assets/Scripts/App.cs | 2 +- Assets/Scripts/PFConstants.cs | 35 +++++++++++ Assets/Scripts/PFConstants.cs.meta | 11 ++++ Assets/Scripts/Scenes/MainController.cs | 2 +- .../Scripts/UI/Prefab/Animation/LoadingPf.cs | 58 ++++++++++++++----- .../UI/Prefab/Panel/BigMapController.cs | 2 +- .../UI/Prefab/Panel/EarthController.cs | 18 +++--- Assets/Scripts/UIManager.cs | 42 +++++++++++++- Assets/Scripts/Utils/CustomDateTime.cs | 31 ++++++++++ Assets/Scripts/Utils/CustomDateTime.cs.meta | 11 ++++ ProjectSettings/ProjectSettings.asset | 2 +- 12 files changed, 187 insertions(+), 34 deletions(-) create mode 100644 Assets/Scripts/PFConstants.cs create mode 100644 Assets/Scripts/PFConstants.cs.meta create mode 100644 Assets/Scripts/Utils/CustomDateTime.cs create mode 100644 Assets/Scripts/Utils/CustomDateTime.cs.meta diff --git a/Assets/Scripts/Apis/UserApi.cs b/Assets/Scripts/Apis/UserApi.cs index 3deedc20..5c57da62 100644 --- a/Assets/Scripts/Apis/UserApi.cs +++ b/Assets/Scripts/Apis/UserApi.cs @@ -123,12 +123,13 @@ namespace Assets.Scripts.Apis return result; } - public DateTime GetNow() + public async Task GetNow() { - var result = Get("NoAuth/GetNow"); + var result = await GetAsync("NoAuth/GetNow"); - return DateTime.Parse(result); + return DateTime.Parse(System.Text.Encoding.UTF8.GetString(result)); } + public async Task> Register(string Phone, string Pwd, string Captcha) { var param = new diff --git a/Assets/Scripts/App.cs b/Assets/Scripts/App.cs index 25c652d8..f04325b2 100644 --- a/Assets/Scripts/App.cs +++ b/Assets/Scripts/App.cs @@ -8,7 +8,7 @@ using System.Net; public static class App { - public static string Host = "http://192.168.0.101:5083/"; + public static string Host = "http://192.168.0.97:5082/"; public static string AppVersion = "1.0.0"; diff --git a/Assets/Scripts/PFConstants.cs b/Assets/Scripts/PFConstants.cs new file mode 100644 index 00000000..de602e05 --- /dev/null +++ b/Assets/Scripts/PFConstants.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.IO; +using UnityEngine; + +public static class PFConstants +{ + /// + /// 课程训练保存在本地的路径 + /// + public static string MapWorkoutRecordFolder + { + get + { + if(!Directory.Exists(Application.persistentDataPath + "/MapWorkoutRecords/")){ + Directory.CreateDirectory(Application.persistentDataPath + "/MapWorkoutRecords/"); + } + + return Application.persistentDataPath + "/MapWorkoutRecords/"; + } + } + /// + /// 设备连接缓存在本地的路径 + /// + public static string DeviceCacheFolder + { + get + { + return Application.persistentDataPath; + } + } +} diff --git a/Assets/Scripts/PFConstants.cs.meta b/Assets/Scripts/PFConstants.cs.meta new file mode 100644 index 00000000..94685a8d --- /dev/null +++ b/Assets/Scripts/PFConstants.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: fe6b725ad54bc6747801a7f7f9b40a59 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Scenes/MainController.cs b/Assets/Scripts/Scenes/MainController.cs index b9fc8593..8678eeed 100644 --- a/Assets/Scripts/Scenes/MainController.cs +++ b/Assets/Scripts/Scenes/MainController.cs @@ -16,7 +16,7 @@ public class MainController : MonoBehaviour { Version = this.transform.Find("GameObject").Find("Version").GetComponent(); Version.text = "V"+App.AppVersion; - DeviceCache.Init(Application.dataPath); + DeviceCache.Init(PFConstants.DeviceCacheFolder); AntConnector.Instance((device2) => { //自动连接 diff --git a/Assets/Scripts/UI/Prefab/Animation/LoadingPf.cs b/Assets/Scripts/UI/Prefab/Animation/LoadingPf.cs index 75d50a50..672529db 100644 --- a/Assets/Scripts/UI/Prefab/Animation/LoadingPf.cs +++ b/Assets/Scripts/UI/Prefab/Animation/LoadingPf.cs @@ -8,8 +8,9 @@ public class LoadingPf : PFUIPanel List sprites; Image image; - protected override void Start() + protected override void Awake() { + base.Awake(); sprites = new List(); for (int i = 1; i < 80; i++) { @@ -17,29 +18,56 @@ public class LoadingPf : PFUIPanel } image = transform.GetComponent(); } + + protected override void Start() + { + + } int index = 0; - float time = 0; + //float time = 0; public override void Show() { base.Show(); index = 0; - time = 0; + //time = 0; + + StartCoroutine(Animation()); + } + + IEnumerator Animation() + { + for (; ; ) + { + if (index % 79 == 0) + { + index = 0; + } + image.sprite = sprites[index]; + index++; + yield return new WaitForSeconds(0.03f); + } } void Update() { - time += Time.deltaTime; - if (time < 0.03) - { - return; - } - time = 0; - if (index % 79 == 0) - { - index = 0; - } - image.sprite = sprites[index]; - index++; + //time += Time.deltaTime; + //if (time < 0.03) + //{ + // return; + //} + //time = 0; + //if (index % 79 == 0) + //{ + // index = 0; + //} + //image.sprite = sprites[index]; + //index++; + } + + public override void Close() + { + StopCoroutine(Animation()); + base.Close(); } } diff --git a/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs b/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs index 8b6d6833..8365f91a 100644 --- a/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/BigMapController.cs @@ -184,7 +184,7 @@ public class BigMapController : PFUIPanel } private void MapManager_OnUpdated() { - Debug.Log("update "+ mapManager.Zoom); + //Debug.Log("update "+ mapManager.Zoom); if(mapManager.Zoom <= 4.8) { diff --git a/Assets/Scripts/UI/Prefab/Panel/EarthController.cs b/Assets/Scripts/UI/Prefab/Panel/EarthController.cs index 61c6263b..58457c4d 100644 --- a/Assets/Scripts/UI/Prefab/Panel/EarthController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/EarthController.cs @@ -113,9 +113,11 @@ public class EarthController : PFUIPanel Country.text = "China"; Province.text = "TaiWan"; ShowSummary(country.latlonCenter); + + map.HighlightCountryRegion(173, 1, false, true, Color.white); } else { - Country.text = country.name; + Country.text = country.name; } }; @@ -129,7 +131,7 @@ public class EarthController : PFUIPanel } }; - map.OnProvinceEnter += async (int provinceIndex, int regionIndex) => + map.OnProvinceEnter += (int provinceIndex, int regionIndex) => { var province = map.provinces[provinceIndex]; @@ -151,11 +153,11 @@ public class EarthController : PFUIPanel EnterBigMap(latLon); }; - skybox = Camera.main.GetComponent(); - Debug.Log(skybox != null); + //skybox = Camera.main.GetComponent(); } - private float rot = 0; - Skybox skybox; + + //private float rot = 0; + //Skybox skybox; /// /// 显示概要信息 /// @@ -209,8 +211,6 @@ public class EarthController : PFUIPanel /// private void EnterBigMap(Vector2 latLon) { - Debug.Log("enter big map"); - map.FlyToLocation(latLon.x, latLon.y, 1f, 0.1f).Then(() => { //Close(); @@ -278,7 +278,7 @@ public class EarthController : PFUIPanel public override void Close() { //base.Close(); - + map.Destroy(); DestroyImmediate(this.gameObject); } } diff --git a/Assets/Scripts/UIManager.cs b/Assets/Scripts/UIManager.cs index 7e8fcea9..a8b9acc1 100644 --- a/Assets/Scripts/UIManager.cs +++ b/Assets/Scripts/UIManager.cs @@ -9,6 +9,7 @@ using Newtonsoft.Json; using UnityEngine.UI; using Assets.Scripts.UI.Control; using Assets.Scripts; +using System; public class UIManager : MonoBehaviour { @@ -154,6 +155,11 @@ public class UIManager : MonoBehaviour { false,Resources.Load("Images/p-4灰")}, { true,Resources.Load("Images/p-4")}, }; + + if(_now == null) + { + InitNow(); + } } // Start is called before the first frame update @@ -476,12 +482,27 @@ public class UIManager : MonoBehaviour public static void AddEvent(GameObject gameObject, EventTriggerType eventTriggerType, UnityAction call) { EventTrigger et = gameObject.GetComponent(); + EventTrigger.Entry pointerEvent = null; if (et == null) { et = gameObject.AddComponent(); } - EventTrigger.Entry pointerEvent = new EventTrigger.Entry(); - pointerEvent.eventID = eventTriggerType; + foreach (EventTrigger.Entry entry2 in et.triggers) + { + if(entry2.eventID == eventTriggerType) + { + pointerEvent = entry2; + break; + } + } + if (pointerEvent == null) + { + pointerEvent = new EventTrigger.Entry(); + pointerEvent.eventID = eventTriggerType; + et.triggers.Add(pointerEvent); + } + //pointerEvent.callback.RemoveAllListeners(); + pointerEvent.callback.AddListener((e)=> { if (gameObject == null || gameObject.activeInHierarchy == false) return; var btn = gameObject.GetComponent