96 lines
2.9 KiB
C#
96 lines
2.9 KiB
C#
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();
|
|
public int Level = 0;
|
|
private void Start()
|
|
{
|
|
if (!GetComponent<Collider>())
|
|
gameObject.AddComponent<MeshCollider>();
|
|
|
|
}
|
|
public void Init()
|
|
{
|
|
OnSetStationInfo();
|
|
GetAreaData();
|
|
}
|
|
|
|
public async void OnSetStationInfo()
|
|
{
|
|
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)
|
|
{
|
|
transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(sts.agentCons);
|
|
transform.GetChild(1).GetComponent<AggregateStation>().SetInfo(sts.energyStation);
|
|
transform.GetChild(2).GetComponent<AggregateStation>().SetInfo(sts.phoStation);
|
|
transform.GetChild(3).GetComponent<AggregateStation>().SetInfo(sts.microGrid);
|
|
transform.GetChild(4).GetComponent<AggregateStation>().SetInfo(sts.airCondition);
|
|
transform.GetChild(5).GetComponent<AggregateStation>().SetInfo(sts.windStation);
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
|