This commit is contained in:
YangHua 2024-06-26 09:07:22 +08:00
parent 0cc0ef38ca
commit 54efd8336f
21 changed files with 388074 additions and 29363 deletions

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
using Adam; using Adam;
using System;
using System.IO;
using Newtonsoft.Json;
public class Bootstrap : MonoSingleton<Bootstrap> public class Bootstrap : MonoSingleton<Bootstrap>
{ {
@ -13,8 +15,10 @@ public class Bootstrap : MonoSingleton<Bootstrap>
/// 0 省会 1 城市 2 区县 /// 0 省会 1 城市 2 区县
/// </summary> /// </summary>
public int currentLevel = 0; public int currentLevel = 0;
public string currentDisName;
public string currentDistCode;
public List<string> landMarks; private List<string> landMarks = new List<string>();
/// <summary> /// <summary>
/// 透明 /// 透明
/// </summary> /// </summary>
@ -65,20 +69,37 @@ public class Bootstrap : MonoSingleton<Bootstrap>
[HideInInspector] [HideInInspector]
public RayHitTester rayHitTester; public RayHitTester rayHitTester;
public GameObject lastLand; public GameObject lastLand;
public GameObject shadowMap;
public int clickCurrentLevel = 2;
[ContextMenu("1")]
private void Awake() private void Awake()
{ {
string[] data = FileUtil.ReadAllLineFromLocal("WebAddress.json"); var serverConfig = new System.Uri(Path.Combine(Application.streamingAssetsPath + @"/Config", "WebAddress.json"));
for (int i = 0; i < data.Length; i++) GetText(serverConfig.ToString(), (temp) =>
{ {
string[] urlInfo = data[i].Split("="); if (!String.IsNullOrWhiteSpace(temp))
urlDic.Add(urlInfo[0], urlInfo[1]); {
Debug.Log("读取到的内容有:" + temp);
urlDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(temp);
//urlDic = JsonUtility.FromJson<Dictionary<string, string>>(temp);
} }
else
{
Debug.Log("加载配置文件错误");
}
});
//string data = FileUtil.ReadFromLocal("WebAddress.json");
//urlDic = JsonConvert.DeserializeObject<Dictionary<string, string>>(data);
webAdapter = GetComponent<WebAdapter>(); webAdapter = GetComponent<WebAdapter>();
rayHitTester = GetComponent<RayHitTester>(); rayHitTester = GetComponent<RayHitTester>();
} }
public void GetText(string url, Action<string> actionResult)
{
StartCoroutine(FileUtil.GetTextAsyn(url, actionResult));
}
void Start() void Start()
{ {
//landMarks = new List<string> { "网络负荷49.84 kw", "上网负荷49.84 kw", "削峰负荷49.84 kw", "填谷负荷49.84 kw", "发电负荷49.84 kw" }; //landMarks = new List<string> { "网络负荷49.84 kw", "上网负荷49.84 kw", "削峰负荷49.84 kw", "填谷负荷49.84 kw", "发电负荷49.84 kw" };
@ -91,6 +112,23 @@ public class Bootstrap : MonoSingleton<Bootstrap>
private void Update() private void Update()
{ {
var hit = rayHitTester.HitTest(); var hit = rayHitTester.HitTest();
if (Input.GetMouseButtonDown(2))
{
if (hit.collider != null)
{
if (cameraRt.currentLevelIndex == 1) return;
clickCurrentLevel--;
if (clickCurrentLevel <= 1)
{
clickCurrentLevel = 1;
}
cameraRt.currentLevelIndex = clickCurrentLevel;
//currentLevel = clickCurrentLevel;
SwitchLand(clickCurrentLevel);
cameraRt.SetTarget(hit.collider.transform);
Debug.Log("clickCurrentLevel==" + clickCurrentLevel);
}
}
if (hit.collider != null) if (hit.collider != null)
{ {
landMarks.Clear(); landMarks.Clear();
@ -106,6 +144,8 @@ public class Bootstrap : MonoSingleton<Bootstrap>
{ {
CloseLandMark(); CloseLandMark();
} }
} }
@ -117,12 +157,12 @@ public class Bootstrap : MonoSingleton<Bootstrap>
public async void ShowLandMark() public async void ShowLandMark()
{ {
if (currentLand == null) return; if (currentLand == null) return;
string distCode = currentLand.GetComponent<CityInfo>().distCode; currentDistCode = currentLand.GetComponent<CityInfo>().distCode;
currentLand.GetComponent<MeshRenderer>().materials = select; currentLand.GetComponent<MeshRenderer>().materials = select;
Vector3 worldToScreenPoint = Camera.main.WorldToScreenPoint(new Vector3(currentLand.transform.position.x, currentLand.transform.position.y, currentLand.transform.position.z)); Vector3 worldToScreenPoint = Camera.main.WorldToScreenPoint(new Vector3(currentLand.transform.position.x, currentLand.transform.position.y, currentLand.transform.position.z));
lastLand = currentLand; lastLand = currentLand;
SwitchLevel(-1); SwitchLevel(-1);
AreaData areaData = await AsyncWebReq.Get<AreaData>($"{urlDic["µØÍ¼µ¯³ö¿ò"]}{distCode}", webAdapter.head, webAdapter.token); AreaData areaData = await AsyncWebReq.Get<AreaData>($"{urlDic[""]}{currentDistCode}", webAdapter.head, webAdapter.token);
if (!bool.Parse(areaData.success)) return; if (!bool.Parse(areaData.success)) return;
for (int i = 0; i < areaData.data.items.Count; i++) for (int i = 0; i < areaData.data.items.Count; i++)
{ {
@ -139,7 +179,6 @@ public class Bootstrap : MonoSingleton<Bootstrap>
/// </summary> /// </summary>
public void CloseLandMark() public void CloseLandMark()
{ {
landMarkAndInfoCotroller.gameObject.SetActive(false); landMarkAndInfoCotroller.gameObject.SetActive(false);
if (lastLand != null) if (lastLand != null)
{ {
@ -160,6 +199,8 @@ public class Bootstrap : MonoSingleton<Bootstrap>
webAdapter.LevelChange(_currentLevel.ToString()); webAdapter.LevelChange(_currentLevel.ToString());
landMarkAndInfoCotroller.gameObject.SetActive(false); landMarkAndInfoCotroller.gameObject.SetActive(false);
currentLevel = _currentLevel; currentLevel = _currentLevel;
clickCurrentLevel = _currentLevel;
shadowMap.gameObject.SetActive(false);
switch (currentLevel) switch (currentLevel)
{ {
case 2: case 2:
@ -169,6 +210,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
cityParents.GetChild(i).gameObject.SetActive(false); cityParents.GetChild(i).gameObject.SetActive(false);
} }
lastCity = null; lastCity = null;
shadowMap.gameObject.SetActive(true);
SwitchMatShow(provincialCapital); SwitchMatShow(provincialCapital);
break; break;
case 1: case 1:
@ -191,18 +233,18 @@ public class Bootstrap : MonoSingleton<Bootstrap>
} }
break; break;
case 0: case 0:
lastCity = currentLand.transform.parent; //lastCity = currentLand.transform.parent;
SwitchMatHide(lastCity); //SwitchMatHide(lastCity);
for (int i = 0; i < areaParents.childCount; i++) //for (int i = 0; i < areaParents.childCount; i++)
{ //{
var child = areaParents.GetChild(i).gameObject; // var child = areaParents.GetChild(i).gameObject;
child.SetActive(child.name == currentLand.name); // child.SetActive(child.name == currentLand.name);
if (child.activeSelf) // if (child.activeSelf)
{ // {
currentArea = child; // currentArea = child;
} // }
} //}
//Debug.Log("ÇøÏØ"); Debug.Log("区县");
break; break;
} }
} }
@ -301,7 +343,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
switch (currentLevel) switch (currentLevel)
{ {
case -1: case -1:
cameraRt.SetMaxMinDistance(10f, 120f); cameraRt.SetMaxMinDistance(30f, 120f);
break; break;
case 0: case 0:
cameraRt.SetMaxMinDistance(10f, 20f); cameraRt.SetMaxMinDistance(10f, 20f);

View File

@ -96,10 +96,10 @@ public class CameraRT : MonoBehaviour
public void SetTarget(Transform _target) public void SetTarget(Transform _target)
{ {
target.position = _target.position; target.position = _target.position;
distance = _target.localScale.x; //distance = _target.localScale.x;
y = _target.eulerAngles.x; //y = _target.eulerAngles.x;
x = _target.eulerAngles.y; //x = _target.eulerAngles.y;
} }
@ -173,6 +173,8 @@ public class CameraRT : MonoBehaviour
cam.transform.rotation = rotation; cam.transform.rotation = rotation;
cam.transform.position = position; cam.transform.position = position;
} }
} }
} }

View File

@ -6,15 +6,18 @@ public class CityInfo : MonoBehaviour
{ {
public string distCode; public string distCode;
public string cityName; public string cityName;
public ScreenTopStatistics sts = new ScreenTopStatistics();
private void Start() private void Start()
{ {
if (!GetComponent<Collider>())
gameObject.AddComponent<MeshCollider>();
OnSetStationInfo(); OnSetStationInfo();
} }
public void OnSetStationInfo() public async void OnSetStationInfo()
{ {
ScreenTopStatistics sts = DataController.Instance.GetStationsByDistCode(distCode); sts = await DataController.Instance.GetProvincialLevelStationInfo(distCode,cityName);
if (sts != null) if (sts != null)
{ {
transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(sts.agentCons); transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(sts.agentCons);

View File

@ -1,21 +1,23 @@
using Cysharp.Threading.Tasks;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
public class DataController : MonoSingleton<DataController> public class DataController : MonoSingleton<DataController>
{ {
public AreaStationData areaStationData = new AreaStationData(); public string distCode;
public string distCode = "37";
// Start is called before the first frame update // Start is called before the first frame update
private async void Awake()
{
string url = Bootstrap.Instance.urlDic["µØÍ¼ÐÅÏ¢»ã×Ü"];
areaStationData = await AsyncWebReq.Get<AreaStationData>(url + distCode, Bootstrap.Instance.webAdapter.head, Bootstrap.Instance.webAdapter.token);
}
public ScreenTopStatistics GetStationsByDistCode(string distCode) public async UniTask<ScreenTopStatistics> GetProvincialLevelStationInfo(string _distCode, string _disName)
{ {
DataItem sts = areaStationData.data.Find(s => s.distCode == distCode); await UniTask.Delay(1000);
if (_distCode.Length == 4)
distCode = _distCode.Substring(0, 2);
if (_distCode.Length == 6)
distCode = _distCode.Substring(0, 4);
string url = Bootstrap.Instance.urlDic["µØÍ¼ÐÅÏ¢»ã×Ü"];
AreaStationData areaStationData = await AsyncWebReq.Get<AreaStationData>(url + distCode, Bootstrap.Instance.webAdapter.head, Bootstrap.Instance.webAdapter.token);
DataItem sts = areaStationData.data.Find(s => s.disName == _disName);
if (sts == null) if (sts == null)
return null; return null;
return sts.screenTopStatistics; return sts.screenTopStatistics;

View File

@ -10,15 +10,35 @@ public class TEst : MonoBehaviour
public AggregateStation aggregateStation; public AggregateStation aggregateStation;
public List<Sprite> sprites = new List<Sprite>(); public List<Sprite> sprites = new List<Sprite>();
public List<GameObject> gameObjects = new List<GameObject>(); public List<GameObject> gameObjects = new List<GameObject>();
public Transform p;
public bool isDeleteStationInstructs;
public float h = 2;
[ContextMenu("GetInfo")] [ContextMenu("GetInfo")]
public void CreateItemAsset() public void CreateItemAsset()
{ {
manager.cityItems = null; manager.cityItems = null;
manager.cityItems = ExcelTool.CreateItemArrayWithExcel(ExcelConfig.excelsFolderPath + "ɽ¶«ÐÐÕþÇø»®Êý¾Ý.xlsx"); manager.cityItems = ExcelTool.CreateItemArrayWithExcel(ExcelConfig.excelsFolderPath + "ɽ¶«ÐÐÕþÇø»®Êý¾Ý.xlsx");
for (int i = 0; i < transform.childCount; i++) for (int i = 0; i < p.childCount; i++)
{ {
CityInfo c = transform.GetChild(i).GetComponent<CityInfo>(); Transform t = p.GetChild(i);
if (t.childCount > 0)
{
for (int j = 0; j < t.childCount; j++)
{
CityInfo cc = t.GetChild(j).GetComponent<CityInfo>();
cc.cityName = cc.gameObject.name;
for (int l = 0; l < manager.cityItems.Length; l++)
{
if (cc.cityName == manager.cityItems[l].districtName)
cc.distCode = manager.cityItems[l].divisionNumber;
}
}
}
else
{
CityInfo c = t.GetComponent<CityInfo>();
c.cityName = c.gameObject.name; c.cityName = c.gameObject.name;
for (int l = 0; l < manager.cityItems.Length; l++) for (int l = 0; l < manager.cityItems.Length; l++)
{ {
@ -26,6 +46,7 @@ public class TEst : MonoBehaviour
c.distCode = manager.cityItems[l].divisionNumber; c.distCode = manager.cityItems[l].divisionNumber;
} }
} }
}
} }
[ContextMenu("CreateStation")] [ContextMenu("CreateStation")]
@ -36,19 +57,37 @@ public class TEst : MonoBehaviour
DestroyImmediate(gameObjects[i]); DestroyImmediate(gameObjects[i]);
} }
gameObjects.Clear(); gameObjects.Clear();
for (int i = 0; i < transform.childCount; i++) if (isDeleteStationInstructs) return;
for (int i = 0; i < p.childCount; i++)
{ {
Transform t = transform.GetChild(i); Transform t = p.GetChild(i);
if (t.childCount > 0)
{
for (int g = 0; g < t.childCount; g++)
{
Transform tt = t.GetChild(g);
for (int j = 0; j < sprites.Count; j++) for (int j = 0; j < sprites.Count; j++)
{ {
AggregateStation _aggregateStation = Instantiate(aggregateStation, t); AggregateStation _aggregateStation = Instantiate(aggregateStation, tt);
_aggregateStation.transform.localPosition = new Vector3( Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), 2f); _aggregateStation.transform.localPosition = new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), h);
_aggregateStation.transform.localEulerAngles = new Vector3(90, 0, 0); _aggregateStation.transform.localEulerAngles = new Vector3(90, 0, 0);
_aggregateStation.SetInfo(sprites[j], "0"); _aggregateStation.SetInfo(sprites[j], "0");
gameObjects.Add(_aggregateStation.gameObject); gameObjects.Add(_aggregateStation.gameObject);
} }
}
}
else
{
for (int j = 0; j < sprites.Count; j++)
{
AggregateStation _aggregateStation = Instantiate(aggregateStation, t);
_aggregateStation.transform.localPosition = new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), h);
_aggregateStation.transform.localEulerAngles = new Vector3(90, 0, 0);
_aggregateStation.SetInfo(sprites[j], "0");
gameObjects.Add(_aggregateStation.gameObject);
}
}
} }
} }
} }

View File

@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.IO; using System.IO;
using System.Text; using System.Text;
using UnityEngine; using UnityEngine;
using UnityEngine.Networking;
namespace Adam namespace Adam
{ {
@ -82,5 +84,14 @@ namespace Adam
string path = Application.dataPath + "/StreamingAssets/" + file + "/" + fileName; string path = Application.dataPath + "/StreamingAssets/" + file + "/" + fileName;
return path; return path;
} }
public static IEnumerator GetTextAsyn(string url, Action<string> actionResult)
{
UnityWebRequest request = UnityWebRequest.Get(url);
yield return request.SendWebRequest();
string t = request.downloadHandler.text;
if (string.IsNullOrEmpty(t)) Debug.LogError("GetTextAsyn()/ Get Text is error! url:" + url);
actionResult?.Invoke(t);
}
} }
} }

