123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- using Com.Xzzs.Boiler.Proto;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class BoilerLevel : MonoBehaviour
- {
- public GameObject level_1;
- public GameObject level_2;
- public GameObject obj_Fill;
- public GameObject obj_Water;
- public GameObject obj_Shell;
- public GameObject obj_Fill_2;
- public GameObject obj_Fill_3;
- public GameObject CYQ;
- public GameObject CYQ_Level;
- bool Istrue;
- public GameObject Sl_A001; //水冷壁
- public GameObject ZF_A003; //蒸发
- public GameObject GR_A004; //过热
- public GameObject JJ_A005; //经济
- public GameObject war_nei;
- public GameObject war_wai;
- public List<GameObject> LQ_level2_list; // 炉墙
- public List<GameObject> LQ_level2_list_2; //外墙
-
- // Start is called before the first frame update
- void Start()
- {
- MessageManager.Instance.OnAddlisten((int)MessageId.MainBoilerLevel, SetLevel);
- MessageManager.Instance.OnAddlisten((int)MessageId.SGGData_Model, SetObjMater); // 上锅筒
- MessageManager.Instance.OnAddlisten((int)MessageId.MainBoilerWaterLevel, SetWaiterLevelStatus);
- MessageManager.Instance.OnAddlisten((int)MessageId.CYQData_Color, BoolCYQColor);
- MessageManager.Instance.OnAddlisten((int)MessageId.CYQData_Model, SetCYQColor);
- MessageManager.Instance.OnAddlisten((int)MessageId.JJQData_Model, SetJJ_A005Color);
- MessageManager.Instance.OnAddlisten((int)MessageId.GRQData_Model, SetGR_A004Color);
- MessageManager.Instance.OnAddlisten((int)MessageId.SGGData_Model, SetLQLevelColor);
- }
- void SetLevel(object obj)
- {
- int id = (int)(obj as object[])[0];
- switch (id)
- {
- case 1:
- level_1.SetActive(true);
- level_2.SetActive(true);
- break;
- case 2:
- level_1.SetActive(false);
- level_2.SetActive(true);
- break;
- case 3:
- level_1.SetActive(false);
- level_2.SetActive(false);
- break;
- default:
- break;
- }
-
- }
-
- //过热器
- void SetGR_A004Color(object obj)
- {
- object[] data = obj as object[];
- GRQ grq = data[0] as GRQ;
- float value = (float)(float.Parse(grq.GRQTwoavgTemperature) / CommonDefine.Instance.upperLimit_GRQ_GRQTwoavgTemperature)*0.5f;
- GR_A004.GetComponent<MeshRenderer>().material.color = new Color(0.5f+ value, 0.172549f, 0.1215686f, 1);
- }
- //经济器
- void SetJJ_A005Color(object obj)
- {
- object[] data = obj as object[];
- JJQ jjq = data[0] as JJQ;
- float value = (float)((float.Parse(jjq.JJQTwoavgTemperature) - CommonDefine.Instance.lowerLimit_JJq_JJQTwoavgTemperature) / (CommonDefine.Instance.upperLimit_JJq_JJQTwoavgTemperature - CommonDefine.Instance.lowerLimit_JJq_JJQTwoavgTemperature)) * 0.5f;
- JJ_A005.GetComponent<MeshRenderer>().material.color = new Color(0.092f, 0.5f+ value, 0.01446244f, 1);
- }
- //炉墙
- void SetLQLevelColor(object obj)
- {
- object[] data = obj as object[];
- SXGG sgg = data[0] as SXGG;
- float temp =(float)(float.Parse(sgg.FurnaceGasTemperature) / CommonDefine.Instance.upperLimit_SGG_FurnaceGasTemperature )*0.5f;
- for (int i = 0; i < LQ_level2_list.Count; i++)
- {
- LQ_level2_list[i].GetComponent<MeshRenderer>().material.color = new Color(0.42f+temp, 0.3529412f, 0.2039216f, 1);
- }
- float temp_2 = (float)(float.Parse(sgg.FurnaceGasTemperature) / CommonDefine.Instance.upperLimit_SGG_FurnaceGasTemperature) * 0.3f;
- for (int i = 0; i < LQ_level2_list_2.Count; i++)
- {
- LQ_level2_list_2[i].GetComponent<MeshRenderer>().material.color = new Color(0.6f + temp_2, 0.5607843f, 0.5607843f, 1);
- }
- }
- void SetWaiterLevelStatus(object obj)
- {
-
- obj_Fill.SetActive(!obj_Fill.activeSelf);
- obj_Fill_2.SetActive(!obj_Fill_2.activeSelf);
- obj_Fill_3.SetActive(!obj_Fill_3.activeSelf);
- if (obj_Fill.activeSelf)
- {
- Material mat = MaterialsManager.Instance.GetMaterial("A_super_charged_boiler_A049");
- obj_Shell.GetComponent<MeshRenderer>().material = mat;
- }
- else
- {
- Material mat = MaterialsManager.Instance.GetMaterial("LucencyMaterial");
- obj_Shell.GetComponent<MeshRenderer>().material = mat;
- }
-
- }
- void SetObjMater(object obj)
- {
- object[] data = obj as object[];
- SXGG sgg = data[0] as SXGG;
- float level = float.Parse(sgg.SGGWaterlevel);
- level = level - (float)CommonDefine.Instance.lowerLimit_SGT_level;
- level = (level / (float)(CommonDefine.Instance.upperLimit_SGG_Waterlevel - CommonDefine.Instance.lowerLimit_SGT_level)) * 140;
-
- obj_Water.GetComponent<MeshRenderer>().material.SetFloat("_FillAmount", 70-level);
- float temp = (float.Parse(sgg.DeclineAvgTemperature) / (float)CommonDefine.Instance.upperLimit_SGG_DeclineAvgTemperature) * 0.5f;
- //设置水冷壁颜色
- Sl_A001.GetComponent<MeshRenderer>().material.color = new Color(0.5f+ temp, 0.4528302f, 0.1431114f, 1);
- float temp_2 = (float.Parse(sgg.UpAvgTemperature) / (float)CommonDefine.Instance.upperLimit_SGG_DeclineAvgTemperature) * 0.5f;
- //蒸发管
- ZF_A003.GetComponent<MeshRenderer>().material.color = new Color(0.5f+ temp_2, 0.4528302f, 0.1431114f, 1);
- }
- void BoolCYQColor(object obj)
- {
- Istrue = (bool)(obj as object[])[0];
- }
- void SetCYQColor(object obj)
- {
- object[] data = obj as object[];
- CYQ cyq = data[0] as CYQ;
-
- if (Istrue)
- {
- float num = float.Parse(cyq.CYQWatertankTemperature) / (float)CommonDefine.Instance.upperLimit_CYQ_Watertemperature;
- if (num > 1)
- {
- num = 1;
- }
- CYQ.GetComponent<MeshRenderer>().material.color = new Color(1, 1 - num, 1 - num, 1);
- }
- else
- {
- float num = float.Parse(cyq.CYQWatertankPressure) / (float)CommonDefine.Instance.upperLimit_CYQ_Waterpressure;
- if (num > 1)
- {
- num = 1;
- }
- CYQ.GetComponent<MeshRenderer>().material.color = new Color(1,1 , 1 - num, 1);
- }
- float level = float.Parse(cyq.CYQWatertankWaterlevel);
- level = level - (float)CommonDefine.Instance.lowerLimit_SGT_level;
- level = (level / (float)(CommonDefine.Instance.upperLimit_CYQ_WaterLevel - CommonDefine.Instance.lowerLimit_CYQ_WaterLevel)) * 140;
- CYQ_Level.GetComponent<MeshRenderer>().material.SetFloat("_FillAmount", 70 - level);
- }
- private void OnDestroy()
- {
- MessageManager.Instance.OnDestory((int)MessageId.MainBoilerLevel);
- MessageManager.Instance.OnDestory((int)MessageId.MainBoilerWaterLevel);
- MessageManager.Instance.OnDestory((int)MessageId.CYQData_Color);
- MessageManager.Instance.OnDestory((int)MessageId.CYQData_Model );
- MessageManager.Instance.OnDestory((int)MessageId.JJQData_Model );
- MessageManager.Instance.OnDestory((int)MessageId.GRQData_Model);
- MessageManager.Instance.OnDestory((int)MessageId.SGGData_Model);
- }
- }
|