网演高层钦州
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

107 lines
3.4 KiB

using AX.MessageSystem;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 到场力量界面
/// </summary>
public class ThePowerToPresentPanel : MonoBehaviour
{
//到场力量消防车信息父类
private Transform mArrivedCarParent;
//到场力量消防车信息预设
private GameObject mArrivedCarPrefab;
private List<KeyValuePair<FireCarEngine, int>> MyCarList = new List<KeyValuePair<FireCarEngine, int>>();
private Dictionary<string, List<KeyValuePair<FireCarEngine, int>>> mMyFireTrucks =
new Dictionary<string, List<KeyValuePair<FireCarEngine, int>>>();
//按中队、车类型组织车辆数据(string:组织机构;List<KeyValuePair<FireCarEngine, int>:某类型车有多少辆)
//private Dictionary<string, List<KeyValuePair<FireCarEngine, int>>> mOrgCars =
// new Dictionary<string, List<KeyValuePair<FireCarEngine, int>>>();
private Toggle mTgl;
private void Awake()
{
MessageDispatcher.AddListener(FireInfoMessage.ArrivedForce.ToString(), ShowThePowerToPresentPanel);
Init();
gameObject.SetActive(false);
}
private void OnEnable()
{
mMyFireTrucks = PowerPresentData.Instance.GetAllPresentCar();
DeleEnginesUI();
MyCarList.Clear();
foreach (var mFireTruck in mMyFireTrucks.Values)
{
MyCarList.AddRange(mFireTruck);
}
ShowArrivedTruckMessage(MyCarList);
}
private void OnDisable()
{
MessageDispatcher.AddListener(FireInfoMessage.ArrivedForce.ToString(), ShowThePowerToPresentPanel);
}
private void DeleEnginesUI()
{
foreach (Transform dept in mArrivedCarParent.transform)
{
Destroy(dept.gameObject);
}
}
/// <summary>
/// 打开,显示到场力量面板
/// </summary>
/// <param name="obj"></param>
private void ShowThePowerToPresentPanel(IMessage obj)
{
bool b = (bool)obj.Data;
gameObject.SetActive(b);
}
void Init()
{
mTgl = transform.parent.transform.Find("TopPanel/Tool/FireInfo/FireSiteInfoPopup/Background/Item (4)/4").GetComponent<Toggle>();
mArrivedCarParent = transform.Find("Body/Scroll View/Viewport/Content");
mArrivedCarPrefab = Resources.Load("ArrivedCarMsg") as GameObject;
}
void ShowArrivedTruckMessage(List<KeyValuePair<FireCarEngine, int>> CarList)
{
CarArrivedMsgShow(CarList);
if (!gameObject.activeSelf)
{
gameObject.SetActive(true);
}
}
void CarArrivedMsgShow(List<KeyValuePair<FireCarEngine, int>> ShowCarList)
{
foreach (Transform t in mArrivedCarParent)
{
Destroy(t.gameObject);
}
if (ShowCarList.Count > 0)
{
foreach (KeyValuePair<FireCarEngine, int> item in ShowCarList)
{
GameObject c = Instantiate(mArrivedCarPrefab, mArrivedCarParent);
c.transform.Find("FireTruckNameAText").GetComponent<Text>().text = item.Key.TypeName;
c.transform.Find("FireTruckNumAText").GetComponent<Text>().text = item.Value.ToString();
}
}
}
/// <summary>
/// 关闭面板
/// </summary>
public void CloseThePowerToPresentPanel()
{
gameObject.SetActive(false);
mTgl.isOn = false;
}
}