ShanDongVirtualPowerPlant/u3d-ShanDongVirtualPowerPlant/Assets/Adam/Scripts/Components/CityInfo.cs

132 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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(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 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(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)
{
if (Level == 3)
{
areaData = a;
}
}
public void SetStationData(ScreenTopStatistics s)
{
if (Level == 3)
{
sts = s;
SetScreenTopStatistices(0);
}
}
/// <summary>
/// 0-代理用户1-微电网2-储能电站3-光伏电站4-风电站5-充电站6-楼宇空调
/// </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;
}
}