View File

@ -12,14 +12,14 @@ public class WebAdapter : MonoBehaviour
[DllImport("__Internal")] [DllImport("__Internal")]
private static extern void OnLevelChange(string level); private static extern void OnLevelChange(string level);
#else #else
public string head;
public string token;
private static void OnLevelChange(string level) private static void OnLevelChange(string level)
{ {
Debug.Log(level); Debug.Log(level);
} }
#endif #endif
public UnityEvent<string> onStation; public UnityEvent<string> onStation;
public string head;
public string token;
public void LevelChange(string level) public void LevelChange(string level)
{ {
OnLevelChange(level); OnLevelChange(level);

View File

@ -88,18 +88,18 @@ MonoBehaviour:
m_PrefilterXRKeywords: 1 m_PrefilterXRKeywords: 1
m_PrefilteringModeForwardPlus: 0 m_PrefilteringModeForwardPlus: 0
m_PrefilteringModeDeferredRendering: 0 m_PrefilteringModeDeferredRendering: 0
m_PrefilteringModeScreenSpaceOcclusion: 0 m_PrefilteringModeScreenSpaceOcclusion: 2
m_PrefilterDebugKeywords: 1 m_PrefilterDebugKeywords: 1
m_PrefilterWriteRenderingLayers: 1 m_PrefilterWriteRenderingLayers: 1
m_PrefilterHDROutput: 1 m_PrefilterHDROutput: 1
m_PrefilterSSAODepthNormals: 1 m_PrefilterSSAODepthNormals: 0
m_PrefilterSSAOSourceDepthLow: 1 m_PrefilterSSAOSourceDepthLow: 1
m_PrefilterSSAOSourceDepthMedium: 1 m_PrefilterSSAOSourceDepthMedium: 1
m_PrefilterSSAOSourceDepthHigh: 1 m_PrefilterSSAOSourceDepthHigh: 1
m_PrefilterSSAOInterleaved: 1 m_PrefilterSSAOInterleaved: 1
m_PrefilterSSAOBlueNoise: 1 m_PrefilterSSAOBlueNoise: 0
m_PrefilterSSAOSampleCountLow: 1 m_PrefilterSSAOSampleCountLow: 1
m_PrefilterSSAOSampleCountMedium: 1 m_PrefilterSSAOSampleCountMedium: 0
m_PrefilterSSAOSampleCountHigh: 1 m_PrefilterSSAOSampleCountHigh: 1
m_PrefilterDBufferMRT1: 1 m_PrefilterDBufferMRT1: 1
m_PrefilterDBufferMRT2: 1 m_PrefilterDBufferMRT2: 1

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7fad919acf08dff4f876dd83912fcdc2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,4 @@
{
"地图弹出框": "http://vpp.shiyuancloud.com:1443/api/vpp-operation-service/screen/mapRegionSummary/",
"地图信息汇总": "http://vpp.shiyuancloud.com:1443/api/vpp-operation-service/screen/mapRegionStatistics/"
}

View File

@ -1,2 +0,0 @@
=http://vpp.shiyuancloud.com:1443/api/vpp-operation-service/screen/mapRegionSummary/
=http://vpp.shiyuancloud.com:1443/api/vpp-operation-service/screen/mapRegionStatistics/