ShanxiKnowledgeBase/SXElectricalInspection/Assets/Adam/Scripts/NameplateController.cs

94 lines
2.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
public class NameplateController : MonoSingleton<NameplateController>
{
public GameObject NameplatePanel;
public RectTransform backTransform;
public RectTransform mtTransform;
public Image NameplateImage;
public GameObject[] Obj_Nameplate;
public List<TextMeshProUGUI> NameplateTextUGUI;
public List<TextMeshPro> TextUGUI_NBQ;
public List<TextMeshPro> TextUGUI_HGQ;
public Dictionary<string, TextMeshProUGUI> DictextMeshPro;
private void Start()
{
Invoke("AddNameplateClick", 5.0f);
}
public void AddNameplateClick()
{
DictextMeshPro = new Dictionary<string, TextMeshProUGUI>();
TextUGUI_NBQ = new List<TextMeshPro>();
TextUGUI_HGQ = new List<TextMeshPro>();
DictextMeshPro.Add("低压互感器铭牌", NameplateTextUGUI[0]);
DictextMeshPro.Add("2号逆变器_铭牌_正确", NameplateTextUGUI[1]);
DictextMeshPro.Add("光伏板_铭牌", NameplateTextUGUI[2]);
Obj_Nameplate = GameObject.FindGameObjectsWithTag("铭牌");
foreach (GameObject item in Obj_Nameplate)
{
item.AddComponent<ShowNameplate>().onDown.AddListener(() =>
{
if (isOnece)
{
SendScore();
Debug.Log("23232传分");
isOnece = false;
}
});
if (item.name != "光伏板_铭牌")
{
TextMeshPro itemMesh = item.transform.GetChild(0).GetComponent<TextMeshPro>();
if (item.name == "低压互感器铭牌")
{
TextUGUI_HGQ.Add(itemMesh);
if (GlobalFlag.isChange == "1")
itemMesh.text = GlobalFlag.runRL.ToString();
else
itemMesh.text = (5 * GlobalFlag.runRL).ToString();
}
else
{
TextUGUI_NBQ.Add(itemMesh);
itemMesh.text = GlobalFlag.pvw.ToString();
}
}
}
}
public bool isOnece = true;
public async void SendScore()
{
if (FractionManager.Instance)
{
await FractionManager.Instance.overAsync(5, 10, "检查光伏");
}
string sceneInfo = GlobalFlag.SceneInfo();
var tempStr = sceneInfo.Split('_');
if (FractionManager.Instance && GlobalFlag.userType == "异常" && tempStr[tempStr.Length - 1].Equals("有光伏"))
{
await FractionManager.Instance.overAsync(6, 10, "测量窃电点");
}
}
public void RefreshShown()
{
foreach (TextMeshProUGUI item in NameplateTextUGUI)
{
item.gameObject.SetActive(false);
}
}
}