1106 lines
38 KiB
C#
1106 lines
38 KiB
C#
using DG.Tweening;
|
||
using HXSJFrameWork;
|
||
using LitJson;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Runtime.InteropServices.ComTypes;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using ZenFulcrum.EmbeddedBrowser;
|
||
|
||
public class MainUIManager : UIBase
|
||
{
|
||
public static MainUIManager _instance;
|
||
public Browser m_htmlPanel;
|
||
//高斯模糊背景
|
||
public GameObject GaussianBlurPanel;
|
||
//单体化展示页面
|
||
public GameObject CurentSinglePage;
|
||
//热力图页面
|
||
public GameObject heatPointDes;
|
||
|
||
public int curModuleIndex;//当前模块索引 0:总体概览;1:智慧运营;2:服务管控;3:综合管理;4:班组事务
|
||
|
||
public bool isRightPanelShow;//综合管理模块右边信息面板是否显示
|
||
|
||
//当前营业厅为几层建筑
|
||
public int buildFloorCount;
|
||
|
||
/// <summary>
|
||
/// 当前所观察楼层
|
||
/// </summary>
|
||
public int curfloor
|
||
{
|
||
get { return _curfloor; }
|
||
set
|
||
{
|
||
_curfloor = value;
|
||
ChangeFloor(value);
|
||
}
|
||
}
|
||
private int _curfloor;
|
||
|
||
|
||
private void Awake()
|
||
{
|
||
_instance = this;
|
||
}
|
||
|
||
|
||
// Start is called before the first frame update
|
||
void Start()
|
||
{
|
||
|
||
//先加载本地设备数据,后面请求接口,再用接口数据覆盖
|
||
U3DLoadDevice(null);
|
||
|
||
//接收前端传来的数据
|
||
ReadEnvironmentData();
|
||
//根据楼层创建楼层切换按钮
|
||
CreateFloorBtn();
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
if (Input.GetKeyDown(KeyCode.I))
|
||
{
|
||
//U3DDeviceViewCenter("KS02");
|
||
//U3DClientViewCenter(0);
|
||
//U3DWorkCardCenter(8);
|
||
//U3DCamViewCenter("KS03");
|
||
//U3DPeopleViewCenter(8);
|
||
//U3DCounterViewCenter(4);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 网页加载成功
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void OnLoad(JSONNode args)
|
||
{
|
||
m_htmlPanel.RegisterFunction("U3dRoam", U3dRoam);
|
||
m_htmlPanel.RegisterFunction("U3DExit", U3DExit);
|
||
m_htmlPanel.RegisterFunction("U3DEnterModule", U3DEnterModule);//进入模块
|
||
m_htmlPanel.RegisterFunction("U3DDeviceViewCenter", U3DDeviceViewCenter);//锁定设备到视角中心并高亮
|
||
m_htmlPanel.RegisterFunction("U3DPeopleViewCenter", U3DPeopleViewCenter);//锁定人员或工牌到视角中心并高亮
|
||
m_htmlPanel.RegisterFunction("U3DWorkCardCenter", U3DWorkCardCenter);//锁定人员或工牌到视角中心并高亮
|
||
m_htmlPanel.RegisterFunction("U3DClientViewCenter", U3DClientViewCenter);//锁定客户到视角中心
|
||
m_htmlPanel.RegisterFunction("U3DCounterViewCenter", U3DCounterViewCenter);//锁定柜台到视角中心
|
||
m_htmlPanel.RegisterFunction("U3DExpViewCenter", U3DExpViewCenter);//锁定异常到视角中心
|
||
m_htmlPanel.RegisterFunction("U3DCamViewCenter", U3DCamViewCenter);//锁定摄像头到视角中心
|
||
m_htmlPanel.RegisterFunction("U3DClosePeopleInfo", U3DClosePeopleInfo);//关闭人物单体化展示
|
||
m_htmlPanel.RegisterFunction("U3DCloseSingleDeviceInfo", U3DCloseSingleDeviceInfo);//关闭设备单体化展示
|
||
m_htmlPanel.RegisterFunction("U3DShowDeviceType", U3DShowDeviceType);//根据类型高亮设备
|
||
m_htmlPanel.RegisterFunction("U3DLoadExceptioIcon", U3DLoadExceptioIcon);//加载异常Icon
|
||
m_htmlPanel.RegisterFunction("U3DCloseExpIcon", U3DCloseExpIcon);//关闭异常Icon
|
||
m_htmlPanel.RegisterFunction("U3DOpenOverlook", U3DOpenOverlook);//开启热力图
|
||
m_htmlPanel.RegisterFunction("U3DCloseOverlook", U3DCloseOverlook);//关闭热力图
|
||
m_htmlPanel.RegisterFunction("U3DBackInitView", U3DBackInitView);//返回初始视角
|
||
m_htmlPanel.RegisterFunction("U3DClosePage", U3DClosePage);//收起UI面板
|
||
m_htmlPanel.RegisterFunction("U3DShowAreaIcon", U3DShowAreaIcon);//显示隐藏分区icon
|
||
m_htmlPanel.RegisterFunction("U3DShowRightBlurPage", U3DShowRightBlurPage);//右侧面板显示隐藏
|
||
m_htmlPanel.RegisterFunction("U3DShowSingleModel", U3DShowSingleModel);//显示单体化模型
|
||
m_htmlPanel.RegisterFunction("U3DShowDeviceTypePanel", U3DShowDeviceTypePanel);//显示隐藏首页右下角设备分类的毛玻璃效果
|
||
m_htmlPanel.RegisterFunction("U3DLoadDevice", U3DLoadDevice);//根据数据动态加载设备
|
||
|
||
ShowLeftBlurPage(true);
|
||
ShowRightBlurPage(true);
|
||
//将接收到的token值和vr全景地址传给web页面
|
||
m_htmlPanel.CallFunction("U3DSendKeyInfo", webtoken);
|
||
//请求设备数据,根据返回数据动态加载设备
|
||
m_htmlPanel.CallFunction("getEquiLocation");
|
||
}
|
||
|
||
private string webtoken;
|
||
|
||
/// <summary>
|
||
/// 获取网页传来的数据
|
||
/// </summary>
|
||
void ReadEnvironmentData()
|
||
{
|
||
//关闭壳子程序
|
||
//CloseU3DManagerProgram();
|
||
//用来接收HTML发来的数据
|
||
string[] CommandLineArgs = Environment.GetCommandLineArgs();
|
||
if (CommandLineArgs.Length < 2 || CommandLineArgs[1] == "")
|
||
{
|
||
Debug.Log("没有接收到参数");
|
||
if (transform.Find("Text") != null)
|
||
{
|
||
transform.Find("Text").GetComponent<Text>().text = "当前无参";
|
||
}
|
||
webtoken = "";
|
||
}
|
||
else
|
||
{
|
||
Debug.Log("参数" + CommandLineArgs[1]);
|
||
if (transform.Find("Text") != null)
|
||
{
|
||
transform.Find("Text").GetComponent<Text>().text = "当前参数为" + CommandLineArgs[1];
|
||
}
|
||
webtoken = CommandLineArgs[1];
|
||
}
|
||
|
||
//加载网页
|
||
string weburl = JsonLoad("/Json/WebPath");
|
||
if (webtoken.Length > 0 && webtoken.Contains("WebPath"))
|
||
{
|
||
WebParam p = JsonUtility.FromJson<WebParam>(webtoken);
|
||
if (p.WebPath != null || p.WebPath.Length > 0)
|
||
{
|
||
weburl = p.WebPath;
|
||
}
|
||
}
|
||
m_htmlPanel.Url = weburl;
|
||
m_htmlPanel.onLoad += OnLoad;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭壳子管理程序
|
||
/// </summary>
|
||
void CloseU3DManagerProgram()
|
||
{
|
||
CloseExe("NJYYT_Manager");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据楼层新建切换楼层按钮
|
||
/// </summary>
|
||
private void CreateFloorBtn()
|
||
{
|
||
Debug.Log("当前建筑楼层" + buildFloorCount);
|
||
if (buildFloorCount > 1)
|
||
{
|
||
//楼层大于1时,创建楼层切换按钮
|
||
for (int i = 0; i < buildFloorCount; i++)
|
||
{
|
||
GameObject to = GameObject.Instantiate(m_htmlPanel.transform.Find("toGroup/To_F1").gameObject);
|
||
to.transform.parent = m_htmlPanel.transform.Find("toGroup");
|
||
int index = i + 1;
|
||
to.name = "To_F" + index;
|
||
to.transform.Find("Label").GetComponent<Text>().text = "F" + index;
|
||
to.GetComponent<Toggle>().onValueChanged.AddListener((check) => {
|
||
if (check)
|
||
{
|
||
curfloor = index;
|
||
}
|
||
});
|
||
to.SetActive(true);
|
||
}
|
||
|
||
}
|
||
//当前默认楼层为最上一层
|
||
curfloor = buildFloorCount;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 切换楼层
|
||
/// </summary>
|
||
public void ChangeFloor(int index)
|
||
{
|
||
Debug.Log("当前楼层" + index);
|
||
//根据楼层切换区域点位(第一个模块,楼层相同)
|
||
ModelManager.instance.ShowSpaceIcon(MainUIManager._instance.curModuleIndex == 0, index);
|
||
//热力图
|
||
if (curModuleIndex == 0)
|
||
{
|
||
ModelManager.instance.ChangeHeatPointByFloor(index);
|
||
}
|
||
//异常
|
||
ModelManager.instance.ShowExpIconByFloor(index);
|
||
//切换模型、分区
|
||
ModelManager.instance.ShowModelByFloor(index);
|
||
//设备
|
||
ModelManager.instance.ShowDeviceByFloor(index);
|
||
//工作人员
|
||
ModelManager.instance.ShowWorkerByFloor(index);
|
||
//客户
|
||
ModelManager.instance.ShowClientByFloor(index);
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据索引切换选中的楼层
|
||
/// </summary>
|
||
/// <param name="index"></param>
|
||
public void ChangeFloorUI(int index)
|
||
{
|
||
//该组下本身存在一个预制,所以子物体索引从1开始,和楼层保持一致
|
||
m_htmlPanel.transform.Find("toGroup").GetChild(index).GetComponent<Toggle>().isOn = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 动态加载设备
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DLoadDevice(JSONNode args)
|
||
{
|
||
|
||
//接口没有数据读取本地json
|
||
string json = "{\"devices\":" + JsonLoad("/Json/DeviceInfo") + "}";
|
||
if (args != null)
|
||
{
|
||
if (args[0].Value.ToString().Length > 0)
|
||
{
|
||
//根据接口中的数据加载设备
|
||
json = "{\"devices\":" + args[0].Value.ToString() + "}";
|
||
}
|
||
}
|
||
Debug.Log("初始化设备...:" + json);
|
||
DeviceData data = JsonMapper.ToObject<DeviceData>(json);
|
||
Debug.Log("第一个设备名称" + data.devices[0].deviceName);
|
||
ModelManager.instance.LoadDevice(data);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示隐藏首页右下角设备分类的毛玻璃效果
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DShowDeviceTypePanel(JSONNode args)
|
||
{
|
||
bool isshow = bool.Parse(args[0].Value.ToString());
|
||
float height = isshow ? 1 : 0;
|
||
GaussianBlurPanel.transform.Find("right/devicetypebg/devicetypebg").GetComponent<RectTransform>().DOScaleY(height, 0.5f);
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="args">0:总体概览;1:智慧运营;2:综合管理;3:班组事务</param>
|
||
void U3DEnterModule(JSONNode args)
|
||
{
|
||
int moduleIndex = int.Parse(args[0].Value.ToString());
|
||
curModuleIndex = moduleIndex;
|
||
Debug.Log("进入模块" + moduleIndex);
|
||
ModelManager.instance.ShowChangePageEffect();
|
||
switch (moduleIndex)
|
||
{
|
||
case 0://综合概览
|
||
ModelManager.instance.CloseExpIcon();
|
||
//综合管理不允许单体化
|
||
ModelManager.instance.CanSingle(false);
|
||
U3DClosePeopleInfo(null);
|
||
U3DCloseSingleDeviceInfo(null);
|
||
ModelManager.instance.HighLightOff();
|
||
ModelManager.instance.ShowSpaceIcon(true, curfloor);
|
||
ShowLeftBlurPage(true);
|
||
ShowRightBlurPage(true);
|
||
break;
|
||
case 1://智慧运营
|
||
ModelManager.instance.CloseExpIcon();
|
||
//综合管理不允许单体化
|
||
ModelManager.instance.CanSingle(false);
|
||
U3DClosePeopleInfo(null);
|
||
U3DCloseSingleDeviceInfo(null);
|
||
ModelManager.instance.HighLightOff();
|
||
ModelManager.instance.ShowSpaceIcon(false, curfloor);
|
||
ShowLeftBlurPage(true);
|
||
ShowRightBlurPage(true);
|
||
//退出热力图
|
||
U3DCloseOverlook(null);
|
||
//退出分区
|
||
ModelManager.instance.ShowSpaceArea(false);
|
||
//退出第一人称漫游
|
||
CameraManager._instance.FirstAutoRoam(false);
|
||
m_htmlPanel.CallFunction("toggleMenuActive");
|
||
break;
|
||
case 2:
|
||
//服务管控
|
||
//综合管理不允许单体化
|
||
ModelManager.instance.CanSingle(false);
|
||
U3DClosePeopleInfo(null);
|
||
U3DCloseSingleDeviceInfo(null);
|
||
ModelManager.instance.HighLightOff();
|
||
ModelManager.instance.ShowSpaceIcon(false, curfloor);
|
||
ShowLeftBlurPage(true);
|
||
ShowRightBlurPage(true);
|
||
//退出热力图
|
||
U3DCloseOverlook(null);
|
||
//退出分区
|
||
ModelManager.instance.ShowSpaceArea(false);
|
||
//退出第一人称漫游
|
||
CameraManager._instance.FirstAutoRoam(false);
|
||
m_htmlPanel.CallFunction("toggleMenuActive");
|
||
break;
|
||
case 3://综合管理
|
||
//综合管理允许单体化
|
||
ModelManager.instance.CanSingle(true);
|
||
ModelManager.instance.CloseExpIcon();
|
||
ShowLeftBlurPage(true);
|
||
ShowRightBlurPage(false);
|
||
ModelManager.instance.ShowSpaceIcon(false, curfloor);
|
||
//退出热力图
|
||
U3DCloseOverlook(null);
|
||
//退出分区
|
||
ModelManager.instance.ShowSpaceArea(false);
|
||
//退出第一人称漫游
|
||
CameraManager._instance.FirstAutoRoam(false);
|
||
m_htmlPanel.CallFunction("toggleMenuActive");
|
||
break;
|
||
case 4://班组事务
|
||
ModelManager.instance.CloseExpIcon();
|
||
//综合管理不允许单体化
|
||
ModelManager.instance.CanSingle(false);
|
||
U3DClosePeopleInfo(null);
|
||
U3DCloseSingleDeviceInfo(null);
|
||
ModelManager.instance.HighLightOff();
|
||
ShowLeftBlurPage(true);
|
||
ShowRightBlurPage(true);
|
||
ModelManager.instance.ShowSpaceIcon(false, curfloor);
|
||
//退出热力图
|
||
U3DCloseOverlook(null);
|
||
//退出分区
|
||
ModelManager.instance.ShowSpaceArea(false);
|
||
//退出第一人称漫游
|
||
CameraManager._instance.FirstAutoRoam(false);
|
||
m_htmlPanel.CallFunction("toggleMenuActive");
|
||
break;
|
||
}
|
||
|
||
//只有首页显示设备分类
|
||
GaussianBlurPanel.transform.Find("right/devicetypebg").gameObject.SetActive(curModuleIndex == 0);
|
||
CloseMenuLast4(curModuleIndex == 0);
|
||
|
||
}
|
||
|
||
#region UI页面
|
||
|
||
/// <summary>
|
||
/// 隐藏首页右侧菜单 后四个高斯模糊背景
|
||
/// </summary>
|
||
private void CloseMenuLast4(bool isShow)
|
||
{
|
||
GaussianBlurPanel.transform.Find("right/menu").GetChild(2).gameObject.SetActive(isShow);
|
||
GaussianBlurPanel.transform.Find("right/menu").GetChild(3).gameObject.SetActive(isShow);
|
||
GaussianBlurPanel.transform.Find("right/menu").GetChild(4).gameObject.SetActive(isShow);
|
||
GaussianBlurPanel.transform.Find("right/menu").GetChild(5).gameObject.SetActive(isShow);
|
||
|
||
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 收起左右面板
|
||
/// </summary>
|
||
private void U3DClosePage(JSONNode args)
|
||
{
|
||
if (args[0].IsValid)
|
||
{
|
||
bool value = (bool)args[0].Value;
|
||
if (value)
|
||
{
|
||
ShowLeftBlurPage(true);
|
||
if (curModuleIndex == 3)
|
||
{
|
||
//在综合模块,并且右侧面板有内容时,显示右侧面板
|
||
if (isRightPanelShow)
|
||
ShowRightBlurPage(true);
|
||
}
|
||
else
|
||
{
|
||
ShowRightBlurPage(true);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
ShowLeftBlurPage(false);
|
||
ShowRightBlurPage(false);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据索引滑入滑出页面
|
||
/// </summary>
|
||
private void ShowLeftBlurPage(bool isShow)
|
||
{
|
||
//初始化左右两边的位置
|
||
Transform left = GaussianBlurPanel.transform.GetChild(0);
|
||
float leftX = left.GetComponent<RectTransform>().rect.width;
|
||
if (isShow)
|
||
{
|
||
left.GetComponent<RectTransform>().anchoredPosition = new Vector2(-leftX, left.GetComponent<RectTransform>().anchoredPosition.y);
|
||
//滑入
|
||
left.GetComponent<RectTransform>().DOAnchorPosX(0, 0.5f).SetEase(Ease.Linear);
|
||
}
|
||
else
|
||
{
|
||
left.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, left.GetComponent<RectTransform>().anchoredPosition.y);
|
||
//滑出
|
||
left.GetComponent<RectTransform>().DOAnchorPosX(-leftX, 0.5f).SetEase(Ease.Linear);
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 右侧面板显示设备人员信息等
|
||
/// </summary>
|
||
private void U3DShowRightBlurPage(JSONNode args)
|
||
{
|
||
if (args[0].IsValid)
|
||
ShowRightBlurPage((bool)args[0].Value);
|
||
isRightPanelShow = (bool)args[0].Value;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据索引滑入滑出页面
|
||
/// </summary>
|
||
private void ShowRightBlurPage(bool isShow)
|
||
{
|
||
//初始化左右两边的位置
|
||
Transform right = GaussianBlurPanel.transform.GetChild(1);
|
||
float rightX = right.GetComponent<RectTransform>().rect.width;
|
||
if (isShow)
|
||
{
|
||
right.GetComponent<RectTransform>().anchoredPosition = new Vector2(rightX, right.GetComponent<RectTransform>().anchoredPosition.y);
|
||
right.GetComponent<RectTransform>().DOAnchorPosX(0, 0.5f).SetEase(Ease.Linear);
|
||
}
|
||
else
|
||
{
|
||
right.GetComponent<RectTransform>().anchoredPosition = new Vector2(0, right.GetComponent<RectTransform>().anchoredPosition.y);
|
||
//滑出
|
||
right.GetComponent<RectTransform>().DOAnchorPosX(rightX, 0.5f).SetEase(Ease.Linear);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// 综合管理模块是否显示单体化模型(页面动画)
|
||
/// </summary>
|
||
/// <param name="show"></param>
|
||
public void ShowSingleModel(bool show)
|
||
{
|
||
if (show)
|
||
{
|
||
CurentSinglePage.GetComponent<RectTransform>().DOAnchorPosX(-95f, 0.5f).SetEase(Ease.Linear);
|
||
}
|
||
else
|
||
{
|
||
CurentSinglePage.GetComponent<RectTransform>().DOAnchorPosX(340f, 0.5f).SetEase(Ease.Linear);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
#endregion UI页面
|
||
|
||
|
||
#region 与前端接口
|
||
/// <summary>
|
||
/// 显示单体化模型
|
||
/// </summary>
|
||
private void U3DShowSingleModel(JSONNode args)
|
||
{
|
||
if (args[0].IsValid)
|
||
{
|
||
DeviceType type = (DeviceType)Enum.ToObject(typeof(DeviceType), int.Parse(args[0].ToString()));
|
||
GameObject obj = ModelManager.instance.FindDeviceByType(type);
|
||
ModelManager.instance.SingleModel(obj);
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// 退出程序
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
private void U3DExit(JSONNode args)
|
||
{
|
||
Application.Quit();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 第一人称漫游
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
private void U3dRoam(JSONNode args)
|
||
{
|
||
bool isRoam = bool.Parse(args[0].Value.ToString());
|
||
CameraManager._instance.FirstAutoRoam(isRoam);
|
||
|
||
//关闭左右面板
|
||
if (isRoam)
|
||
{
|
||
ShowLeftBlurPage(false);
|
||
ShowRightBlurPage(false);
|
||
//显示所有观察层
|
||
ChangeFloor(buildFloorCount + 1);
|
||
}
|
||
else
|
||
{
|
||
//恢复观察楼层
|
||
ChangeFloor(curfloor);
|
||
if (curModuleIndex == 3)
|
||
{
|
||
ShowLeftBlurPage(true);
|
||
//综合模块,不显示右侧面板,当单体化展示时,显示右侧面板
|
||
}
|
||
else
|
||
{
|
||
ShowLeftBlurPage(true);
|
||
ShowRightBlurPage(true);
|
||
m_htmlPanel.CallFunction("U3DControlShrink", true);
|
||
m_htmlPanel.CallFunction("U3DCloseRoomTip");//关闭漫游提示
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 开启俯视视图(热力图视角)
|
||
/// </summary>
|
||
void U3DOpenOverlook(JSONNode args)
|
||
{
|
||
// mainCamera.GetComponent<CameraView>().InitViewAnim();
|
||
CameraManager._instance.InitView();
|
||
//ModelManager.instance.ShowHeatmap(true);
|
||
ModelManager.instance.ShowHeatPoint(curfloor);
|
||
ModelManager.instance.ShowChangePageEffect();
|
||
ModelManager.instance.ShowSpaceEffect(false);
|
||
heatPointDes.gameObject.SetActive(true);
|
||
//停止计算待机时长
|
||
CameraManager._instance.isInFirstRoam = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭俯视视图(热力图视角)
|
||
/// </summary>
|
||
void U3DCloseOverlook(JSONNode args)
|
||
{
|
||
heatPointDes.gameObject.SetActive(false);
|
||
ModelManager.instance.HideHeatPoint();
|
||
if (curModuleIndex == 0)
|
||
ModelManager.instance.ShowSpaceEffect(true);
|
||
//ModelManager.instance.ShowHeatmap(false);
|
||
//开始计算待机时长
|
||
CameraManager._instance.isInFirstRoam = false;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 相机回到初始视角
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DBackInitView(JSONNode args)
|
||
{
|
||
CameraManager._instance.InitView(() =>
|
||
{
|
||
//取消按钮高亮
|
||
m_htmlPanel.CallFunction("toggleMenuActive");
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 设备视角居中——综合管理模块
|
||
/// </summary>
|
||
void U3DDeviceViewCenter(JSONNode args)
|
||
{
|
||
//需要居中定位的模型
|
||
Debug.Log("设备视角居中设备索引:" + args[0].Value);
|
||
GameObject curModel = ModelManager.instance.FindDeviceByCode(args[0].Value.ToString());
|
||
if (curModel == null)
|
||
return;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
|
||
//显示设备详情并且单体化展示
|
||
//Main.intance.m_htmlPanel.CallFunction("showRightDetails", index);
|
||
m_htmlPanel.CallFunction("clickShowDetails", args[0].Value.ToString());
|
||
Debug.Log("设备单体化名称" + curModel);
|
||
ModelManager.instance.SingleModel(curModel);
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
|
||
});
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 摄像头视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DCamViewCenter(JSONNode args)
|
||
{
|
||
//需要居中定位的模型
|
||
Debug.Log("摄像头视角居中" + args[0].Value);
|
||
//int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.camList.Count;
|
||
GameObject curModel = ModelManager.instance.FindDeviceByCode(args[0].Value.ToString());
|
||
Debug.Log("设备编号" + args[0].Value.ToString() + "所找到的摄像头" + curModel);
|
||
if (!curModel)
|
||
return;
|
||
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 人员视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DPeopleViewCenter(JSONNode args)
|
||
{
|
||
Debug.Log("工牌和人员视角居中" + args[0].Value);
|
||
//需要居中定位的模型
|
||
int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.peoples.Count;
|
||
GameObject curModel = ModelManager.instance.peoples[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 工牌视角居中,高亮并显示工牌信息
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DWorkCardCenter(JSONNode args)
|
||
{
|
||
Debug.Log("工牌和人员视角居中" + args[0].Value);
|
||
//需要居中定位的模型
|
||
int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.peoples.Count;
|
||
GameObject curModel = ModelManager.instance.peoples[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
//显示电子工牌信息
|
||
m_htmlPanel.CallFunction("clickShowDetails", 4);
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 客户视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DClientViewCenter(JSONNode args)
|
||
{
|
||
Debug.Log("客户视角居中" + args[0].Value);
|
||
int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.clients.Count;
|
||
//需要居中定位的模型
|
||
GameObject curModel = ModelManager.instance.clients[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 柜台视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DCounterViewCenter(JSONNode args)
|
||
{
|
||
//Debug.Log(args[0].IsValid);
|
||
Debug.Log(args[0].Value);
|
||
int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.counters.Count;
|
||
//需要居中定位的模型
|
||
GameObject curModel = ModelManager.instance.counters[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 8);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 异常视角居中
|
||
/// </summary>
|
||
/// <param name="args">0:离岗;1:人员聚集;2:防滑;3:体温;4:工单临期;5:工单逾期</param>
|
||
void U3DExpViewCenter(JSONNode args)
|
||
{
|
||
int expindex = 0;
|
||
Debug.Log(args[0].Value);
|
||
switch (args[0].Value)
|
||
{
|
||
case "离岗异常":
|
||
expindex = 0;
|
||
break;
|
||
case "人员聚集":
|
||
expindex = 1;
|
||
break;
|
||
case "防滑设施未摆放":
|
||
expindex = 2;
|
||
break;
|
||
case "体温异常":
|
||
expindex = 3;
|
||
break;
|
||
case "工单临期":
|
||
expindex = 4;
|
||
break;
|
||
case "工单逾期":
|
||
expindex = 5;
|
||
break;
|
||
case "设备异常":
|
||
expindex = 6;
|
||
break;
|
||
case "预受理信息预警":
|
||
expindex = 4;
|
||
break;
|
||
case "疑似人员跌倒":
|
||
expindex = 2;
|
||
break;
|
||
case "排队":
|
||
expindex = 1;
|
||
break;
|
||
case "频繁临厅":
|
||
expindex = 1;
|
||
break;
|
||
case "高温预警":
|
||
expindex = 3;
|
||
break;
|
||
case "业务受理机已下线":
|
||
expindex = 4;
|
||
break;
|
||
}
|
||
//需要居中定位的模型
|
||
//GameObject curModel = ModelManager.instance.expPoints[expindex].gameObject;
|
||
GameObject curModel = ModelManager.instance.FindExpPointByName(args[0].Value.ToString());
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward);
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 关闭人物单体化展示信息
|
||
/// </summary>
|
||
void U3DClosePeopleInfo(JSONNode args)
|
||
{
|
||
if (CameraManager._instance.curentSingleObj)
|
||
{
|
||
CameraManager._instance.curentSingleObj.layer = LayerMask.NameToLayer("Default");
|
||
CameraManager._instance.curentSingleObj = null;
|
||
ShowSingleModel(false);
|
||
ShowRightBlurPage(false);
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 关闭设备单体化展示信息
|
||
/// </summary>
|
||
void U3DCloseSingleDeviceInfo(JSONNode args)
|
||
{
|
||
Debug.Log("关闭单体化模型");
|
||
if (CameraManager._instance.curentSingleObj)
|
||
{
|
||
Debug.Log("不为空");
|
||
CameraManager._instance.curentSingleObj.layer = LayerMask.NameToLayer("Default");
|
||
CameraManager._instance.curentSingleObj = null;
|
||
ShowSingleModel(false);
|
||
ShowRightBlurPage(false);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 加载异常Icon
|
||
/// </summary>
|
||
void U3DLoadExceptioIcon(JSONNode args)
|
||
{
|
||
Debug.Log(args[0].Value);
|
||
//解析数据
|
||
//ExceptionData data = JsonUtility.FromJson<ExceptionData>(args[0].Value.ToString());
|
||
ExceptionData data = JsonMapper.ToObject<ExceptionData>(args[0].Value.ToString());
|
||
Debug.Log(data.arr[0].name);
|
||
//expInfo = data.arr;
|
||
//expIconList = new GameObject[data.infoList.Length];
|
||
//foreach (var item in data.infoList)
|
||
//{
|
||
// Create3DIcon(item);
|
||
//}
|
||
//LoadExceptioIconTest();
|
||
ModelManager.instance.LoadExpIcon();
|
||
}
|
||
/// <summary>
|
||
/// 关闭异常Icon
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DCloseExpIcon(JSONNode args)
|
||
{
|
||
ModelManager.instance.CloseExpIcon();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 显示隐藏分区
|
||
/// </summary>
|
||
/// <param name="args">bool :true显示,false:隐藏</param>
|
||
void U3DShowAreaIcon(JSONNode args)
|
||
{
|
||
Debug.Log(args[0].Value);
|
||
if (args[0].IsValid)
|
||
{
|
||
//是否开始计算待机时长
|
||
CameraManager._instance.isInFirstRoam = (bool)args[0].Value;
|
||
ModelManager.instance.ShowSpaceArea((bool)args[0].Value);
|
||
}
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 根据类型高亮设备
|
||
/// </summary>
|
||
void U3DShowDeviceType(JSONNode args)
|
||
{
|
||
int index = int.Parse(args[0].Value.ToString()) + 1;
|
||
bool show = (bool)args[1].Value;
|
||
Debug.Log(index + "高亮" + show);
|
||
if (show)
|
||
{
|
||
//根据传入类型高亮设备
|
||
ModelManager.instance.HighLightDeviceOn(index);
|
||
}
|
||
else
|
||
{
|
||
//根据传入类型高亮设备
|
||
ModelManager.instance.HighLightDeviceOff(index);
|
||
}
|
||
|
||
}
|
||
|
||
#endregion 与前端接口
|
||
|
||
#region 测试代码可删
|
||
/// <summary>
|
||
/// 设备视角居中——综合管理模块
|
||
/// </summary>
|
||
void U3DDeviceViewCenter(string code)
|
||
{
|
||
//需要居中定位的模型
|
||
Debug.Log("设备视角居中设备索引:" + code);
|
||
GameObject curModel = ModelManager.instance.FindDeviceByCode(code);
|
||
if (curModel == null)
|
||
return;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
//显示设备详情并且单体化展示
|
||
//Main.intance.m_htmlPanel.CallFunction("showRightDetails", index);
|
||
m_htmlPanel.CallFunction("clickShowDetails", code);
|
||
Debug.Log("设备单体化名称" + curModel);
|
||
ModelManager.instance.SingleModel(curModel);
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
|
||
});
|
||
|
||
}
|
||
|
||
/// <summary>
|
||
/// 摄像头视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DCamViewCenter(string code)
|
||
{
|
||
//需要居中定位的模型
|
||
Debug.Log("摄像头视角居中" + code);
|
||
//int index = int.Parse(args[0].Value.ToString()) % ModelManager.instance.camList.Count;
|
||
GameObject curModel = ModelManager.instance.FindDeviceByCode(code);
|
||
Debug.Log("设备编号" + code + "所找到的摄像头" + curModel);
|
||
if (!curModel)
|
||
return;
|
||
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 人员视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DPeopleViewCenter(int code)
|
||
{
|
||
Debug.Log("工牌和人员视角居中" + code);
|
||
//需要居中定位的模型
|
||
int index = code % ModelManager.instance.peoples.Count;
|
||
GameObject curModel = ModelManager.instance.peoples[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 工牌视角居中,高亮并显示工牌信息
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DWorkCardCenter(int code)
|
||
{
|
||
Debug.Log("工牌和人员视角居中" + code);
|
||
//需要居中定位的模型
|
||
int index = code % ModelManager.instance.peoples.Count;
|
||
GameObject curModel = ModelManager.instance.peoples[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
//显示电子工牌信息
|
||
m_htmlPanel.CallFunction("clickShowDetails", 4);
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 3, () => {
|
||
ModelManager.instance.LightFlashCount(curModel);
|
||
});
|
||
}
|
||
|
||
/// <summary>
|
||
/// 客户视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DClientViewCenter(int code)
|
||
{
|
||
Debug.Log("客户视角居中" + code);
|
||
int index = code % ModelManager.instance.clients.Count;
|
||
//需要居中定位的模型
|
||
GameObject curModel = ModelManager.instance.clients[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 柜台视角居中
|
||
/// </summary>
|
||
/// <param name="args"></param>
|
||
void U3DCounterViewCenter(int code)
|
||
{
|
||
//Debug.Log(args[0].IsValid);
|
||
int index = code % ModelManager.instance.counters.Count;
|
||
//需要居中定位的模型
|
||
GameObject curModel = ModelManager.instance.counters[index].gameObject;
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward, 8);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 异常视角居中
|
||
/// </summary>
|
||
/// <param name="args">0:离岗;1:人员聚集;2:防滑;3:体温;4:工单临期;5:工单逾期</param>
|
||
void U3DExpViewCenter(string expname)
|
||
{
|
||
int expindex = 0;
|
||
Debug.Log(expname);
|
||
switch (expname)
|
||
{
|
||
case "离岗异常":
|
||
expindex = 0;
|
||
break;
|
||
case "人员聚集":
|
||
expindex = 1;
|
||
break;
|
||
case "防滑设施未摆放":
|
||
expindex = 2;
|
||
break;
|
||
case "体温异常":
|
||
expindex = 3;
|
||
break;
|
||
case "工单临期":
|
||
expindex = 4;
|
||
break;
|
||
case "工单逾期":
|
||
expindex = 5;
|
||
break;
|
||
case "设备异常":
|
||
expindex = 6;
|
||
break;
|
||
case "预受理信息预警":
|
||
expindex = 4;
|
||
break;
|
||
case "疑似人员跌倒":
|
||
expindex = 2;
|
||
break;
|
||
case "排队":
|
||
expindex = 1;
|
||
break;
|
||
case "频繁临厅":
|
||
expindex = 1;
|
||
break;
|
||
case "高温预警":
|
||
expindex = 3;
|
||
break;
|
||
case "业务受理机已下线":
|
||
expindex = 4;
|
||
break;
|
||
}
|
||
//需要居中定位的模型
|
||
//GameObject curModel = ModelManager.instance.expPoints[expindex].gameObject;
|
||
GameObject curModel = ModelManager.instance.FindExpPointByName(expname);
|
||
//如果当前设备楼层没有显示
|
||
if (curModel.GetComponent<ModelItem>().floorIndex > curfloor)
|
||
{
|
||
//显示设备所在楼层
|
||
ChangeFloorUI(curModel.GetComponent<ModelItem>().floorIndex);
|
||
}
|
||
CameraManager._instance.ViewCenterPoint(curModel, curModel.transform.forward);
|
||
}
|
||
|
||
#endregion 测试代码可删
|
||
}
|
||
|
||
public struct WebParam
|
||
{
|
||
public string ServerPath;//下载服务器地址
|
||
public string ProgramID;//三维资源包名称
|
||
public string token;//传给前端的token
|
||
public string VRPath;//VR全景地址
|
||
public string WebPath;//三维嵌入前端的网页地址
|
||
} |