128 lines
3.8 KiB
C#
128 lines
3.8 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;
|
||
public GameObject tips;
|
||
private void Awake()
|
||
{
|
||
if (!GetComponent<Collider>())
|
||
gameObject.AddComponent<MeshCollider>();
|
||
if (transform.childCount > 0)
|
||
{
|
||
tips = transform.GetChild(0).gameObject;
|
||
tips.AddComponent<DistanceAdjuster>();
|
||
tips.SetActive(false);
|
||
}
|
||
}
|
||
public void Init()
|
||
{
|
||
OnSetStationInfo();
|
||
GetAreaData();
|
||
|
||
}
|
||
|
||
public void OnSetStationInfo()
|
||
{
|
||
if (!string.IsNullOrEmpty(distCode) && distCode.Length == 4 && Level != 3)
|
||
{
|
||
sts = DataController.Instance.GetProvincialLevelStationDataByDistCode(distCode);
|
||
DataController.Instance.loadingScreenTopStatisticsTasks.Add(DataController.Instance.GetProvincialLevelStationData(distCode));
|
||
}
|
||
|
||
SetScreenTopStatistices(0);
|
||
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 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(int stationIndex)
|
||
{
|
||
if (transform.childCount == 0) return;
|
||
if (sts != null && !string.IsNullOrEmpty(sts.distCode))
|
||
{
|
||
transform.GetChild(0).GetComponent<AggregateStation>().SetInfo(CheckCurrentStation(stationIndex)[0], CheckCurrentStation(stationIndex)[1]);
|
||
}
|
||
else
|
||
{
|
||
transform.GetChild(0).gameObject.SetActive(false);
|
||
}
|
||
|
||
}
|
||
|
||
public void SetAreaData(AreaData a)
|
||
{
|
||
areaData = a;
|
||
}
|
||
|
||
public void SetStationData(ScreenTopStatistics s)
|
||
{
|
||
sts = s;
|
||
SetScreenTopStatistices(0);
|
||
}
|
||
/// <summary>
|
||
/// 0-<2D><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD>1-<><CEA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2-<2D><><EFBFBD>ܵ<EFBFBD>վ<EFBFBD><D5BE>3-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>վ<EFBFBD><D5BE>4-<2D><><EFBFBD><EFBFBD>վ<EFBFBD><D5BE>5-<2D><><EFBFBD><EFBFBD>վ<EFBFBD><D5BE>6-¥<><C2A5><EFBFBD>յ<EFBFBD>
|
||
/// </summary>
|
||
/// <param name="stationIndex"></param>
|
||
/// <returns></returns>
|
||
public List<string> CheckCurrentStation(int stationIndex)
|
||
{
|
||
List<string> temp = new List<string>();
|
||
switch (stationIndex)
|
||
{
|
||
case 0:
|
||
temp.Add(sts.agentCons);
|
||
temp.Add(sts.agentConsRegulateCap);
|
||
break;
|
||
case 1:
|
||
temp.Add(sts.microGrid);
|
||
temp.Add(sts.microGridRegulateCap);
|
||
break;
|
||
case 2:
|
||
temp.Add(sts.energyStation);
|
||
temp.Add(sts.energyStationRegulateCap);
|
||
break;
|
||
case 3:
|
||
temp.Add(sts.phoStation);
|
||
temp.Add(sts.phoStationRegulateCap);
|
||
break;
|
||
case 4:
|
||
temp.Add(sts.windStation);
|
||
temp.Add(sts.windStationRegulateCap);
|
||
break;
|
||
case 5:
|
||
temp.Add(sts.chargeStation);
|
||
temp.Add(sts.chargeStationRegulateCap);
|
||
break;
|
||
case 6:
|
||
temp.Add(sts.airCondition);
|
||
temp.Add(sts.airConditionRegulateCap);
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
return temp;
|
||
}
|
||
}
|
||
|
||
|