using DG.Tweening;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
///
/// 模式选择
///
[AddComponentMenu("PatternChoose/模式选择")]
public class PatternChoose : MonoBehaviour
{
static PatternChoose _inst;
public static PatternChoose Inst => _inst;
public Button TS_button;
public Button RL_button;
///
/// 热力效果图
///
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;
///
/// 设备新增窗口
///
public GameObject sb_xz_page;
///
/// 设备编辑窗口
///
public GameObject sb_bj_page;
///
/// 设备查看窗口
///
public GameObject sb_ck_page;
///
/// 端口新增窗口
///
public GameObject dk_xz_page;
///
/// 端口编辑窗口
///
public GameObject dk_bj_page;
public CreateLine huaXian;
///
/// 线缆
///
public ByCode xianlan;
public GameObject xianlan_popup;
public UIToCabinet uiToCabinet;
public Image xunJianImg;
[Header("时间筛选")]
public GameObject calendar;
//public ZCalendar zCalendar;
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) =>
{
if (isgo)
{
roomCut_fuc();
}
});
});
quanJing.onValueChanged.AddListener((x) =>
{
if (!x)
return;
ExtendedFlycam.Inst.reminder((isgo) =>
{
if (isgo)
{
quanJing_fuc();
}
});
});
niaoKan.onValueChanged.AddListener((x) =>
{
ExtendedFlycam.Inst.reminder((isgo) =>
{
if (isgo)
{
niaoKan_fuc();
}
});
});
back_page.onClick.AddListener(() =>
{
ExtendedFlycam.Inst.reminder((isgo) =>
{
if (isgo)
{
quanJing_fuc();
if (Menu.M_数字孪生_线缆连接_展示 == CabinetUIManager.Instance.current_menu)
{
SearchName searchName = search_go.GetComponent();
searchName.showXianLan(searchName._co);
}
else if (Menu.M_数字孪生_场景管理 == CabinetUIManager.Instance.current_menu)
{
GameManager.Inst.search_box.GetComponent().LoadCabinet(SearchName.SearchType.机柜);
GameManager.Inst.search_box.SetActive(true);
}
}
});
});
//Debug.Log("版本号 1.1.1");
}
///
/// 点击切换房间
///
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);
}
}
///
/// 点击全景
///
public void quanJing_fuc()
{
//if (!quanJing.isOn)
// return;
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().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().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().F2();
}
for (int i = 0; i < GameManager.Inst.roomDoors.Count; i++)
{
GameManager.Inst.roomDoors[i].gameObject.GetComponent().enabled = true;
}
}
else
{
List transforms = new List();
transforms.AddRange(TransparentGlowManage.Inst.points);
transforms.AddRange(TransparentGlowManage.Inst.points_battery);
var s = Array.FindAll(transforms.ToArray(), (item) =>
{
return (item.GetComponent() != 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()).ToArray();
TransparentGlowManage.Inst.transparencyALL(s);
}
for (int i = 0; i < GameManager.Inst.TmsPorts_go.Count; i++)
{
GameManager.Inst.TmsPorts_go[i].GetComponent().hight.SetActive(false);
}
}
///
/// 点击鸟瞰
///
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();
}
///
/// 关闭所有弹窗
///
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);
}
}