860 lines
23 KiB
C#
860 lines
23 KiB
C#
//using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using System.Linq;
|
||
using DG.Tweening;
|
||
using HighlightingSystem;
|
||
using System.Reflection;
|
||
using HXSJFrameWork;
|
||
|
||
public class ModelManager : MonoBehaviour
|
||
{
|
||
|
||
[HideInInspector]
|
||
public static ModelManager instance;
|
||
[HideInInspector]
|
||
public List<ModelItem> devices;
|
||
[HideInInspector]
|
||
public List<ModelItem> peoples;
|
||
[HideInInspector]
|
||
public List<ModelItem> spacePoints;
|
||
[HideInInspector]
|
||
public List<ModelItem> expPoints;
|
||
[HideInInspector]
|
||
public List<ModelItem> models;
|
||
//监控
|
||
[HideInInspector]
|
||
public List<ModelItem> camList;
|
||
//客户
|
||
[HideInInspector]
|
||
public List<ModelItem> clients;
|
||
//柜台
|
||
[HideInInspector]
|
||
public List<ModelItem> counters;
|
||
//空间Icon
|
||
private List<GameObject> spaceIconList;
|
||
//分区
|
||
private GameObject _spaceArea;
|
||
|
||
//异常Icon
|
||
private List<Exception3DIcon> expIconList;
|
||
//热力图
|
||
private Heatmap heatmap;
|
||
//人员点位热力图
|
||
private HeatPointManager m_heatpoint;
|
||
//切换热力图特效
|
||
private ParticleSystem changePage;//切换页面时的特效
|
||
|
||
|
||
//屋顶
|
||
//private Transform wuDing;
|
||
//3DCanvas
|
||
public Transform iconPanel;
|
||
//屋顶高度
|
||
//[HideInInspector]
|
||
public float wudingHeight=0;
|
||
|
||
private void Awake()
|
||
{
|
||
instance = this;
|
||
|
||
expIconList = new List<Exception3DIcon>();
|
||
//wuDing = transform.Find("WuDing");
|
||
iconPanel = transform.Find("3DIconPanel");
|
||
_spaceArea = transform.Find("fenqu").gameObject;
|
||
changePage = transform.Find("ChangeHeatmapEffect").GetComponent<ParticleSystem>();
|
||
heatmap = GetComponentInChildren<Heatmap>(true);
|
||
m_heatpoint = GetComponentInChildren<HeatPointManager>(true);
|
||
m_heatpoint.InitPoint();
|
||
|
||
//RandomHeatValue();
|
||
InitData();
|
||
InitPeople();
|
||
InitClient();
|
||
LoadSpacePointIcon();
|
||
}
|
||
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 动态加载设备
|
||
/// </summary>
|
||
/// <param name="data"></param>
|
||
public void LoadDevice(DeviceData data)
|
||
{
|
||
if (devices.Count > 0)
|
||
{ devices.Clear(); }
|
||
if (camList.Count > 0)
|
||
{ camList.Clear(); }
|
||
//加载设备
|
||
DeviceManager.instance.LoadDeviceByJson(data);
|
||
|
||
//加载设备后,初始化数据
|
||
InitDeviceData();
|
||
InitDevice();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 清空数据
|
||
/// </summary>
|
||
public void ClearData()
|
||
{
|
||
|
||
}
|
||
|
||
|
||
private float time;
|
||
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
//测试demo,动态随机热力图效果
|
||
time += Time.deltaTime;
|
||
if (time > 1)
|
||
{
|
||
time = 0;
|
||
//RandomHeatValue();
|
||
//RandomUpdateHeatValue();
|
||
}
|
||
|
||
|
||
}
|
||
|
||
#region 初始时获取数据
|
||
|
||
/// <summary>
|
||
/// 根据类型初始化所有数据
|
||
/// </summary>
|
||
void InitData()
|
||
{
|
||
|
||
spacePoints = new List<ModelItem>();
|
||
expPoints = new List<ModelItem>();
|
||
peoples = new List<ModelItem>();
|
||
clients = new List<ModelItem>();
|
||
counters = new List<ModelItem>();
|
||
models = new List<ModelItem>();
|
||
foreach (ModelItem item in transform.GetComponentsInChildren<ModelItem>(true))
|
||
{
|
||
if (item.modelType == ModelType.SpacePoint)
|
||
spacePoints.Add(item);
|
||
else if (item.modelType == ModelType.ExpEvent)
|
||
expPoints.Add(item);
|
||
else if (item.modelType == ModelType.Worker)
|
||
{
|
||
//电子工牌
|
||
//devices.Add(item);
|
||
peoples.Add(item);
|
||
}
|
||
else if (item.modelType == ModelType.Client)
|
||
clients.Add(item);
|
||
else if (item.modelType == ModelType.counter)
|
||
counters.Add(item);
|
||
else if (item.modelType == ModelType.Model)
|
||
{
|
||
if(MainUIManager._instance == null)
|
||
{
|
||
MainUIManager._instance = FindObjectOfType<MainUIManager>();
|
||
}
|
||
//一般情况下,屋顶为一个组
|
||
if (item.floorIndex > MainUIManager._instance.buildFloorCount)
|
||
{
|
||
Debug.Log(item.name);
|
||
wudingHeight=item.transform.position.y;
|
||
}
|
||
models.Add(item);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化设备数据
|
||
/// </summary>
|
||
private void InitDeviceData()
|
||
{
|
||
Debug.Log("设备数量@"+devices.Count);
|
||
devices = new List<ModelItem>();
|
||
camList = new List<ModelItem>();
|
||
foreach (ModelItem item in transform.GetComponentsInChildren<ModelItem>())
|
||
{
|
||
if (item.modelType == ModelType.Device)
|
||
{
|
||
devices.Add(item);
|
||
if (item.deviceType == DeviceType.SheXiangTou)
|
||
camList.Add(item);
|
||
}
|
||
}
|
||
Debug.Log("设备数量#" + devices.Count);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化设备
|
||
/// </summary>
|
||
private void InitDevice()
|
||
{
|
||
|
||
foreach (var item in devices)
|
||
{
|
||
//工牌暂时同人员一样
|
||
if (item.deviceType != DeviceType.GongPai)
|
||
{
|
||
if (item.GetComponent<DeviceClick>() == null)
|
||
{
|
||
item.gameObject.AddComponent<DeviceClick>();
|
||
}
|
||
item.GetComponent<DeviceClick>().deviceType = item.deviceType;
|
||
//todo:传入设备索引
|
||
//item.GetComponent<DeviceClick>().index = 0;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 初始化人员
|
||
/// </summary>
|
||
private void InitPeople()
|
||
{
|
||
foreach (var item in peoples)
|
||
{
|
||
if (item.GetComponent<PeopleClick>() == null)
|
||
{
|
||
item.gameObject.AddComponent<PeopleClick>();
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化客户
|
||
/// </summary>
|
||
private void InitClient()
|
||
{
|
||
foreach (var item in clients)
|
||
{
|
||
if (item.GetComponent<ClientClick>() == null)
|
||
{
|
||
item.gameObject.AddComponent<ClientClick>();
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化柜台
|
||
/// </summary>
|
||
private void InitCounter()
|
||
{
|
||
foreach (var item in clients)
|
||
{
|
||
if (item.GetComponent<CounterClick>() == null)
|
||
{
|
||
item.gameObject.AddComponent<CounterClick>();
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 加载异常Icon
|
||
/// </summary>
|
||
public void LoadExpIcon()
|
||
{
|
||
|
||
GameObject obj = Resources.Load<GameObject>(ResourcePath._exp3DIcon);
|
||
for (int i = 0; i < expPoints.Count; i++)
|
||
{
|
||
GameObject icon = GameObject.Instantiate(obj);
|
||
//icon.transform.parent = iconPanel;
|
||
icon.GetComponent<RectTransform>().SetParent(iconPanel);
|
||
icon.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
||
icon.transform.position = expPoints[i].transform.position;
|
||
if (icon.GetComponent<Exception3DIcon>() == null)
|
||
icon.AddComponent<Exception3DIcon>();
|
||
expIconList.Add(icon.GetComponent<Exception3DIcon>());
|
||
icon.name = expPoints[i].name;
|
||
icon.GetComponent<Exception3DIcon>().InitExpIcon(expPoints[i].GetComponent<ModelItem>().expType, i, expPoints[i].floorIndex);
|
||
}
|
||
//测试,第一个摄像头警告
|
||
camList[12].GetComponent<DeviceClick>()._isCamWarm = true;
|
||
//根据楼层判断是否显示icon
|
||
ShowExpIconByFloor(MainUIManager._instance.curfloor);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据异常名称找到对应的异常点位
|
||
/// </summary>
|
||
/// <param name="name">异常名称</param>
|
||
/// <returns></returns>
|
||
public GameObject FindExpPointByName(string name)
|
||
{
|
||
foreach (var item in expPoints)
|
||
{
|
||
if (item.name == name)
|
||
return item.gameObject;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭异常
|
||
/// </summary>
|
||
|
||
public void CloseExpIcon()
|
||
{
|
||
foreach (var item in expIconList)
|
||
{
|
||
Destroy(item.gameObject);
|
||
}
|
||
expIconList.Clear();
|
||
foreach (var item in camList)
|
||
{
|
||
item.GetComponent<DeviceClick>()._isCamWarm = false;
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 加载空间点Icon
|
||
/// </summary>
|
||
public void LoadSpacePointIcon()
|
||
{
|
||
spaceIconList = new List<GameObject>();
|
||
GameObject obj = Resources.Load<GameObject>(ResourcePath._space3DIcon);
|
||
GameObject objeffect = Resources.Load<GameObject>(ResourcePath._space3DEffect);
|
||
foreach (var item in spacePoints)
|
||
{
|
||
GameObject icon = GameObject.Instantiate(obj);
|
||
GameObject effect = GameObject.Instantiate(objeffect);
|
||
//icon.transform.parent = iconPanel;
|
||
effect.transform.SetParent(item.transform);
|
||
effect.transform.localPosition = Vector3.zero;
|
||
icon.GetComponent<RectTransform>().SetParent(iconPanel);
|
||
icon.transform.localScale = new Vector3(0.5f, 0.5f, 0.5f);
|
||
icon.transform.position = new Vector3(item.transform.position.x, item.transform.position.y + 0.5f, item.transform.position.z);
|
||
icon.transform.Find("Image/Text").GetComponent<Text>().text = item.name;
|
||
if (icon.GetComponent<LookAtCam>() == null)
|
||
{
|
||
icon.AddComponent<LookAtCam>();
|
||
}
|
||
if (!icon.GetComponent<Space3DIcon>())
|
||
icon.AddComponent<Space3DIcon>();
|
||
//楼层信息
|
||
icon.GetComponent<Space3DIcon>().floorIndex = item.floorIndex;
|
||
icon.GetComponent<LookAtCam>().Cam = Camera.main.transform;
|
||
icon.GetComponent<Space3DIcon>().effect = effect;
|
||
spaceIconList.Add(icon);
|
||
//默认分区隐藏
|
||
//icon.gameObject.SetActive(false);
|
||
//effect.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据设备类型,找到一个设备
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
public GameObject FindDeviceByType(DeviceType type)
|
||
{
|
||
foreach (var item in devices)
|
||
{
|
||
if (item.deviceType == type)
|
||
return item.gameObject;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据设备类型和索引,找到一个设备
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
public GameObject FindDeviceByTypeAndID(DeviceType type, int index)
|
||
{
|
||
int curindex = -1;
|
||
foreach (var item in devices)
|
||
{
|
||
if (item.deviceType == type)
|
||
{
|
||
curindex++;
|
||
if (curindex == index)
|
||
return item.gameObject;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据设备索引,找到一个设备
|
||
/// </summary>
|
||
/// <param name="type"></param>
|
||
public GameObject FindDeviceByCode(string deviceSeq)
|
||
{
|
||
|
||
foreach (var item in devices)
|
||
{
|
||
if (deviceSeq == item.code)
|
||
return item.gameObject;
|
||
}
|
||
return null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 单体化模型360展示
|
||
/// </summary>
|
||
/// <param name="obj"></param>
|
||
public void SingleModel(GameObject obj)
|
||
{
|
||
//将上一个单体化物体隐藏
|
||
if (CameraManager._instance.curentSingleObj != null)
|
||
{
|
||
CameraManager._instance.singleCam.GetComponent<Camera360>().ChangeObjLayer(CameraManager._instance.curentSingleObj, "Default");
|
||
}
|
||
//显示单体化展示页面
|
||
MainUIManager._instance.CurentSinglePage.SetActive(true);
|
||
//将当前物体设置为单体化360观察的物体
|
||
CameraManager._instance.curentSingleObj = obj;
|
||
CameraManager._instance.singleCam.GetComponent<Camera360>().SetTarget(obj.transform);
|
||
Debug.Log("设备单体化" + obj);
|
||
//设置模型为正视角
|
||
CameraManager._instance.singleCam.GetComponent<Camera360>().ChangeObjLayer(CameraManager._instance.curentSingleObj, "single360");
|
||
MainUIManager._instance.ShowSingleModel(true);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 是否显示空间Icon
|
||
/// </summary>
|
||
/// <param name="isShow"></param>
|
||
public void ShowSpaceIcon(bool isShow,int floorindex)
|
||
{
|
||
Debug.Log("空间Icon" + isShow+ spaceIconList.Count);
|
||
foreach (var item in spaceIconList)
|
||
{
|
||
//显示并且楼层相等
|
||
item.SetActive(isShow&&floorindex==item.GetComponent<Space3DIcon>().floorIndex);
|
||
//Icon显示+热力图不显示=特效显示
|
||
item.GetComponent<Space3DIcon>().effect.gameObject.SetActive(item.activeSelf&&!m_heatpoint.gameObject.activeSelf);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 是否显示空间icon下的蓝色光圈特效
|
||
/// </summary>
|
||
/// <param name="show"></param>
|
||
public void ShowSpaceEffect(bool show)
|
||
{
|
||
foreach (var item in spaceIconList)
|
||
{
|
||
//Icon显示,特效才显示
|
||
item.GetComponent<Space3DIcon>().effect.gameObject.SetActive(item.activeSelf&&show);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示分区块
|
||
/// </summary>
|
||
/// <param name="isshow"></param>
|
||
public void ShowSpaceArea(bool isshow)
|
||
{
|
||
_spaceArea.SetActive(isshow);
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 播放切换页面的特效
|
||
/// </summary>
|
||
public void ShowChangePageEffect()
|
||
{
|
||
changePage.Play();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 根据类型高亮设备
|
||
/// </summary>
|
||
/// <param name="index">索引从1开始</param>
|
||
public void HighLightDeviceOn(int index)
|
||
{
|
||
foreach (ModelItem device in devices)
|
||
{
|
||
if (device.GetComponent<ModelItem>().deviceType.GetHashCode() == index)
|
||
{
|
||
AddHighLightComponent(device.gameObject);
|
||
device.GetComponent<Highlighter>().TweenStart();
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据设备类型关闭高亮
|
||
/// </summary>
|
||
/// <param name="index">索引从1开始</param>
|
||
public void HighLightDeviceOff(int index)
|
||
{
|
||
foreach (ModelItem device in devices)
|
||
{
|
||
if (device.GetComponent<ModelItem>().deviceType.GetHashCode() == index)
|
||
{
|
||
if (device.GetComponent<Highlighter>())
|
||
device.GetComponent<Highlighter>().TweenStop();
|
||
}
|
||
}
|
||
}
|
||
/// <summary>
|
||
///关闭所有设备高亮
|
||
/// </summary>
|
||
public void HighLightOff()
|
||
{
|
||
foreach (ModelItem device in devices)
|
||
{
|
||
if (device.GetComponent<Highlighter>())
|
||
device.GetComponent<Highlighter>().TweenStop();
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 添加闪烁边缘光
|
||
/// </summary>
|
||
private void AddHighLightComponent(GameObject obj)
|
||
{
|
||
if (!obj.GetComponent<Highlighter>())
|
||
{
|
||
Highlighter h = obj.AddComponent<Highlighter>();
|
||
h.overlay = true;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 摄像头进入房间内部,隐藏空间3DIcon,显示屋顶
|
||
/// </summary>
|
||
public void CameraNear(bool isNear)
|
||
{
|
||
//ShowSpaceIcon(!isNear);
|
||
//wuDing.gameObject.SetActive(isNear);
|
||
//当前所观察为最高楼层,进入屋顶下的范围后,显示屋顶楼层
|
||
if (MainUIManager._instance.curfloor == MainUIManager._instance.buildFloorCount)
|
||
{
|
||
foreach (ModelItem item in models)
|
||
{
|
||
//屋顶的楼层索引比建筑楼层的索引大:例:建筑为两层,则屋顶为第三层
|
||
if (item.floorIndex > MainUIManager._instance.buildFloorCount)
|
||
{
|
||
item.gameObject.SetActive(isNear);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//当视角拉进时,缩小异常Icon
|
||
if (expIconList.Count > 0)
|
||
{
|
||
float expIconScale = isNear ? 0.1f : 0.5f;
|
||
Vector3 expEffectScale = isNear ? new Vector3(0.3f, 0.3f, 0.3f) : Vector3.one;
|
||
foreach (Exception3DIcon icomn in expIconList)
|
||
{
|
||
icomn.transform.localScale = new Vector3(expIconScale, expIconScale, expIconScale);
|
||
icomn.transform.Find("effect").transform.localScale = expEffectScale;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 综合管理允许单体化显示
|
||
/// </summary>
|
||
/// <param name="istrue"></param>
|
||
public void CanSingle(bool istrue)
|
||
{
|
||
foreach (ModelItem device in devices)
|
||
{
|
||
if (device.GetComponent<DeviceClick>())
|
||
device.GetComponent<DeviceClick>().isSingle = istrue;
|
||
|
||
}
|
||
|
||
foreach (ModelItem item in peoples)
|
||
{
|
||
item.GetComponent<PeopleClick>().isSingle = istrue;
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 高亮闪烁3秒后关闭
|
||
/// </summary>
|
||
/// <param name="obj">高亮物体</param>
|
||
public void LightFlashCount(GameObject obj)
|
||
{
|
||
float a = 0;
|
||
LightFlash(obj, true);
|
||
DOTween.To(() => a, x => a = x, 1, 3).OnComplete(() =>
|
||
{
|
||
LightFlash(obj, false);
|
||
});
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 高亮闪烁
|
||
/// </summary>
|
||
/// <param name="obj">高亮物体</param>
|
||
/// <param name="on">是否高亮</param>
|
||
public void LightFlash(GameObject obj, bool on)
|
||
{
|
||
if (!obj.GetComponent<Highlighter>())
|
||
obj.AddComponent<Highlighter>();
|
||
|
||
if (on)
|
||
obj.GetComponent<Highlighter>().TweenStart();
|
||
else
|
||
obj.GetComponent<Highlighter>().TweenStop();
|
||
}
|
||
|
||
|
||
#region 热力图(弃用)
|
||
//热力图点位
|
||
public List<HeatPoint> heatPoints;
|
||
//世界坐标
|
||
public List<Vector3> m_Vector3s;
|
||
//X:半径(0,2);Y:强度(0,1)
|
||
public List<Vector2> m_Vector2s;
|
||
//切换热力图时的特效
|
||
private ParticleSystem _changeHeatmapEffect;
|
||
|
||
/// <summary>
|
||
/// 随机热力图热点值(测试)
|
||
/// </summary>
|
||
private void RandomHeatValue()
|
||
{
|
||
|
||
heatPoints.Clear();
|
||
for (int i = 0; i < 20; i++)
|
||
{
|
||
heatPoints.Add(new HeatPoint()
|
||
{
|
||
point = new Vector3(Random.Range(-13, 13f), 0, Random.Range(-9f, 7f)),
|
||
radius = Random.Range(1f, 2f),
|
||
intensity = Random.Range(1f, 2)
|
||
});
|
||
//heatmap.AddHeatPoint(heatPoints[i].point, heatPoints[i].radius, heatPoints[i].intensity);
|
||
}
|
||
UpdateHeatValue();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示和关闭热力图
|
||
/// </summary>
|
||
/// <param name="isShow"></param>
|
||
public void ShowHeatmap(bool isShow)
|
||
{
|
||
if (isShow)
|
||
{
|
||
|
||
|
||
//播放切换热力图特效
|
||
//if (!_changeHeatmapEffect)
|
||
//{
|
||
// _changeHeatmapEffect = GameObject.Instantiate(Resources.Load<GameObject>(ResourcePath._changeHeatmapEffect).GetComponent<ParticleSystem>());
|
||
// _changeHeatmapEffect.transform.SetParent(transform);
|
||
// _changeHeatmapEffect.transform.localPosition = new Vector3(0,0.2f,0);
|
||
//}
|
||
//_changeHeatmapEffect.Play();
|
||
//_changeHeatmapEffect.gameObject.SetActive(false);
|
||
//_changeHeatmapEffect.gameObject.SetActive(true);
|
||
//Invoke("InvokeShowHeatmap", 4);
|
||
InvokeShowHeatmap();
|
||
//ShowSpaceIcon(true);
|
||
}
|
||
else
|
||
{
|
||
heatmap.gameObject.SetActive(false);
|
||
//ShowSpaceIcon(false);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// 延时显示热力图,等特效播放两秒后显示
|
||
/// </summary>
|
||
private void InvokeShowHeatmap()
|
||
{
|
||
UpdateHeatValue();
|
||
heatmap.gameObject.SetActive(true);
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 更新热力值
|
||
/// </summary>
|
||
public void UpdateHeatValue()
|
||
{
|
||
heatmap.SetHeatPoints(heatPoints.Select((v) => new HeatPoint()
|
||
{
|
||
point = v.point,
|
||
radius = v.radius,
|
||
intensity = v.intensity
|
||
}));
|
||
}
|
||
|
||
/// <summary>
|
||
/// 随机动态更新热力值
|
||
/// </summary>
|
||
public void RandomUpdateHeatValue()
|
||
{
|
||
//随机其中一个值
|
||
int randomIndex = Random.Range(0, heatPoints.Count());
|
||
heatPoints[randomIndex] = new HeatPoint()
|
||
{
|
||
point = new Vector3(Random.Range(-13, 13f), 0, Random.Range(-8f, 6f)),
|
||
radius = Random.Range(0f, 2f),
|
||
intensity = Random.Range(0f, 2)
|
||
};
|
||
|
||
heatmap.SetHeatPoints(heatPoints.Select((v) => new HeatPoint()
|
||
{
|
||
point = v.point,
|
||
radius = v.radius,
|
||
intensity = v.intensity
|
||
}));
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 热力图
|
||
/// <summary>
|
||
/// 显示热力图
|
||
/// </summary>
|
||
public void ShowHeatPoint(int floorIndex)
|
||
{
|
||
Debug.Log("显示热力图,当前楼层为"+floorIndex);
|
||
m_heatpoint.gameObject.SetActive(true);
|
||
ChangeHeatPointByFloor(floorIndex);
|
||
MainUIManager._instance.heatPointDes.SetActive(true);
|
||
}
|
||
/// <summary>
|
||
/// 隐藏热力图
|
||
/// </summary>
|
||
public void HideHeatPoint()
|
||
{
|
||
m_heatpoint.gameObject.SetActive(false);
|
||
MainUIManager._instance.heatPointDes.SetActive(false);
|
||
}
|
||
/// <summary>
|
||
/// 根据楼层切换热力图
|
||
/// </summary>
|
||
/// <param name="floorIndex"></param>
|
||
public void ChangeHeatPointByFloor(int floorIndex = 2)
|
||
{
|
||
m_heatpoint.ShowHeatPointByFloor(true, floorIndex);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 模型
|
||
/// <summary>
|
||
/// 根据楼层切换模型
|
||
/// </summary>
|
||
public void ShowModelByFloor(int floorindex)
|
||
{
|
||
foreach (var item in models)
|
||
{
|
||
item.gameObject.SetActive(item.floorIndex <= floorindex);
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 楼层切换
|
||
|
||
/// <summary>
|
||
/// 根据楼层显示设备模型
|
||
/// </summary>
|
||
public void ShowDeviceByFloor(int floorindex)
|
||
{
|
||
foreach (var item in devices)
|
||
{
|
||
item.gameObject.SetActive(item.floorIndex <= floorindex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据楼层显示客户模型
|
||
/// </summary>
|
||
public void ShowClientByFloor(int floorindex)
|
||
{
|
||
foreach (var item in clients)
|
||
{
|
||
item.gameObject.SetActive(item.floorIndex <= floorindex);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据楼层显示营业员模型
|
||
/// </summary>
|
||
public void ShowWorkerByFloor(int floorindex)
|
||
{
|
||
foreach (var item in peoples)
|
||
{
|
||
item.gameObject.SetActive(item.floorIndex <= floorindex);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 根据楼层显示异常事件点位
|
||
/// </summary>
|
||
public void ShowExpIconByFloor(int floorindex)
|
||
{
|
||
foreach (var item in expIconList)
|
||
{
|
||
item.gameObject.SetActive(item.floorIndex <= floorindex);
|
||
}
|
||
//根据楼层切换监控报警图标
|
||
foreach (var item in camList)
|
||
{
|
||
if (item.GetComponent<DeviceClick>().warmIcon)
|
||
{
|
||
item.GetComponent<DeviceClick>().warmIcon.gameObject.SetActive(item.floorIndex <= floorindex);
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion 楼层切换
|
||
}
|
||
|
||
|
||
[System.Serializable]
|
||
public class HeatPoint
|
||
{
|
||
/// <summary>
|
||
/// 世界坐标系位置
|
||
/// </summary>
|
||
public Vector3 point;
|
||
|
||
/// <summary>
|
||
/// 半径
|
||
/// </summary>
|
||
public float radius;
|
||
|
||
/// <summary>
|
||
/// 强度
|
||
/// </summary>
|
||
public float intensity;
|
||
} |