From 6066f52411419be22281e1c2c37850280b2a7347 Mon Sep 17 00:00:00 2001 From: mengtao Date: Fri, 19 Apr 2024 11:22:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=AE=9A=E4=BD=8D=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Common/GameManager.cs | 1 + .../PersonnelLocation/LocationSimulator.cs | 22 ++++++++++--------- Assets/Scripts/Manager/Config.cs | 8 +++++++ .../UIManager/View/PersonnelLocationPanel.cs | 8 +++---- Assets/StreamingAssets/Config.json | 7 +++--- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/Assets/Scripts/Common/GameManager.cs b/Assets/Scripts/Common/GameManager.cs index b8dfbbb..5370c04 100644 --- a/Assets/Scripts/Common/GameManager.cs +++ b/Assets/Scripts/Common/GameManager.cs @@ -48,6 +48,7 @@ public class GameManager : Singleton Config.Tags = webConfig.Tags; Config.Range = webConfig.Range; Config.Interval = webConfig.Interval; + Config.MapId = webConfig.MapId; Config.AlarmServer = webConfig.AlarmServer; Config.AlarmInterval = webConfig.AlarmInterval; Debug.Log("ServerAddress:" + Config.ServerAddress + " Interval:" + Config.Interval + " Range:" + Config.Range); diff --git a/Assets/Scripts/Main/Core/PersonnelLocation/LocationSimulator.cs b/Assets/Scripts/Main/Core/PersonnelLocation/LocationSimulator.cs index 52b579c..fc09d02 100644 --- a/Assets/Scripts/Main/Core/PersonnelLocation/LocationSimulator.cs +++ b/Assets/Scripts/Main/Core/PersonnelLocation/LocationSimulator.cs @@ -64,7 +64,7 @@ public class LocationSimulator : MonoBehaviour postData.Add(i.ToString(), json); i++; } - HttpManager.Instance.Post (url, postData); + HttpManager.Instance.Post(url, postData); } } @@ -77,7 +77,7 @@ public class LocationSimulator : MonoBehaviour if (isOn) { - LoadTrackData(targetNo, data => + LoadTrackData(targetNo, data => { trackLocationData = data; if (trackLocationData.Count > 0) @@ -96,10 +96,10 @@ public class LocationSimulator : MonoBehaviour /// /// /// - private void LoadTrackData(long targetNo,Action> action) + private void LoadTrackData(long targetNo, Action> action) { var url = HttpManager.Instance.GetPersonnelHistoryData; - HttpManager.Instance.Get>(url, tempData => + HttpManager.Instance.Get>(url, tempData => { var loadedData = new List(); foreach (var item in tempData) @@ -199,7 +199,7 @@ public class LocationSimulator : MonoBehaviour { while (true) { - var url = $"{Config.LocationServer}/le/uwbofferdata/getPositionDataByMapId/12"; + var url = $"{Config.LocationServer}/le/uwbofferdata/getPositionDataByMapId/{Config.MapId}"; HttpManager.Instance.Get(url, tempData => { if (tempData.errorCode != 1) @@ -221,7 +221,9 @@ public class LocationSimulator : MonoBehaviour if (agentControllers.ContainsKey(data.targetNo)) { - agentControllers[data.targetNo].UpdatePosition(data); + //agentControllers[data.targetNo].UpdatePosition(data); + agentControllers[data.targetNo].enabled = false; + agentControllers[data.targetNo].transform.position = Main.LocationSimulator.ConversionTransform(data); } else { @@ -247,7 +249,7 @@ public class LocationSimulator : MonoBehaviour yield return new WaitForSeconds(Config.Interval); } } - + /// /// 确保角色始终在地面上 @@ -273,7 +275,7 @@ public class LocationSimulator : MonoBehaviour /// private AgentController CreateAgent(LocationData data) { - + if (characterCount > 4) characterCount = 0; var obj = Instantiate(AssetManager.Instance.characters[characterCount]) as GameObject; @@ -286,7 +288,7 @@ public class LocationSimulator : MonoBehaviour controller.targetNo = data.targetNo; controller.ShowStatus(data.createdTime, data.targetNo); controller.SetToNvMesh(pos); - SetActive(obj,data); + SetActive(obj, data); characterCount++; return controller; @@ -312,7 +314,7 @@ public class LocationSimulator : MonoBehaviour /// public Vector3 ConversionTransform(LocationData data) { - var pos = new Vector3(-((float)data.xAxis+offsetX), -17.7f, -((float)data.yAxis+offsetZ)); + var pos = new Vector3(-((float)data.xAxis - offsetX), -17.7f, -((float)data.yAxis - offsetZ)); //pos.y = SetY(pos); return pos; diff --git a/Assets/Scripts/Manager/Config.cs b/Assets/Scripts/Manager/Config.cs index 69fc0ba..8d74ac2 100644 --- a/Assets/Scripts/Manager/Config.cs +++ b/Assets/Scripts/Manager/Config.cs @@ -23,6 +23,10 @@ public static class Config /// public static string LocationServer { get; set; } /// + /// 人员定位接口地图id + /// + public static string MapId { get; set; } + /// /// 人员定位报警接口 /// public static string AlarmServer { get; set; } @@ -71,6 +75,10 @@ public class ConfigWebGL /// public string LocationServer { get; set; } /// + /// 人员定位接口地图id + /// + public string MapId { get; set; } + /// /// 人员定位报警接口 /// public string AlarmServer { get; set; } diff --git a/Assets/Scripts/UIManager/View/PersonnelLocationPanel.cs b/Assets/Scripts/UIManager/View/PersonnelLocationPanel.cs index 8a45cf4..06ee474 100644 --- a/Assets/Scripts/UIManager/View/PersonnelLocationPanel.cs +++ b/Assets/Scripts/UIManager/View/PersonnelLocationPanel.cs @@ -74,12 +74,12 @@ public class PersonnelLocationPanel : UIView alarmScrollView.ResetAllDelegates(); }); - + } private void LoadTags(List tags) { - employeeScrollView.SetUpdateFunc(tags, (index, item) => + employeeScrollView.SetUpdateFunc(tags, (index, item) => { string info = tags[index]; item.name = info; @@ -90,13 +90,13 @@ public class PersonnelLocationPanel : UIView item.transform.Find("Show").GetComponent().onValueChanged.AddListener(v => Main.Event.EmployeeActive(long.Parse(info), v)); item.transform.Find("Track").GetComponent().onValueChanged.AddListener(v => Main.LocationSimulator.GetTrackPlaybackData(v, long.Parse(info))); }); - + } private void GetPersonnelData() { numbsrs.Clear(); - var url = $"{Config.LocationServer}/le/uwbofferdata/getPositionDataByMapId/12"; + var url = $"{Config.LocationServer}/le/uwbofferdata/getPositionDataByMapId/{Config.MapId}"; HttpManager.Instance.Get(url, tempData => { if (tempData.list.Count > 0) diff --git a/Assets/StreamingAssets/Config.json b/Assets/StreamingAssets/Config.json index d35397d..e51863a 100644 --- a/Assets/StreamingAssets/Config.json +++ b/Assets/StreamingAssets/Config.json @@ -3,10 +3,11 @@ "BucketName": "WebPlan", "AreaName": "虹口区", "CompanyName": "凯德龙之梦", - "LocationServer": "http://96291c6.r8.cpolar.top", - "AlarmServer":"http://3949b92f.r6.cpolar.top", + "LocationServer": "http://101.201.70.191:8080", + "AlarmServer":"http://101.201.70.191:8080", + "MapId":"4", "PersonnelVideoUrl":"https://demo.unified-streaming.com/k8s/features/stable/video/tears-of-steel/tears-of-steel.ism/.m3u8", - "Tags": ["10777839","10777836","10777842","10777826","10777827","10774520","10777834","10777831","10774521","10774529","10774519","10774527","10774530","10774508","10770002"], + "Tags": ["10671050","10671051","10671052","10671053","10671054","10671057","10671058","10671059","10671061","10671064"], "Interval":1, "Range":0.3, "AlarmInterval":10