From 5db375bcf5c7ac4358e9c7a1677ba1110c6cba9b Mon Sep 17 00:00:00 2001 From: suntao Date: Thu, 20 May 2021 16:15:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=8F=B0=E6=B9=BE=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=82=B9=E5=87=BB=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/App.cs | 10 ++++---- Assets/Scripts/Devices/Ant/AntConnector.cs | 5 ++++ .../UI/Prefab/Panel/EarthController.cs | 24 +++++++++++++++---- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/App.cs b/Assets/Scripts/App.cs index 52031556..e56f8bc4 100644 --- a/Assets/Scripts/App.cs +++ b/Assets/Scripts/App.cs @@ -50,10 +50,10 @@ public static class App static App() { -#if !UNITY_EDITOR - //Host = "http://pf.juze.pro/"; - //UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000); - //TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001); -#endif +//#if !UNITY_EDITOR +// //Host = "http://pf.juze.pro/"; +// //UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000); +// //TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001); +//#endif } } diff --git a/Assets/Scripts/Devices/Ant/AntConnector.cs b/Assets/Scripts/Devices/Ant/AntConnector.cs index 103ab48c..0e08c844 100644 --- a/Assets/Scripts/Devices/Ant/AntConnector.cs +++ b/Assets/Scripts/Devices/Ant/AntConnector.cs @@ -183,6 +183,11 @@ namespace Assets.Scripts.Devices.Ant } searchChannel.channelResponse -= antChannel_channelResponse_FeSearch; searchChannel = null; + foreach (var item in discoveredDevices) + { + item.State = DeviceState.Disconnected; + } + discoveredDevices.Clear(); usedChannels.Clear(); IsBackgroundScanning = false; diff --git a/Assets/Scripts/UI/Prefab/Panel/EarthController.cs b/Assets/Scripts/UI/Prefab/Panel/EarthController.cs index 58457c4d..57c04780 100644 --- a/Assets/Scripts/UI/Prefab/Panel/EarthController.cs +++ b/Assets/Scripts/UI/Prefab/Panel/EarthController.cs @@ -8,6 +8,7 @@ using Assets.Scripts.Apis; using Newtonsoft.Json.Linq; using Assets.Scripts; using UnityEngine.EventSystems; +using System; public class EarthController : PFUIPanel { @@ -29,6 +30,7 @@ public class EarthController : PFUIPanel bool showSummary = false; Vector2 latlonCenter; private GameObject panel; + private bool isTaiwanClick = false; protected override void Awake() { base.Awake(); @@ -123,11 +125,15 @@ public class EarthController : PFUIPanel map.OnCountryClick += (int countryIndex, int regionIndex) => { + var country = map.countries[countryIndex]; - if (country.name.ToLower().Contains("taiwan")) + Debug.Log($"country click { country.name }, { countryIndex }, { regionIndex }"); + if (country.name.ToLower().Contains("taiwan") || country.name.ToLower().Contains("china")) { - var latLon = country.latlonCenter; - EnterBigMap(latLon); + //var latLon = map.countries[36].latlonCenter; //country.latlonCenter; + //EnterBigMap(latLon); + isTaiwanClick = true; + Invoke("DelayEnterBigMapForTaiwan", 0.01f); } }; @@ -148,6 +154,8 @@ public class EarthController : PFUIPanel }; map.OnProvinceClick += (int provinceIndex, int regionIndex) => { + isTaiwanClick = false; + Debug.Log("province click"); var province = map.provinces[provinceIndex]; var latLon = province.latlonCenter; EnterBigMap(latLon); @@ -156,6 +164,13 @@ public class EarthController : PFUIPanel //skybox = Camera.main.GetComponent(); } + private void DelayEnterBigMapForTaiwan() + { + if (!isTaiwanClick) return; + var latLon = map.countries[36].latlonCenter; + EnterBigMap(latLon); + } + //private float rot = 0; //Skybox skybox; /// @@ -229,7 +244,7 @@ public class EarthController : PFUIPanel //Debug.Log("click"); Vector2 latLon = Conversion.GetLatLonFromSpherePoint(sphereLocation); - Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y); + Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y); } @@ -280,5 +295,6 @@ public class EarthController : PFUIPanel //base.Close(); map.Destroy(); DestroyImmediate(this.gameObject); + GC.SuppressFinalize(this); } }