上海虹口龙之梦项目
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.
 
 
 
 

99 lines
3.3 KiB

using AillieoUtils;
using System.Collections;
using System.Collections.Generic;
using System.Security.Claims;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// 人员定位面板
/// </summary>
public class PersonnelLocationPanel : UIView
{
public ScrollView alarmScrollView;
public ScrollView employeeScrollView;
public List<GameObject> locationCards = new List<GameObject>();
public List<EmployeeItem> items = new List<EmployeeItem>();
public Toggle showAll;
public Color chaiXieColor = Color.white;
public Color diDianColor = Color.white;
public Color sosColor = Color.white;
public Color xinlvColor = Color.white;
public Color jinruColor = Color.white;
public Color likaiColor = Color.white;
public Color biaoqianColor = Color.white;
public Color quyuchaoyuanColor = Color.white;
private string alarmUrl = "";
public Dictionary<int, Color> AlarmColor = new Dictionary<int, Color>();
public override void Awake()
{
base.Awake();
showAll.onValueChanged.AddListener(v => Main.Event.EmployeeItemActive(v));
LoadTags(Config.Tags);
AlarmColor.Add(1, chaiXieColor);
AlarmColor.Add(2, diDianColor);
AlarmColor.Add(3, sosColor);
AlarmColor.Add(4, xinlvColor);
AlarmColor.Add(5, jinruColor);
AlarmColor.Add(6, likaiColor);
AlarmColor.Add(10, biaoqianColor);
AlarmColor.Add(13, quyuchaoyuanColor);
alarmUrl = $"{Config.AlarmServer}/prod-api/dingweiRest/apiGetAlarmDatas";
Debug.Log(alarmUrl);
}
private void Start()
{
InvokeRepeating("GetAlarmData", 0, Config.AlarmInterval);
}
private void GetAlarmData()
{
HttpManager.Instance.Post<AlarmData>(alarmUrl, tempData =>
{
if (tempData.ErrorCode == 1)
{
if (tempData.List.Count > 0)
{
alarmScrollView.SetUpdateFunc((index, item) =>
{
var data = tempData.List[index];
item.gameObject.SetActive(true);
item.GetComponent<AlarmItem>().Set(data, AlarmColor);
item.GetComponent<AlarmItem>().alarml = data;
});
alarmScrollView.SetItemCountFunc(() => tempData.List.Count);
alarmScrollView.UpdateData(false);
}
}
});
}
private void LoadTags(List<string> tags)
{
employeeScrollView.SetUpdateFunc((index, item) =>
{
string info = tags[index];
item.gameObject.SetActive(true);
item.name = info;
item.GetComponent<EmployeeItem>().targetNo=long.Parse(info);
item.transform.Find("CardNumber").GetComponent<Text>().text=info;
locationCards.Add(item.gameObject);
items.Add(item.GetComponent<EmployeeItem>());
item.Find("Show").GetComponent<Toggle>().onValueChanged.AddListener(v => Main.Event.EmployeeActive(long.Parse(info), v));
item.Find("Track").GetComponent<Toggle>().onValueChanged.AddListener(v => Main.LocationSimulator.GetTrackPlaybackData(v, long.Parse(info)));
});
employeeScrollView.SetItemCountFunc(() => tags.Count);
employeeScrollView.UpdateData(false);
}
}