Compare commits
5 Commits
9d9ed16a32
...
adff1ae9b0
| Author | SHA1 | Date |
|---|---|---|
|
|
adff1ae9b0 | |
|
|
6370664333 | |
|
|
b1f1678fab | |
|
|
3b4fb3ac95 | |
|
|
336ed418dd |
Binary file not shown.
|
|
@ -35,7 +35,7 @@ RectTransform:
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 0}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
m_SizeDelta: {x: 260, y: 50}
|
m_SizeDelta: {x: 232, y: 50}
|
||||||
m_Pivot: {x: 0, y: 1}
|
m_Pivot: {x: 0, y: 1}
|
||||||
--- !u!222 &6600844594400070395
|
--- !u!222 &6600844594400070395
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
|
@ -100,7 +100,7 @@ MonoBehaviour:
|
||||||
m_fontSizeMin: 18
|
m_fontSizeMin: 18
|
||||||
m_fontSizeMax: 72
|
m_fontSizeMax: 72
|
||||||
m_fontStyle: 0
|
m_fontStyle: 0
|
||||||
m_HorizontalAlignment: 2
|
m_HorizontalAlignment: 1
|
||||||
m_VerticalAlignment: 512
|
m_VerticalAlignment: 512
|
||||||
m_textAlignment: 65535
|
m_textAlignment: 65535
|
||||||
m_characterSpacing: 0
|
m_characterSpacing: 0
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load Diff
|
|
@ -7,6 +7,12 @@ using Adam;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
[Serializable]
|
||||||
|
public class DependencyLevel
|
||||||
|
{
|
||||||
|
public int level;
|
||||||
|
public GameObject[] objs;
|
||||||
|
}
|
||||||
|
|
||||||
public class Bootstrap : MonoSingleton<Bootstrap>
|
public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
{
|
{
|
||||||
|
|
@ -69,7 +75,8 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
[HideInInspector]
|
[HideInInspector]
|
||||||
public RayHitTester rayHitTester;
|
public RayHitTester rayHitTester;
|
||||||
public GameObject lastLand;
|
public GameObject lastLand;
|
||||||
public GameObject shadowMap;
|
[Header("ÒÀ¸½Äĸö²ã¼¶ÉϵÄÎïÌå")]
|
||||||
|
public List<DependencyLevel> dependencyLevel = new List<DependencyLevel>();
|
||||||
|
|
||||||
public int clickCurrentLevel = 2;
|
public int clickCurrentLevel = 2;
|
||||||
[ContextMenu("1")]
|
[ContextMenu("1")]
|
||||||
|
|
@ -90,9 +97,6 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//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>();
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +108,11 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
{
|
{
|
||||||
//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" };
|
||||||
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
||||||
cameraRt.OnLimitScroll += SwitchLand;
|
cameraRt.OnLimitScroll += (s) =>
|
||||||
|
{
|
||||||
|
SwitchLand(s);
|
||||||
|
webAdapter.OnLevelChange(s);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,21 +120,21 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
var hit = rayHitTester.HitTest();
|
var hit = rayHitTester.HitTest();
|
||||||
if (Input.GetMouseButtonDown(2))
|
if (Input.GetMouseButtonDown(0))
|
||||||
{
|
{
|
||||||
if (hit.collider != null)
|
if (hit.collider != null)
|
||||||
{
|
{
|
||||||
if (cameraRt.currentLevelIndex == 1) return;
|
Debug.Log("clickCurrentLevel==" + clickCurrentLevel);
|
||||||
|
if (cameraRt.currentLevelIndex == 0) return;
|
||||||
clickCurrentLevel--;
|
clickCurrentLevel--;
|
||||||
if (clickCurrentLevel <= 1)
|
if (clickCurrentLevel <= 0)
|
||||||
{
|
{
|
||||||
clickCurrentLevel = 1;
|
clickCurrentLevel = 0;
|
||||||
}
|
}
|
||||||
cameraRt.currentLevelIndex = clickCurrentLevel;
|
cameraRt.currentLevelIndex = clickCurrentLevel;
|
||||||
//currentLevel = clickCurrentLevel;
|
//currentLevel = clickCurrentLevel;
|
||||||
SwitchLand(clickCurrentLevel);
|
SwitchLand(clickCurrentLevel);
|
||||||
cameraRt.SetTarget(hit.collider.transform);
|
cameraRt.SetTarget(hit.collider.transform);
|
||||||
Debug.Log("clickCurrentLevel==" + clickCurrentLevel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hit.collider != null)
|
if (hit.collider != null)
|
||||||
|
|
@ -157,13 +165,12 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
public async void ShowLandMark()
|
public async void ShowLandMark()
|
||||||
{
|
{
|
||||||
if (currentLand == null) return;
|
if (currentLand == null) return;
|
||||||
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["ľŘÍźľŻłöżň"]}{currentDistCode}", webAdapter.head, webAdapter.token);
|
AreaData areaData = currentLand.GetComponent<CityInfo>().areaData;
|
||||||
if (!bool.Parse(areaData.success)) return;
|
if (areaData != null && !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++)
|
||||||
{
|
{
|
||||||
string info = $"{areaData.data.items[i].label}:{areaData.data.items[i].value}{areaData.data.items[i].unit}";
|
string info = $"{areaData.data.items[i].label}:{areaData.data.items[i].value}{areaData.data.items[i].unit}";
|
||||||
|
|
@ -196,11 +203,9 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
public void SwitchLand(int _currentLevel)
|
public void SwitchLand(int _currentLevel)
|
||||||
{
|
{
|
||||||
if (currentLand == null) return;
|
if (currentLand == null) return;
|
||||||
webAdapter.LevelChange(_currentLevel.ToString());
|
|
||||||
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
landMarkAndInfoCotroller.gameObject.SetActive(false);
|
||||||
currentLevel = _currentLevel;
|
currentLevel = _currentLevel;
|
||||||
clickCurrentLevel = _currentLevel;
|
clickCurrentLevel = _currentLevel;
|
||||||
shadowMap.gameObject.SetActive(false);
|
|
||||||
switch (currentLevel)
|
switch (currentLevel)
|
||||||
{
|
{
|
||||||
case 2:
|
case 2:
|
||||||
|
|
@ -210,7 +215,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:
|
||||||
|
|
@ -233,20 +238,27 @@ 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;
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < dependencyLevel.Count; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < dependencyLevel[i].objs.Length; j++)
|
||||||
|
{
|
||||||
|
dependencyLevel[i].objs[j].SetActive(dependencyLevel[i].level == currentLevel);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -258,7 +270,6 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
tween.Kill(true);
|
tween.Kill(true);
|
||||||
_fadeTweens.Remove(parent);
|
_fadeTweens.Remove(parent);
|
||||||
}
|
}
|
||||||
//bool isChange = true;
|
|
||||||
var renderers = GetMeshRenderers(parent);
|
var renderers = GetMeshRenderers(parent);
|
||||||
List<Material> currentMaters = new List<Material>();
|
List<Material> currentMaters = new List<Material>();
|
||||||
for (int i = 0; i < renderers.Count; i++)
|
for (int i = 0; i < renderers.Count; i++)
|
||||||
|
|
@ -282,6 +293,14 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
{
|
{
|
||||||
renderers[i].GetComponent<Collider>().enabled = true;
|
renderers[i].GetComponent<Collider>().enabled = true;
|
||||||
renderers[i].materials = mat;
|
renderers[i].materials = mat;
|
||||||
|
if (renderers[i].transform.childCount > 0)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < renderers[i].transform.childCount; j++)
|
||||||
|
{
|
||||||
|
bool isShow = renderers[i].transform.GetChild(j).GetComponent<AggregateStation>().isHaveValue;
|
||||||
|
renderers[i].transform.GetChild(j).gameObject.SetActive(isShow);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_fadeTweens.Remove(parent);
|
_fadeTweens.Remove(parent);
|
||||||
});
|
});
|
||||||
|
|
@ -301,6 +320,13 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
{
|
{
|
||||||
renderers[i].GetComponent<Collider>().enabled = false;
|
renderers[i].GetComponent<Collider>().enabled = false;
|
||||||
renderers[i].materials = opacity;
|
renderers[i].materials = opacity;
|
||||||
|
if (renderers[i].transform.childCount > 0)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < renderers[i].transform.childCount; j++)
|
||||||
|
{
|
||||||
|
renderers[i].transform.GetChild(j).gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
List<Material> currentMaters = new List<Material>();
|
List<Material> currentMaters = new List<Material>();
|
||||||
for (int i = 0; i < renderers.Count; i++)
|
for (int i = 0; i < renderers.Count; i++)
|
||||||
|
|
@ -343,7 +369,7 @@ public class Bootstrap : MonoSingleton<Bootstrap>
|
||||||
switch (currentLevel)
|
switch (currentLevel)
|
||||||
{
|
{
|
||||||
case -1:
|
case -1:
|
||||||
cameraRt.SetMaxMinDistance(30f, 120f);
|
cameraRt.SetMaxMinDistance(10f, 120f);
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
cameraRt.SetMaxMinDistance(10f, 20f);
|
cameraRt.SetMaxMinDistance(10f, 20f);
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ public class CameraRT : MonoBehaviour
|
||||||
bool isAutoRotating = false;
|
bool isAutoRotating = false;
|
||||||
|
|
||||||
public bool isMove = true;
|
public bool isMove = true;
|
||||||
|
public bool isRotate = true;
|
||||||
public int[] levels;
|
public int[] levels;
|
||||||
//动态调节相机缩放的灵敏度
|
//动态调节相机缩放的灵敏度
|
||||||
float tempSpeed;
|
float tempSpeed;
|
||||||
|
|
@ -156,7 +157,8 @@ public class CameraRT : MonoBehaviour
|
||||||
Scroll();
|
Scroll();
|
||||||
if (isMove)
|
if (isMove)
|
||||||
Move();
|
Move();
|
||||||
Rotate();
|
if (isRotate)
|
||||||
|
Rotate();
|
||||||
|
|
||||||
Quaternion rotation = Quaternion.Euler(y, x, z);
|
Quaternion rotation = Quaternion.Euler(y, x, z);
|
||||||
Vector3 disVector = new Vector3(0.0f, 0.0f, -distance);
|
Vector3 disVector = new Vector3(0.0f, 0.0f, -distance);
|
||||||
|
|
@ -174,7 +176,7 @@ public class CameraRT : MonoBehaviour
|
||||||
cam.transform.position = position;
|
cam.transform.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -245,7 +247,7 @@ public class CameraRT : MonoBehaviour
|
||||||
|
|
||||||
if (currentLevelIndex != lastLevelIndex)
|
if (currentLevelIndex != lastLevelIndex)
|
||||||
{
|
{
|
||||||
//Debug.Log($"currentLevelIndex=={currentLevelIndex}");
|
Debug.Log($"UnityLog=currentLevelIndex=={currentLevelIndex}");
|
||||||
OnLimitScroll?.Invoke(currentLevelIndex);
|
OnLimitScroll?.Invoke(currentLevelIndex);
|
||||||
lastLevelIndex = currentLevelIndex;
|
lastLevelIndex = currentLevelIndex;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ public class AggregateStation : MonoBehaviour
|
||||||
|
|
||||||
public SpriteRenderer instruct;
|
public SpriteRenderer instruct;
|
||||||
public TMP_Text instructInfo;
|
public TMP_Text instructInfo;
|
||||||
|
public bool isHaveValue;
|
||||||
public void SetInfo(Sprite stationIcon, string num)
|
public void SetInfo(Sprite stationIcon, string num)
|
||||||
{
|
{
|
||||||
instruct.sprite = stationIcon;
|
instruct.sprite = stationIcon;
|
||||||
|
|
@ -17,5 +18,6 @@ public class AggregateStation : MonoBehaviour
|
||||||
{
|
{
|
||||||
instructInfo.text = num;
|
instructInfo.text = num;
|
||||||
gameObject.SetActive(num != "0");
|
gameObject.SetActive(num != "0");
|
||||||
|
isHaveValue = num != "0" ? true : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,17 +7,54 @@ public class CityInfo : MonoBehaviour
|
||||||
public string distCode;
|
public string distCode;
|
||||||
public string cityName;
|
public string cityName;
|
||||||
public ScreenTopStatistics sts = new ScreenTopStatistics();
|
public ScreenTopStatistics sts = new ScreenTopStatistics();
|
||||||
|
public AreaData areaData = new AreaData();
|
||||||
|
public int Level = 0;
|
||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
if (!GetComponent<Collider>())
|
if (!GetComponent<Collider>())
|
||||||
gameObject.AddComponent<MeshCollider>();
|
gameObject.AddComponent<MeshCollider>();
|
||||||
|
|
||||||
|
}
|
||||||
|
public void Init()
|
||||||
|
{
|
||||||
OnSetStationInfo();
|
OnSetStationInfo();
|
||||||
|
GetAreaData();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void OnSetStationInfo()
|
public async void OnSetStationInfo()
|
||||||
{
|
{
|
||||||
sts = await DataController.Instance.GetProvincialLevelStationInfo(distCode,cityName);
|
if (!string.IsNullOrEmpty(distCode) && distCode.Length == 6 && Level != 3)
|
||||||
|
{
|
||||||
|
DataController.Instance.loadingScreenTopStatisticsTasks.Add(DataController.Instance.GetProvincialLevelStationInfo(distCode, cityName));
|
||||||
|
sts = await DataController.Instance.GetProvincialLevelStationInfo(distCode, cityName);
|
||||||
|
}
|
||||||
|
else if (!string.IsNullOrEmpty(distCode) && distCode.Length == 4 && Level != 3)
|
||||||
|
sts = DataController.Instance.GetProvincialLevelStationDataByDistCode(distCode);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
SetScreenTopStatistices(sts);
|
||||||
|
if (!string.IsNullOrEmpty(distCode) && distCode.Length == 6 && transform.parent.gameObject.activeSelf && Level != 3)
|
||||||
|
transform.parent.gameObject.SetActive(false);
|
||||||
|
if (Level == 3)
|
||||||
|
gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void GetAreaData()
|
||||||
|
{
|
||||||
|
if (Level != 3)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(distCode))
|
||||||
|
{
|
||||||
|
DataController.Instance.loadingAreaDataTasks.Add(DataController.Instance.GetAreaDataByDistCode(distCode));
|
||||||
|
areaData = await DataController.Instance.GetAreaDataByDistCode(distCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetScreenTopStatistices(ScreenTopStatistics sts)
|
||||||
|
{
|
||||||
if (sts != null)
|
if (sts != null)
|
||||||
{
|
{
|
||||||
transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(sts.agentCons);
|
transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(sts.agentCons);
|
||||||
|
|
@ -34,9 +71,25 @@ public class CityInfo : MonoBehaviour
|
||||||
transform.GetChild(i).gameObject.SetActive(false);
|
transform.GetChild(i).gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetAreaData(AreaData a)
|
||||||
|
{
|
||||||
|
if (Level == 3)
|
||||||
|
{
|
||||||
|
areaData = a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetStationData(ScreenTopStatistics s)
|
||||||
|
{
|
||||||
|
if (Level == 3)
|
||||||
|
{
|
||||||
|
sts = s;
|
||||||
|
SetScreenTopStatistices(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,29 +8,30 @@ using UnityEngine;
|
||||||
//@description:
|
//@description:
|
||||||
//============================================================
|
//============================================================
|
||||||
|
|
||||||
public class DistanceAdjuster : MonoBehaviour
|
public class DistanceAdjuster : MonoBehaviour
|
||||||
{
|
{
|
||||||
public float minDistance = 100;
|
public float minDistance = 10;
|
||||||
public float maxDistance = 300;
|
public float maxDistance = 120;
|
||||||
public float minScale = 1;
|
private float minScale = 0.3f;
|
||||||
public float maxScale = 1;
|
public float maxScale = 1;
|
||||||
private Camera _camera;
|
private Camera _camera;
|
||||||
// Use this for initialization
|
// Use this for initialization
|
||||||
private void Start () {
|
private void Start()
|
||||||
_camera = Camera.main;
|
{
|
||||||
}
|
_camera = Camera.main;
|
||||||
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
var d = Vector3.Distance(transform.position, _camera.transform.position);
|
var d = Vector3.Distance(transform.position, _camera.transform.position);
|
||||||
var s = Remap(d, minDistance, maxDistance, minScale, maxScale);
|
var s = Remap(d, minDistance, maxDistance, minScale, maxScale);
|
||||||
s= Mathf.Max(s, minScale);
|
s = Mathf.Max(s, minScale);
|
||||||
s= Mathf.Min(s, maxScale);
|
s = Mathf.Min(s, maxScale);
|
||||||
transform.localScale = Vector3.one * s;
|
transform.localScale = Vector3.one * s;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float Remap(float value, float inMin, float inMax, float outMin, float outMax)
|
private float Remap(float value, float inMin, float inMax, float outMin, float outMax)
|
||||||
{
|
{
|
||||||
return (value - inMin) / (inMax - inMin) * (outMax - outMin) + outMin;
|
return (value - inMin) / (inMax - inMin) * (outMax - outMin) + outMin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,22 @@ public class AreaStationData
|
||||||
public string msg ;
|
public string msg ;
|
||||||
}
|
}
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
public class DataItem
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public string distCode;
|
||||||
|
/// <summary>
|
||||||
|
/// 济南市
|
||||||
|
/// </summary>
|
||||||
|
public string disName;
|
||||||
|
/// <summary>
|
||||||
|
/// 用户资源统计
|
||||||
|
/// </summary>
|
||||||
|
public ScreenTopStatistics screenTopStatistics;
|
||||||
|
}
|
||||||
|
[Serializable]
|
||||||
public class ScreenTopStatistics
|
public class ScreenTopStatistics
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -57,19 +73,4 @@ public class ScreenTopStatistics
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string airCondition ;
|
public string airCondition ;
|
||||||
}
|
}
|
||||||
[Serializable]
|
|
||||||
public class DataItem
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public string distCode ;
|
|
||||||
/// <summary>
|
|
||||||
/// 济南市
|
|
||||||
/// </summary>
|
|
||||||
public string disName ;
|
|
||||||
/// <summary>
|
|
||||||
/// 用户资源统计
|
|
||||||
/// </summary>
|
|
||||||
public ScreenTopStatistics screenTopStatistics ;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -6,13 +6,50 @@ using UnityEngine;
|
||||||
public class DataController : MonoSingleton<DataController>
|
public class DataController : MonoSingleton<DataController>
|
||||||
{
|
{
|
||||||
public string distCode;
|
public string distCode;
|
||||||
// Start is called before the first frame update
|
private AreaStationData areaStationData = new AreaStationData();
|
||||||
|
private CityInfo[] cityInfos;
|
||||||
|
|
||||||
|
[HideInInspector]
|
||||||
|
public List<UniTask<AreaData>> loadingAreaDataTasks = new List<UniTask<AreaData>>();
|
||||||
|
[HideInInspector]
|
||||||
|
public List<UniTask<ScreenTopStatistics>> loadingScreenTopStatisticsTasks = new List<UniTask<ScreenTopStatistics>>();
|
||||||
|
|
||||||
|
|
||||||
|
private AreaData[] areaDatas;
|
||||||
|
private ScreenTopStatistics[] screenTopStatistics;
|
||||||
|
|
||||||
|
private async void Start()
|
||||||
|
{
|
||||||
|
await UniTask.Delay(1);
|
||||||
|
areaStationData = await GetProvincialLevelStationData("37");
|
||||||
|
cityInfos = transform.GetComponentsInChildren<CityInfo>();
|
||||||
|
for (int i = 0; i < cityInfos.Length; i++)
|
||||||
|
{
|
||||||
|
cityInfos[i].Init();
|
||||||
|
}
|
||||||
|
areaDatas = await UniTask.WhenAll(loadingAreaDataTasks);
|
||||||
|
for (int i = 0; i < cityInfos.Length; i++)
|
||||||
|
{
|
||||||
|
string distCodeTemp = cityInfos[i].distCode;
|
||||||
|
cityInfos[i].SetAreaData(GetAreaDateByDistCode(distCodeTemp));
|
||||||
|
}
|
||||||
|
screenTopStatistics = await UniTask.WhenAll(loadingScreenTopStatisticsTasks);
|
||||||
|
for (int i = 0; i < cityInfos.Length; i++)
|
||||||
|
{
|
||||||
|
string distCodeTemp = cityInfos[i].distCode;
|
||||||
|
cityInfos[i].SetStationData(GetAreLevelStationDataByDistCode(distCodeTemp));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 针对市级
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_distCode"></param>
|
||||||
|
/// <param name="_disName"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public async UniTask<ScreenTopStatistics> GetProvincialLevelStationInfo(string _distCode, string _disName)
|
public async UniTask<ScreenTopStatistics> GetProvincialLevelStationInfo(string _distCode, string _disName)
|
||||||
{
|
{
|
||||||
await UniTask.Delay(1000);
|
|
||||||
if (_distCode.Length == 4)
|
|
||||||
distCode = _distCode.Substring(0, 2);
|
|
||||||
if (_distCode.Length == 6)
|
if (_distCode.Length == 6)
|
||||||
distCode = _distCode.Substring(0, 4);
|
distCode = _distCode.Substring(0, 4);
|
||||||
string url = Bootstrap.Instance.urlDic["地图信息汇总"];
|
string url = Bootstrap.Instance.urlDic["地图信息汇总"];
|
||||||
|
|
@ -22,4 +59,78 @@ public class DataController : MonoSingleton<DataController>
|
||||||
return null;
|
return null;
|
||||||
return sts.screenTopStatistics;
|
return sts.screenTopStatistics;
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 通过市级视角去获取数据 针对区县
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_distCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ScreenTopStatistics GetAreLevelStationDataByDistCode(string _distCode)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < screenTopStatistics.Length; i++)
|
||||||
|
{
|
||||||
|
if (screenTopStatistics[i] != null && screenTopStatistics[i].distCode == _distCode)
|
||||||
|
{
|
||||||
|
return screenTopStatistics[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 针对市级区域
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_distCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ScreenTopStatistics GetProvincialLevelStationDataByDistCode(string _distCode)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < areaStationData.data.Count; i++)
|
||||||
|
{
|
||||||
|
if (areaStationData.data[i].distCode == _distCode)
|
||||||
|
{
|
||||||
|
return areaStationData.data[i].screenTopStatistics;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取每个区域的聚合信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_distCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async UniTask<AreaData> GetAreaDataByDistCode(string _distCode)
|
||||||
|
{
|
||||||
|
await UniTask.Delay(2);
|
||||||
|
string url = Bootstrap.Instance.urlDic["地图弹出框"];
|
||||||
|
AreaData areaData = await AsyncWebReq.Get<AreaData>($"{url}{_distCode}", Bootstrap.Instance.webAdapter.head, Bootstrap.Instance.webAdapter.token);
|
||||||
|
if ( !bool.Parse(areaData.success)) return null;
|
||||||
|
return areaData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AreaData GetAreaDateByDistCode(string _distCode)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < areaDatas.Length; i++)
|
||||||
|
{
|
||||||
|
if (areaDatas[i].data.distCode == _distCode)
|
||||||
|
{
|
||||||
|
return areaDatas[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取地图汇总
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="_distCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private async UniTask<AreaStationData> GetProvincialLevelStationData(string _distCode)
|
||||||
|
{
|
||||||
|
string url = Bootstrap.Instance.urlDic["地图信息汇总"];
|
||||||
|
AreaStationData areaStationData = await AsyncWebReq.Get<AreaStationData>(url + _distCode, Bootstrap.Instance.webAdapter.head, Bootstrap.Instance.webAdapter.token);
|
||||||
|
return areaStationData;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,31 +10,35 @@ public class WebAdapter : MonoBehaviour
|
||||||
public string head;
|
public string head;
|
||||||
public string token;
|
public string token;
|
||||||
[DllImport("__Internal")]
|
[DllImport("__Internal")]
|
||||||
private static extern void OnLevelChange(string level);
|
private static extern void LevelChange(int _level);
|
||||||
#else
|
#else
|
||||||
public string head;
|
public string head;
|
||||||
public string token;
|
public string token;
|
||||||
private static void OnLevelChange(string level)
|
private static void LevelChange(int _level)
|
||||||
{
|
{
|
||||||
Debug.Log(level);
|
//Debug.Log(level);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
public UnityEvent<string> onStation;
|
public UnityEvent<string> onStation;
|
||||||
public void LevelChange(string level)
|
public void OnLevelChange(int _level)
|
||||||
{
|
{
|
||||||
OnLevelChange(level);
|
LevelChange(_level);
|
||||||
|
//Debug.Log("UnityLog==level==" + _level);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnStation(string station)
|
public void OnStation(string station)
|
||||||
{
|
{
|
||||||
onStation?.Invoke(station);
|
onStation?.Invoke(station);
|
||||||
|
Debug.Log("UnityLog==station==" + station);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetHeadAndToken(string _headAndToken)
|
public void SetHeadAndToken(string _headAndToken)
|
||||||
{
|
{
|
||||||
string[] data = _headAndToken.Split("+");
|
string[] data = _headAndToken.Split("+");
|
||||||
head = data[0].Replace(" ", "");
|
head = data[0];
|
||||||
token = data[1].Replace(" ", "");
|
token = data[1];
|
||||||
|
Debug.Log("UnityLog==head==" + head);
|
||||||
|
Debug.Log("UnityLog==token==" + token);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,6 @@ GameObject:
|
||||||
- component: {fileID: 8450930769468669304}
|
- component: {fileID: 8450930769468669304}
|
||||||
- component: {fileID: 4813033407047159934}
|
- component: {fileID: 4813033407047159934}
|
||||||
- component: {fileID: 6902716355753532296}
|
- component: {fileID: 6902716355753532296}
|
||||||
- component: {fileID: 686787467225068926}
|
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: map
|
m_Name: map
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
|
|
@ -84,25 +83,3 @@ MeshRenderer:
|
||||||
m_SortingLayer: 0
|
m_SortingLayer: 0
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
m_AdditionalVertexStreams: {fileID: 0}
|
m_AdditionalVertexStreams: {fileID: 0}
|
||||||
--- !u!64 &686787467225068926
|
|
||||||
MeshCollider:
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_GameObject: {fileID: 8874296918683621621}
|
|
||||||
m_Material: {fileID: 0}
|
|
||||||
m_IncludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_ExcludeLayers:
|
|
||||||
serializedVersion: 2
|
|
||||||
m_Bits: 0
|
|
||||||
m_LayerOverridePriority: 0
|
|
||||||
m_IsTrigger: 0
|
|
||||||
m_ProvidesContacts: 0
|
|
||||||
m_Enabled: 1
|
|
||||||
serializedVersion: 5
|
|
||||||
m_Convex: 0
|
|
||||||
m_CookingOptions: 30
|
|
||||||
m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
mergeInto(LibraryManager.library, {
|
mergeInto(LibraryManager.library, {
|
||||||
OnLevelChange: function (level) {
|
LevelChange: function(level){
|
||||||
_OnLevelChange(Pointer_stringify(level))
|
OnLevelChange(level);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: ff73f99e1c44b6343b9263813d2918fb
|
guid: ae6e8e62919c37440ac1dcf99066b1e3
|
||||||
PluginImporter:
|
PluginImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Reference in New Issue