/// <summary> /// 设置人员历史所在区域 /// </summary> public void SetItemArea(Personnel p, string areaStr) { HistoryPersonUIItem item = items.Find((i) => i.personnel == p); if (item != null) { item.RefleshTxtPlace(areaStr); } }
/// <summary> /// 移除显示轨迹中的某个人员 /// </summary> /// <param name="personnelT"></param> public void RemovePerson(Personnel personnelT) { currentPersonnels.Remove(personnelT); //List<HistoryPersonUIItem> pList = new List<HistoryPersonUIItem>(personsGrid.GetComponentsInChildren<HistoryPersonUIItem>()); //HistoryPersonUIItem item = pList.Find((i) => i.personnel == personnelT); HistoryPersonUIItem item = items.Find((i) => i.personnel == personnelT); DestroyImmediate(item.gameObject); items.Remove(item); }
/// <summary> /// 创建人员列表 /// </summary> public HistoryPersonUIItem CreatePersonItem(Personnel personnelT, Color colorT) { HistoryPersonUIItem item = Instantiate(PersonItemPrefab); item.Init(personnelT, colorT); item.transform.SetParent(personsGrid.transform); item.transform.localPosition = Vector3.zero; item.transform.localScale = Vector3.one; item.gameObject.SetActive(true); return(item); }
Position firstPoint = null;//第一个点的位置 自动移动进度条到该点 /// <summary> /// 显示某个标签的历史数据 /// </summary> /// <param name="code"></param> public void ShowHistoryData() { if (isLoadDataSuccessed) { return; } //LocationManager.Instance.ClearHistoryPaths(); //string code = "0002"; List <HistoryPersonUIItem> historyPersonUIItems = personsGrid.GetComponentsInChildren <HistoryPersonUIItem>().ToList(); DateTime end = GetEndTime(); DateTime start = GetStartTime(); List <List <Position> > psList = new List <List <Position> >(); personnel_Points = new Dictionary <Personnel, List <Position> >(); //List<Position> ps = new List<Position>(); List <LocationHistoryPath_M> paths = new List <LocationHistoryPath_M>(); progressbarLoadValue = 0; List <int> topoNodeIds = RoomFactory.Instance.GetCurrentDepNodeChildNodeIds(SceneEvents.DepNode); Loom.StartSingleThread(() => { firstPoint = null; foreach (Personnel p in currentPersonnels) { List <Position> ps = GetHistoryData(p.Id, topoNodeIds, start, end, 1440f); psList.Add(ps); if (personnel_Points.ContainsKey(p)) { personnel_Points[p] = ps; } else { personnel_Points.Add(p, ps); } if (ps != null && ps.Count > 0) { Position fps = ps[0]; if (firstPoint == null) { firstPoint = fps; } else { if (fps.Time < firstPoint.Time) { firstPoint = fps; } } } } Debug.Log("StartSingleThread1"); Loom.DispatchToMainThread(() => { ProgressbarLoad.Instance.Show(1); ProgressbarLoad.Instance.Hide(); int k = 0; foreach (Personnel p in personnel_Points.Keys) { List <Position> ps = personnel_Points[p]; Debug.LogError("点数:" + ps.Count); if (ps.Count < 2) { continue; } var posInfoList = new PositionInfoList(); for (int i = 0; i < ps.Count; i++) { var posInfo = new PositionInfo(ps[i], start); posInfoList.Add(posInfo); } Color colorT = colors[k % colors.Count]; HistoryPersonUIItem item = historyPersonUIItems.Find((i) => i.personnel.Id == p.Id); if (item != null) { colorT = item.color; } PathInfo pathInfo = new PathInfo(); pathInfo.personnelT = p; pathInfo.color = colorT; pathInfo.posList = posInfoList; pathInfo.timeLength = timeLength; LocationHistoryPath_M histoyObj = LocationHistoryManager.Instance.ShowLocationHistoryPath_M(pathInfo); //histoyObj.InitData(timeLength, timelist); HistoryManController historyManController = histoyObj.gameObject.AddComponent <HistoryManController>(); histoyObj.historyManController = historyManController; historyManController.Init(colorT, histoyObj); PersonAnimationController personAnimationController = histoyObj.gameObject.GetComponent <PersonAnimationController>(); personAnimationController.DoMove(); Debug.Log("StartSingleThread2"); k++; } }); //Debug.Log("StartSingleThread3"); Loom.DispatchToMainThread(() => { isLoadDataSuccessed = true; //timeStart = Time.time; timeSum = 0; Debug.Log("StartSingleThread3"); if (firstPoint != null) { DateTime t = LocationManager.GetTimestampToDateTime(firstPoint.Time); Debug.Log(firstPoint.Time); timeSum = t.Hour * 3600 + t.Minute * 60 + t.Second - slider.ValueMin * 3600; Debug.Log(timeSum); } }); }); }