397 lines
13 KiB
C#
397 lines
13 KiB
C#
using DG.Tweening;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using UnityEngine.Windows;
|
||
|
||
/// <summary>
|
||
/// 模式选择
|
||
/// </summary>
|
||
[AddComponentMenu("PatternChoose/模式选择")]
|
||
public class PatternChoose : MonoBehaviour
|
||
{
|
||
static PatternChoose _inst;
|
||
public static PatternChoose Inst => _inst;
|
||
public Button TS_button;
|
||
public Button RL_button;
|
||
/// <summary>
|
||
/// 热力效果图
|
||
/// </summary>
|
||
public GameObject heatMap;
|
||
public GameObject search_go;
|
||
|
||
Vector3 init_pos;
|
||
Vector3 init_rot;
|
||
|
||
[SerializeField] public Color red_alarm;
|
||
[SerializeField] public Color yellow_alarm;
|
||
[SerializeField] public Color blue_alarm;
|
||
|
||
public Button back_page;
|
||
|
||
public Toggle roomCut;
|
||
public Toggle quanJing;
|
||
public Toggle niaoKan;
|
||
|
||
[Header("上次点击的菜单类型")]
|
||
public Menu current_menu;
|
||
|
||
/// <summary>
|
||
/// 设备新增窗口
|
||
/// </summary>
|
||
public GameObject sb_xz_page;
|
||
/// <summary>
|
||
/// 设备编辑窗口
|
||
/// </summary>
|
||
public GameObject sb_bj_page;
|
||
/// <summary>
|
||
/// 设备查看窗口
|
||
/// </summary>
|
||
public GameObject sb_ck_page;
|
||
/// <summary>
|
||
/// 端口新增窗口
|
||
/// </summary>
|
||
public GameObject dk_xz_page;
|
||
/// <summary>
|
||
/// 端口编辑窗口
|
||
/// </summary>
|
||
public GameObject dk_bj_page;
|
||
public CreateLine huaXian;
|
||
/// <summary>
|
||
/// 线缆
|
||
/// </summary>
|
||
public ByCode xianlan;
|
||
public GameObject xianlan_popup;
|
||
|
||
public UIToCabinet uiToCabinet;
|
||
|
||
public Image xunJianImg;
|
||
|
||
[Header("时间筛选")]
|
||
public GameObject calendar;
|
||
//public ZCalendar zCalendar;
|
||
|
||
[Header("图片轮播UI")]
|
||
public GameObject Carousel_Object;
|
||
|
||
private void Awake()
|
||
{
|
||
|
||
if (_inst != null && _inst != this)
|
||
{
|
||
Destroy(this.gameObject);
|
||
}
|
||
else
|
||
{
|
||
_inst = this;
|
||
//DontDestroyOnLoad(this.gameObject);
|
||
}
|
||
init_pos = Camera.main.transform.localPosition;
|
||
init_rot = Camera.main.transform.localEulerAngles;
|
||
}
|
||
void Start()
|
||
{
|
||
//Debug.Log("版本号 1.1.1");
|
||
roomCut.onValueChanged.AddListener((x) =>
|
||
{
|
||
if (CabinetUIManager.Instance.current_menu == Menu.M_数字机房_智能巡检)
|
||
return;
|
||
ExtendedFlycam.Inst.reminder((isgo, list, prompt) =>
|
||
{
|
||
if (isgo)
|
||
{
|
||
GameManager.Inst.RemoveEmptyElements();
|
||
//FindDeletedDevices(list);
|
||
roomCut_fuc();
|
||
}
|
||
});
|
||
});
|
||
|
||
quanJing.onValueChanged.AddListener((x) =>
|
||
{
|
||
if (!x)
|
||
return;
|
||
ExtendedFlycam.Inst.reminder((isgo, list, prompt) =>
|
||
{
|
||
if (isgo)
|
||
{
|
||
GameManager.Inst.RemoveEmptyElements();
|
||
//FindDeletedDevices(list);
|
||
quanJing_fuc();
|
||
}
|
||
});
|
||
});
|
||
|
||
niaoKan.onValueChanged.AddListener((x) =>
|
||
{
|
||
ExtendedFlycam.Inst.reminder((isgo, list, prompt) =>
|
||
{
|
||
if (isgo)
|
||
{
|
||
GameManager.Inst.RemoveEmptyElements();
|
||
//FindDeletedDevices(list);
|
||
niaoKan_fuc();
|
||
}
|
||
});
|
||
});
|
||
|
||
back_page.onClick.AddListener(() =>
|
||
{
|
||
ExtendedFlycam.Inst.reminder((isgo, list, prompt) =>
|
||
{
|
||
if (isgo)
|
||
{
|
||
GameManager.Inst.RemoveEmptyElements();
|
||
//FindDeletedDevices(list);
|
||
if (Menu.M_数字机房_线缆连接_配置 == CabinetUIManager.Instance.current_menu)
|
||
{
|
||
ExtendedFlycam.Inst.QieHuan(Menu.M_数字机房_线缆连接_配置);
|
||
LineGroupManager.Instance.ShowPanel();
|
||
SecondConfirmPanel.Instance.panel_object.SetActive(false);
|
||
return;
|
||
}
|
||
quanJing_fuc();
|
||
if (Menu.M_数字机房_线缆连接_展示 == CabinetUIManager.Instance.current_menu)
|
||
{
|
||
SearchName searchName = search_go.GetComponent<SearchName>();
|
||
searchName.showXianLan(searchName._co);
|
||
}
|
||
else if (Menu.M_数字机房_场景管理 == CabinetUIManager.Instance.current_menu)
|
||
{
|
||
SearchName searchName = GameManager.Inst.search_box.GetComponent<SearchName>();
|
||
searchName.LoadCabinet(SearchName.SearchType.机柜);
|
||
GameManager.Inst.search_box.SetActive(true);
|
||
searchName.inputField.text = string.Empty;
|
||
}
|
||
}
|
||
});
|
||
});
|
||
|
||
//Debug.Log("版本号 1.1.1");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 寻找删除的设备在列表中的位置
|
||
/// </summary>
|
||
/// <param name="list"></param>
|
||
public void FindDeletedDevices(List<GameObject> list)
|
||
{
|
||
if (list != null && list.Count > 0)
|
||
{
|
||
for (int i = 0; i < list.Count; i++)
|
||
{
|
||
var v = GameManager.Inst.Racks_go.FirstOrDefault(x => x == list[i]);
|
||
if (v != null)
|
||
GameManager.Inst.Racks_go.Remove(v);
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点击切换房间
|
||
/// </summary>
|
||
public void roomCut_fuc()
|
||
{
|
||
ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu, 2);
|
||
for (int i = 0; i < xianlan.transform.childCount; i++)
|
||
{
|
||
xianlan.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点击全景
|
||
/// </summary>
|
||
public void quanJing_fuc()
|
||
{
|
||
//if (!quanJing.isOn)
|
||
// return;
|
||
GameManager.Inst.RemoveEmptyElements();
|
||
sb_ck_page.SetActive(false);
|
||
GameManager.Inst.magnifyState = false;
|
||
TransparentGlowManage.Inst.is_magnify = false;
|
||
for (int i = 0; i < CabinetUIManager.Instance.cabine_hights_now.Count; i++)
|
||
{
|
||
CabinetUIManager.Instance.cabine_hights_now[i].SetActive(true);
|
||
}
|
||
CabinetUIManager.Instance.cabine_hights_now.Clear();
|
||
if (Menu.M_全景监控_柜门状态 != CabinetUIManager.Instance.current_menu)
|
||
{
|
||
GameManager.Inst.power_close();
|
||
//GameManager.Inst.Cabinets_go[0].GetComponent<ClickEvent>().openCap(false);
|
||
}
|
||
//ExtendedFlycam.Inst.CameraRtDisable();
|
||
GameManager.Inst.editorMenu.gameObject.SetActive(false);
|
||
ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu);
|
||
//ExtendedFlycam.Inst.CameraRtDisable();
|
||
for (int i = 0; i < xianlan.transform.childCount; i++)
|
||
{
|
||
xianlan.transform.GetChild(i).gameObject.SetActive(false);
|
||
}
|
||
|
||
if (Menu.M_数字机房_接地网 != CabinetUIManager.Instance.current_menu)
|
||
{
|
||
for (int i = 0; i < GameManager.Inst.Cabinets_go.Count; i++)
|
||
{
|
||
//string s2 = GameManager.Inst.Cabinets_go[i].GetComponent<DeviceQuery>().deviceList.devicePosition.Split('-')[0];
|
||
//if (s1 != s2)
|
||
GameManager.Inst.Cabinets_go[i].SetActive(true);
|
||
//else if (s1 == s2 && GameManager.Inst.Cabinets_go[i] != gameObject)
|
||
GameManager.Inst.Cabinets_go[i].GetComponent<TransparentGlow>().F2();
|
||
}
|
||
for (int i = 0; i < GameManager.Inst.roomDoors.Count; i++)
|
||
{
|
||
GameManager.Inst.roomDoors[i].gameObject.GetComponent<BoxCollider>().enabled = true;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
List<Transform> transforms = new List<Transform>();
|
||
transforms.AddRange(TransparentGlowManage.Inst.points);
|
||
transforms.AddRange(TransparentGlowManage.Inst.points_battery);
|
||
|
||
var s = Array.FindAll(transforms.ToArray(), (item) =>
|
||
{
|
||
return (item.GetComponent<TransparentGlow>() != null /*&&
|
||
item.name != "R08" && item.name != "R15" && item.name != "R65" &&
|
||
item.name != "R57" && item.name != "R54" && item.name != "R45" &&
|
||
item.name != "R37" && item.name != "R29" && item.name != "R22"*/);
|
||
}).Select(item => item.GetComponent<TransparentGlow>()).ToArray();
|
||
|
||
TransparentGlowManage.Inst.transparencyALL(s);
|
||
}
|
||
|
||
for (int i = 0; i < GameManager.Inst.TmsPorts_go.Count; i++)
|
||
{
|
||
GameManager.Inst.TmsPorts_go[i].GetComponent<PortQuery>().hight.SetActive(false);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 点击鸟瞰
|
||
/// </summary>
|
||
public void niaoKan_fuc()
|
||
{
|
||
GameManager.Inst.editorMenu.gameObject.SetActive(false);
|
||
ExtendedFlycam.Inst.QieHuan(CabinetUIManager.Instance.current_menu, 3);
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
if (GameManager.Inst.magnifyState)
|
||
{
|
||
back_page.gameObject.SetActive(true);
|
||
}
|
||
else
|
||
{
|
||
back_page.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
|
||
public void F1(bool isheatMap)
|
||
{
|
||
heatMap.SetActive(isheatMap);
|
||
ExtendedFlycam.Inst.init_mainCamera_rot();
|
||
Camera.main.transform.DOMove(/*TransparentGlowManage.Inst.MainCamera_pos*/init_pos, 1f);
|
||
Camera.main.transform.DORotateQuaternion(Quaternion.Euler(/*TransparentGlowManage.Inst.MainCamera_rot*/init_rot), 1f).OnComplete(() =>
|
||
{
|
||
//更新相机初始旋转角度
|
||
ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
|
||
});
|
||
TransparentGlowManage.Inst.renewALL();
|
||
}
|
||
|
||
void F2(bool isheatMap)
|
||
{
|
||
heatMap.SetActive(isheatMap);
|
||
ExtendedFlycam.Inst.init_mainCamera_rot();
|
||
Camera.main.transform.DOMove(/*TransparentGlowManage.Inst.MainCamera_pos*/init_pos, 1f);
|
||
Camera.main.transform.DORotateQuaternion(Quaternion.Euler(/*TransparentGlowManage.Inst.MainCamera_rot*/init_rot), 1f).OnComplete(() =>
|
||
{
|
||
//更新相机初始旋转角度
|
||
ExtendedFlycam.Inst.initialRotationEulerAngles = Camera.main.transform.localEulerAngles;
|
||
});
|
||
TransparentGlowManage.Inst.renewALL();
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 关闭所有弹窗
|
||
/// </summary>
|
||
public void clspup(Menu menu = Menu.None)
|
||
{
|
||
sb_bj_page.SetActive(false);
|
||
sb_xz_page.SetActive(false);
|
||
if (Menu.M_数字机房_线缆连接_配置 != menu || !GameManager.Inst.magnifyState)
|
||
dk_bj_page.SetActive(false);
|
||
dk_xz_page.SetActive(false);
|
||
sb_ck_page.SetActive(false);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检测字符
|
||
/// </summary>
|
||
/// <param name="_callback"></param>
|
||
/// <param name="inputField"></param>
|
||
/// <param name="inputField1"></param>
|
||
public void DetectCharacters(Action<bool> _callback, TMP_InputField inputField = null, InputField inputField1 = null)
|
||
{
|
||
if (inputField != null)
|
||
{
|
||
if (CheckString(inputField.text))
|
||
_callback?.Invoke(true);
|
||
else
|
||
{
|
||
SecondConfirmPanel.DeleteConform((x) =>
|
||
{
|
||
_callback?.Invoke(false);
|
||
}, "请检查:输入长度(50字符内);内容是否含有空格、换行、转义字符、特殊符号");
|
||
}
|
||
}
|
||
else if (inputField1 != null)
|
||
{
|
||
if (CheckString(inputField1.text))
|
||
_callback?.Invoke(true);
|
||
else
|
||
{
|
||
SecondConfirmPanel.DeleteConform((x) =>
|
||
{
|
||
_callback?.Invoke(false);
|
||
}, "请检查:输入长度(50字符内);内容是否含有空格、换行、转义字符、特殊符号");
|
||
}
|
||
}
|
||
else
|
||
_callback?.Invoke(false);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检查字符串
|
||
/// </summary>
|
||
/// <param name="input"></param>
|
||
/// <returns></returns>
|
||
public bool CheckString(string input)
|
||
{
|
||
if (string.IsNullOrEmpty(input))
|
||
{
|
||
return false; // 如果输入为空字符串,则返回false
|
||
}
|
||
|
||
if (input.Length > 50)
|
||
{
|
||
return false; // 如果长度超过50,则返回false
|
||
}
|
||
foreach (char c in input)
|
||
{
|
||
if (char.IsWhiteSpace(c) || char.IsControl(c) || char.IsSymbol(c))
|
||
{
|
||
return false; // 如果包含空格、换行、转义字符、特殊符号,则返回false
|
||
}
|
||
}
|
||
return true; // 如果没有空格、换行、转义字符、特殊符号且长度不超过50,则返回true
|
||
}
|
||
}
|