232 lines
6.5 KiB
C#
232 lines
6.5 KiB
C#
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using UnityEngine;
|
||
using System;
|
||
|
||
public class AppCache
|
||
{
|
||
|
||
public enum MonitorType
|
||
{
|
||
GNSS,
|
||
EnvironmentalMonitoring,
|
||
CrackMonitoring,
|
||
VibrationMonitoring,
|
||
SurfaceStrainMonitoring
|
||
}
|
||
public static int screenWidth = 3550;
|
||
public static int screenHeight = 1080;
|
||
|
||
public static string url = "https://api.zk.gzckgc.cn";
|
||
|
||
//界面
|
||
public static PageType cameraType = PageType.Camera1;
|
||
public static PageType pageType = PageType.PnlPage1;
|
||
//点位gnss
|
||
public static List<IconData> iconPointList01;
|
||
//相机点位gnss
|
||
public static List<Transform> iconCameraList01 = new List<Transform>();
|
||
//点位环境监测
|
||
public static List<IconData> iconPointList02;
|
||
//相机点位环境检测
|
||
public static List<Transform> iconCameraList02 = new List<Transform>();
|
||
//点位裂缝监测
|
||
public static List<IconData> iconPointList03;
|
||
//相机点位裂缝监测
|
||
public static List<Transform> iconCameraList03 = new List<Transform>();
|
||
//点位加速度震动监测
|
||
public static List<IconData> iconPointList04;
|
||
//相机点位加速度震动监测
|
||
public static List<Transform> iconCameraList04 = new List<Transform>();
|
||
public static List<Vector3> areaPointList01 = new List<Vector3>();
|
||
public static List<Vector3> areaPointList02 = new List<Vector3>();
|
||
|
||
|
||
//初始化
|
||
public static void Init()
|
||
{
|
||
//分辨率设置
|
||
if (Application.platform == RuntimePlatform.WindowsPlayer)
|
||
{
|
||
float height = Screen.width * (screenHeight / (float)screenWidth);
|
||
Screen.SetResolution(Screen.width, (int)height, true);
|
||
|
||
//Screen.SetResolution(screenWidth, screenHeight, true);
|
||
}
|
||
//初始化
|
||
cameraType = PageType.Camera1;
|
||
pageType = PageType.PnlPage1;
|
||
}
|
||
|
||
|
||
|
||
#region 页面管理
|
||
|
||
//已打开页面列表
|
||
private static List<PageType> pageList = new List<PageType>();
|
||
|
||
//打开页面
|
||
public static void OpenPage(PageType page)
|
||
{
|
||
if (page != PageType.Null)
|
||
{
|
||
ActionCenter.Instance.DoAction(GameEvent.OpenPage, page);
|
||
if (!pageList.Contains(page))
|
||
{
|
||
pageList.Add(page);
|
||
}
|
||
}
|
||
}
|
||
|
||
//打开页面
|
||
public static void OpenDialog<T>(PageType page, T t)
|
||
{
|
||
if (page != PageType.Null)
|
||
{
|
||
ActionCenter.Instance.DoAction(GameEvent.OpenDialog, page, t);
|
||
if (!pageList.Contains(page))
|
||
{
|
||
pageList.Add(page);
|
||
}
|
||
}
|
||
}
|
||
|
||
//delay秒后打开页面
|
||
public static void OpenPageDelay(PageType page, float delay)
|
||
{
|
||
ActionCenter.Instance.DoActionDelay(OpenPage, delay, page);
|
||
}
|
||
|
||
//关闭页面
|
||
public static void ClosePage(PageType page)
|
||
{
|
||
|
||
if (pageList.Contains(page) && page != PageType.Null)
|
||
{
|
||
ActionCenter.Instance.DoAction(GameEvent.ClosePage, page);
|
||
pageList.Remove(page);
|
||
}
|
||
}
|
||
|
||
//关闭页面
|
||
public static void ClosePage(List<PageType> list)
|
||
{
|
||
for (int i = 0; i < list.Count; i++)
|
||
{
|
||
if (pageList.Contains(list[i]) && list[i] != PageType.Null)
|
||
{
|
||
ActionCenter.Instance.DoAction(GameEvent.ClosePage, list[i]);
|
||
pageList.Remove(list[i]);
|
||
}
|
||
}
|
||
}
|
||
|
||
//关闭页面,参数为保留页面
|
||
public static void CloseAllPage(PageType page = PageType.Null)
|
||
{
|
||
for (int i = 0; i < pageList.Count; i++)
|
||
{
|
||
if (pageList[i] != page)
|
||
{
|
||
ActionCenter.Instance.DoAction(GameEvent.ClosePage, pageList[i]);
|
||
}
|
||
}
|
||
pageList.Clear();
|
||
if (page != PageType.Null)
|
||
{
|
||
pageList.Add(page);
|
||
}
|
||
}
|
||
|
||
//关闭页面,参数为保留页面
|
||
public static void CloseAllPage(List<PageType> list)
|
||
{
|
||
//保留页面
|
||
List<PageType> saveList = new List<PageType>();
|
||
for (int i = 0; i < list.Count; i++)
|
||
{
|
||
if (list[i] != PageType.Null && pageList.Contains(list[i]))
|
||
{
|
||
saveList.Add(list[i]);
|
||
}
|
||
}
|
||
//关闭现有页面
|
||
for (int i = 0; i < pageList.Count; i++)
|
||
{
|
||
if (!saveList.Contains(pageList[i]))
|
||
{
|
||
ActionCenter.Instance.DoAction(GameEvent.ClosePage, pageList[i]);
|
||
}
|
||
}
|
||
pageList.Clear();
|
||
//当前页面更新
|
||
for (int i = 0; i < saveList.Count; i++)
|
||
{
|
||
pageList.Add(list[i]);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
#endregion
|
||
|
||
// 根据device_sn查找在AppCache.iconCameraList01中的下标
|
||
public static int FindIndexInIconCameraList(string deviceSn)
|
||
{
|
||
if (AppCache.iconCameraList01 == null)
|
||
return -1;
|
||
|
||
// 遍历列表查找匹配的下标
|
||
for (int i = 0; i < AppCache.iconCameraList01.Count; i++)
|
||
{
|
||
// 从name中提取device_sn部分(去掉"_Camera"后缀)
|
||
string nameWithoutSuffix = AppCache.iconCameraList01[i].name.Split('_')[0];
|
||
|
||
if (nameWithoutSuffix == deviceSn)
|
||
{
|
||
return i; // 找到匹配的下标
|
||
}
|
||
}
|
||
|
||
return -1; // 未找到
|
||
}
|
||
|
||
public static List<IconData> GetIconPointListByType(MonitorType type)
|
||
{
|
||
switch (type)
|
||
{
|
||
case MonitorType.GNSS:
|
||
return iconPointList01;
|
||
case MonitorType.EnvironmentalMonitoring:
|
||
return iconPointList02;
|
||
case MonitorType.CrackMonitoring:
|
||
return iconPointList03;
|
||
case MonitorType.VibrationMonitoring:
|
||
return iconPointList04;
|
||
default:
|
||
Debug.LogError("未知的监测类型: " + type);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public static List<Transform> GetIconCameraListByType(MonitorType type)
|
||
{
|
||
switch (type)
|
||
{
|
||
case MonitorType.GNSS:
|
||
return iconCameraList01;
|
||
case MonitorType.EnvironmentalMonitoring:
|
||
return iconCameraList02;
|
||
case MonitorType.CrackMonitoring:
|
||
return iconCameraList03;
|
||
case MonitorType.VibrationMonitoring:
|
||
return iconCameraList04;
|
||
default:
|
||
Debug.LogError("未知的监测类型: " + type);
|
||
return null;
|
||
}
|
||
}
|
||
|
||
}
|