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

170 lines
4.8 KiB
C#
Raw Blame History

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;
public Vector2D LA;
public Vector2D LB;
public Vector2D LC;
public Vector2D VA;
public Vector2D VB;
public Vector2D VC;
private void Awake()
{
if (Level != 3)
{
if (!GetComponent<Collider>())
gameObject.AddComponent<MeshCollider>();
if (transform.childCount > 0)
{
tips = transform.GetChild(0).gameObject;
tips.AddComponent<DistanceAdjuster>();
tips.SetActive(false);
}
}
if (transform.childCount > 0 && transform.GetChild(0).childCount > 0)
{
Transform a = transform.GetChild(0).transform.Find("1");
if (a != null)
{
VA.x = a.position.x;
VA.y = a.position.z;
}
Transform b = transform.GetChild(0).transform.Find("2");
if (b != null)
{
VB.x = b.position.x;
VB.y = b.position.z;
}
Transform c = transform.GetChild(0).transform.Find("3");
if (c != null)
{
VC.x = c.position.x;
VC.y = c.position.z;
}
}
}
public void Init()
{
OnSetStationInfo();
//GetAreaData();
}
public void SetOriginalVectorAndL()
{
WebApiExtension.SetVector2D(LA, LB, LC, VA, VB, VC);
}
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.GetAreaPopUpDataByDistCode(distCode));
//areaData = await DataController.Instance.GetAreaDataByDistCode(distCode);
}
}
}
public void SetScreenTopStatistices(int stationIndex)
{
if (Level == 3) return;
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;
}
}