123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class GongChengLieBiaoItem : MonoBehaviour
- {
- public GongChengLieBiaoData _currentData;
- private Text _indexText;
- private Text _nameText;
- private Text _stateText;
- private Button _button;
- private Image _highLightImg;
-
- public void Init()
- {
- _indexText = this.transform.Find("index").GetComponent<Text>();
- _nameText = this.transform.Find("type").GetComponent<Text>();
- _stateText = this.transform.Find("state").GetComponent<Text>();
- _highLightImg = this.transform.Find("highLight").GetComponent<Image>();
- _button = this.GetComponent<Button>();
- _button.onClick.AddListener(ItemClick);
- }
- public void ItemClick()
- {
- switch (_currentData.type)
- {
- case GongChengType.shuiWei:
- case GongChengType.shuiYa:
- case GongChengType.weiYi:
- if (GCJKLayer._Instance.currentSelectItem != null)
- {
- GCJKLayer._Instance.currentSelectItem.SetHighLight(false);
- }
- GCJKLayer._Instance.currentSelectItem = this;
- SetHighLight(true);
- GCJKLayer._Instance._DeviceTrendPanel.Show(_currentData.name,_currentData.type,_currentData.gid,_currentData.sid);
- break;
- }
- }
- private void OnDestroy()
- {
- if (GCJKLayer._Instance.currentSelectItem != null && GCJKLayer._Instance.currentSelectItem == this)
- {
- GCJKLayer._Instance.currentSelectItem = null;
- }
- }
- public void SetHighLight(bool show)
- {
- _highLightImg.enabled = show;
- }
- public void SetData(GongChengLieBiaoData data)
- {
- _currentData = data;
- _indexText.text = $"{_currentData.index:00}";
- _nameText.text = $"{_currentData.name}";
- switch (_currentData.state)
- {
- case GongChengState.normal:
- _stateText.text = $"<color=#15DCFC>正常</color>";
- break;
- case GongChengState.runing:
- _stateText.text = $"<color=#15DCFC>运行</color>";
- break;
- case GongChengState.fix:
- _stateText.text = $"<color=#FFBC1D>养护</color>";
- break;
- case GongChengState.warning:
- _stateText.text = $"<color=#EF491C>告警</color>";
- break;
- }
- }
- }
|