JiNanCementPlantForUnity/Assets/Scripts/ShowGroup.cs

402 lines
14 KiB
C#

using HighlightPlus;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ShowGroup : MonoBehaviour
{
public static ShowGroup _instance;
public List<GameObject> 线;
public List<GameObject> _空压机房_;
public List<GameObject> 线;
public List<GameObject> 线;
public List<GameObject> ;
public List<GameObject> ;
public List<GameObject> ;
public List<GameObject> _回转窑空压机房_;
public List<GameObject> ;
public List<GameObject> ;
public List<GameObject> ;
public List<GameObject> ;
public List<GameObject> ;
public List<GameObject> ;
public GameObject Parent_配电室点位;
public GameObject ;
public GameObject Parent_水;
void Start()
{
_instance = this;
foreach (Transform item in Parent_配电室点位.transform)
{
if (item.gameObject.activeInHierarchy)
.Add(item.gameObject);
}
foreach (Transform item in Parent_水.transform)
{
if (item.gameObject.activeInHierarchy)
.Add(item.gameObject);
}
foreach (Transform item in .transform)
{
if (item.gameObject.activeInHierarchy)
.Add(item.gameObject);
}
}
public void Show(string name)
{
if (name.Contains("1号生产线"))
{
Hide();
for (int i = 0; i < 线.Count; i++)
{
线[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip(线[i], out GameObject tip);
if (!线[i].name.Equals("空压机房"))
{
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = 线[i].name;
}
}
CameraTween.instance.MoveCameraToPos("1号生产线");
}
else if (name.Contains("2号生产线"))
{
Hide();
for (int i = 0; i < 线.Count; i++)
{
线[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip(线[i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = 线[i].name;
}
CameraTween.instance.MoveCameraToPos("2号生产线");
}
else if (name.Contains("3号生产线"))
{
Hide();
for (int i = 0; i < 线.Count; i++)
{
线[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip(线[i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = 线[i].name;
}
CameraTween.instance.MoveCameraToPos("3号生产线");
}
else if (name.Contains("破碎系统"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip([i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = [i].name;
m.Message = [i].name;
}
CameraTween.instance.MoveCameraToPos("破碎系统");
}
else if (name.Contains("生料系统"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip([i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = [i].name;
}
CameraTween.instance.MoveCameraToPos("生料系统");
}
else if (name.Contains("回转窑系统"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip([i], out GameObject tip);
if (![i].name.Equals("回转窑空压机房"))
{
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = [i].name;
}
}
CameraTween.instance.MoveCameraToPos("回转窑系统");
}
else if (name.Contains("煤磨系统"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip([i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = [i].name;
}
CameraTween.instance.MoveCameraToPos("煤磨系统");
}
else if (name.Contains("水泥磨系统"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip([i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = [i].name;
}
CameraTween.instance.MoveCameraToPos("水泥磨系统");
}
else if (name.Contains("能源监测_煤"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip([i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = [i].name;
}
CameraTween.instance.MoveCameraToPos("主视角");
}
else if (name.Contains("配电室"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
ShowTip([i], out GameObject tip);
AddEventListener(tip.transform, [i]);
}
CameraTween.instance.MoveCameraToPos("主视角");
}
else if (name.Contains("能源监测_水"))
{
Hide();
for (int i = 0; i < .Count; i++)
{
ShowTip([i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = [i].name;
}
}
else
{
Hide();
CameraTween.instance.MoveCameraToPos("主视角");
}
}
#region
private void Hide()
{
ClaerTips();
for (int i = 0; i < 线.Count; i++)
{
线[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < _回转窑空压机房_.Count; i++)
{
_回转窑空压机房_[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < _空压机房_.Count; i++)
{
_空压机房_[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < 线.Count; i++)
{
线[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < 线.Count; i++)
{
线[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < .Count; i++)
{
线[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < .Count; i++)
{
[i].GetComponent<HighlightEffect>().highlighted = false;
}
for (int i = 0; i < .Count; i++)
{
}
for (int i = 0; i < .Count; i++)
{
}
}
#endregion
public GameObject PointTipPrefab;
[Header("生成的标签")]
public List<GameObject> PointTips;
/// <summary>
/// 展示标签,标签内容更新
/// </summary>
/// <param name="tf"></param>
private void ShowTip(GameObject tf, out GameObject tip)
{
if (tf.transform.Find("LabelPos"))
{
var t = Instantiate(PointTipPrefab, tf.transform.Find("LabelPos"));
tip = t;
tf.transform.Find("LabelPos").eulerAngles = Vector3.zero;
t.GetComponentInChildren<TextMeshProUGUI>().text = tf.name;
if (tf.name.Equals("回转窑空压机房"))
{
t.transform.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
{
Hide();
for (int i = 0; i < _回转窑空压机房_.Count; i++)
{
_回转窑空压机房_[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip(_回转窑空压机房_[i], out GameObject tip);
var m = tip.AddComponent<UITIP>();
m.type = TipType.;
m.Message = _回转窑空压机房_[i].name;
}
CameraTween.instance.MoveCameraToPos("回转窑空压机房");
});
t.transform.Find("video").gameObject.SetActive(true);
t.transform.Find("video").GetComponent<Button>().onClick.AddListener(() =>
{
VideoManager.instance.ShowVideo("空压机动画");
});
}
else if (tf.name.Equals("空压机房"))
{
t.transform.Find("Button").GetComponent<Button>().onClick.AddListener(() =>
{
Hide();
for (int i = 0; i < _空压机房_.Count; i++)
{
_空压机房_[i].GetComponent<HighlightEffect>().highlighted = true;
ShowTip(_空压机房_[i], out GameObject tip1);
var m = tip1.AddComponent<UITIP>();
m.type = TipType.;
m.Message = _空压机房_[i].name;
}
CameraTween.instance.MoveCameraToPos("空压机房");
});
}
PointTips.Add(t);
}
else
{
var t = Instantiate(PointTipPrefab, tf.transform);
tip = t;
t.GetComponentInChildren<TextMeshProUGUI>().text = tf.name;
if (tf.name.Contains("_"))
{
string[] array = tf.name.Split("_");
t.GetComponentInChildren<TextMeshProUGUI>().text = array[1];
}
PointTips.Add(t);
}
}
private void AddEventListener(Transform BtnTransform, GameObject g)
{
Button btn = BtnTransform.GetComponentInChildren<Button>();
//string t = "{\"type\": \"Btn\", \"message\": \"" + g.name + "\"}";
string t = g.name;
btn.onClick.AddListener(() =>
{
for (int i = 0; i < .Count; i++)
{
if ([i].name == g.name)
{
CameraTween.instance.MoveCameraToPos(g.name);
}
}
BrideWebView.Instance.webViewPrefab.WebView.PostMessage(t);
Debug.Log("(C#Log)JSON Post:" + t);
});
}
private void ClaerTips()
{
for (int i = 0; i < PointTips.Count; i++)
{
Destroy(PointTips[i]);
}
PointTips.Clear();
}
void Update()
{
//if (Input.GetKeyDown(KeyCode.Alpha1))
//{
// Show("主视角");
//}
//if (Input.GetKeyDown(KeyCode.Alpha2))
//{
// Show("1号生产线");
//}
//if (Input.GetKeyDown(KeyCode.Alpha3))
//{
// Show("2号生产线");
//}
//if (Input.GetKeyDown(KeyCode.Alpha4))
//{
// Show("3号生产线");
//}
//if (Input.GetKeyDown(KeyCode.Alpha5))
//{
// Show("破碎系统");
//}
//if (Input.GetKeyDown(KeyCode.Alpha6))
//{
// Show("生料系统");
//}
//if (Input.GetKeyDown(KeyCode.Alpha7))
//{
// Show("水泥磨系统");
//}
//if (Input.GetKeyDown(KeyCode.Alpha8))
//{
// Show("回转窑系统");
//}
//if (Input.GetKeyDown(KeyCode.Alpha9))
//{
// Show("煤磨系统");
//}
//if (Input.GetKeyDown(KeyCode.Keypad0))
//{
// Show("煤");
//}
}
}