using System.Collections; using System.Collections.Generic; using UnityEngine; public class CityInfo : MonoBehaviour { public string distCode; public string cityName; public ScreenTopStatistics sts = new ScreenTopStatistics(); public AreaData areaData = new AreaData(); private void Start() { if (!GetComponent()) gameObject.AddComponent(); } public void Init() { OnSetStationInfo(); GetAreaData(); } public async void OnSetStationInfo() { if (distCode.Length == 6) sts = await DataController.Instance.GetProvincialLevelStationInfo(distCode, cityName); else sts = DataController.Instance.GetProvincialLevelStationDataByDistCode(distCode); if (sts != null) { transform.GetChild(0).GetComponent().SetInfo(sts.agentCons); transform.GetChild(1).GetComponent().SetInfo(sts.energyStation); transform.GetChild(2).GetComponent().SetInfo(sts.phoStation); transform.GetChild(3).GetComponent().SetInfo(sts.microGrid); transform.GetChild(4).GetComponent().SetInfo(sts.airCondition); transform.GetChild(5).GetComponent().SetInfo(sts.windStation); } else { for (int i = 0; i < transform.childCount; i++) { transform.GetChild(i).gameObject.SetActive(false); } } if (distCode.Length == 6 && transform.parent.gameObject.activeSelf) transform.parent.gameObject.SetActive(false); } public async void GetAreaData() { if (!string.IsNullOrEmpty(distCode)) areaData = await DataController.Instance.GetAreaDataByDistCode(distCode); } }