BoilerLevel.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using Com.Xzzs.Boiler.Proto;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class BoilerLevel : MonoBehaviour
  6. {
  7. public GameObject level_1;
  8. public GameObject level_2;
  9. public GameObject obj_Fill;
  10. public GameObject obj_Water;
  11. public GameObject obj_Shell;
  12. public GameObject obj_Fill_2;
  13. public GameObject obj_Fill_3;
  14. public GameObject CYQ;
  15. public GameObject CYQ_Level;
  16. bool Istrue;
  17. public GameObject Sl_A001; //水冷壁
  18. public GameObject ZF_A003; //蒸发
  19. public GameObject GR_A004; //过热
  20. public GameObject JJ_A005; //经济
  21. public GameObject war_nei;
  22. public GameObject war_wai;
  23. public List<GameObject> LQ_level2_list; // 炉墙
  24. public List<GameObject> LQ_level2_list_2; //外墙
  25. // Start is called before the first frame update
  26. void Start()
  27. {
  28. MessageManager.Instance.OnAddlisten((int)MessageId.MainBoilerLevel, SetLevel);
  29. MessageManager.Instance.OnAddlisten((int)MessageId.SGGData_Model, SetObjMater); // 上锅筒
  30. MessageManager.Instance.OnAddlisten((int)MessageId.MainBoilerWaterLevel, SetWaiterLevelStatus);
  31. MessageManager.Instance.OnAddlisten((int)MessageId.CYQData_Color, BoolCYQColor);
  32. MessageManager.Instance.OnAddlisten((int)MessageId.CYQData_Model, SetCYQColor);
  33. MessageManager.Instance.OnAddlisten((int)MessageId.JJQData_Model, SetJJ_A005Color);
  34. MessageManager.Instance.OnAddlisten((int)MessageId.GRQData_Model, SetGR_A004Color);
  35. MessageManager.Instance.OnAddlisten((int)MessageId.SGGData_Model, SetLQLevelColor);
  36. }
  37. void SetLevel(object obj)
  38. {
  39. int id = (int)(obj as object[])[0];
  40. switch (id)
  41. {
  42. case 1:
  43. level_1.SetActive(true);
  44. level_2.SetActive(true);
  45. break;
  46. case 2:
  47. level_1.SetActive(false);
  48. level_2.SetActive(true);
  49. break;
  50. case 3:
  51. level_1.SetActive(false);
  52. level_2.SetActive(false);
  53. break;
  54. default:
  55. break;
  56. }
  57. }
  58. //过热器
  59. void SetGR_A004Color(object obj)
  60. {
  61. object[] data = obj as object[];
  62. GRQ grq = data[0] as GRQ;
  63. float value = (float)(float.Parse(grq.GRQTwoavgTemperature) / CommonDefine.Instance.upperLimit_GRQ_GRQTwoavgTemperature)*0.5f;
  64. GR_A004.GetComponent<MeshRenderer>().material.color = new Color(0.5f+ value, 0.172549f, 0.1215686f, 1);
  65. }
  66. //经济器
  67. void SetJJ_A005Color(object obj)
  68. {
  69. object[] data = obj as object[];
  70. JJQ jjq = data[0] as JJQ;
  71. float value = (float)((float.Parse(jjq.JJQTwoavgTemperature) - CommonDefine.Instance.lowerLimit_JJq_JJQTwoavgTemperature) / (CommonDefine.Instance.upperLimit_JJq_JJQTwoavgTemperature - CommonDefine.Instance.lowerLimit_JJq_JJQTwoavgTemperature)) * 0.5f;
  72. JJ_A005.GetComponent<MeshRenderer>().material.color = new Color(0.092f, 0.5f+ value, 0.01446244f, 1);
  73. }
  74. //炉墙
  75. void SetLQLevelColor(object obj)
  76. {
  77. object[] data = obj as object[];
  78. SXGG sgg = data[0] as SXGG;
  79. float temp =(float)(float.Parse(sgg.FurnaceGasTemperature) / CommonDefine.Instance.upperLimit_SGG_FurnaceGasTemperature )*0.5f;
  80. for (int i = 0; i < LQ_level2_list.Count; i++)
  81. {
  82. LQ_level2_list[i].GetComponent<MeshRenderer>().material.color = new Color(0.42f+temp, 0.3529412f, 0.2039216f, 1);
  83. }
  84. float temp_2 = (float)(float.Parse(sgg.FurnaceGasTemperature) / CommonDefine.Instance.upperLimit_SGG_FurnaceGasTemperature) * 0.3f;
  85. for (int i = 0; i < LQ_level2_list_2.Count; i++)
  86. {
  87. LQ_level2_list_2[i].GetComponent<MeshRenderer>().material.color = new Color(0.6f + temp_2, 0.5607843f, 0.5607843f, 1);
  88. }
  89. }
  90. void SetWaiterLevelStatus(object obj)
  91. {
  92. obj_Fill.SetActive(!obj_Fill.activeSelf);
  93. obj_Fill_2.SetActive(!obj_Fill_2.activeSelf);
  94. obj_Fill_3.SetActive(!obj_Fill_3.activeSelf);
  95. if (obj_Fill.activeSelf)
  96. {
  97. Material mat = MaterialsManager.Instance.GetMaterial("A_super_charged_boiler_A049");
  98. obj_Shell.GetComponent<MeshRenderer>().material = mat;
  99. }
  100. else
  101. {
  102. Material mat = MaterialsManager.Instance.GetMaterial("LucencyMaterial");
  103. obj_Shell.GetComponent<MeshRenderer>().material = mat;
  104. }
  105. }
  106. void SetObjMater(object obj)
  107. {
  108. object[] data = obj as object[];
  109. SXGG sgg = data[0] as SXGG;
  110. float level = float.Parse(sgg.SGGWaterlevel);
  111. level = level - (float)CommonDefine.Instance.lowerLimit_SGT_level;
  112. level = (level / (float)(CommonDefine.Instance.upperLimit_SGG_Waterlevel - CommonDefine.Instance.lowerLimit_SGT_level)) * 140;
  113. obj_Water.GetComponent<MeshRenderer>().material.SetFloat("_FillAmount", 70-level);
  114. float temp = (float.Parse(sgg.DeclineAvgTemperature) / (float)CommonDefine.Instance.upperLimit_SGG_DeclineAvgTemperature) * 0.5f;
  115. //设置水冷壁颜色
  116. Sl_A001.GetComponent<MeshRenderer>().material.color = new Color(0.5f+ temp, 0.4528302f, 0.1431114f, 1);
  117. float temp_2 = (float.Parse(sgg.UpAvgTemperature) / (float)CommonDefine.Instance.upperLimit_SGG_DeclineAvgTemperature) * 0.5f;
  118. //蒸发管
  119. ZF_A003.GetComponent<MeshRenderer>().material.color = new Color(0.5f+ temp_2, 0.4528302f, 0.1431114f, 1);
  120. }
  121. void BoolCYQColor(object obj)
  122. {
  123. Istrue = (bool)(obj as object[])[0];
  124. }
  125. void SetCYQColor(object obj)
  126. {
  127. object[] data = obj as object[];
  128. CYQ cyq = data[0] as CYQ;
  129. if (Istrue)
  130. {
  131. float num = float.Parse(cyq.CYQWatertankTemperature) / (float)CommonDefine.Instance.upperLimit_CYQ_Watertemperature;
  132. if (num > 1)
  133. {
  134. num = 1;
  135. }
  136. CYQ.GetComponent<MeshRenderer>().material.color = new Color(1, 1 - num, 1 - num, 1);
  137. }
  138. else
  139. {
  140. float num = float.Parse(cyq.CYQWatertankPressure) / (float)CommonDefine.Instance.upperLimit_CYQ_Waterpressure;
  141. if (num > 1)
  142. {
  143. num = 1;
  144. }
  145. CYQ.GetComponent<MeshRenderer>().material.color = new Color(1,1 , 1 - num, 1);
  146. }
  147. float level = float.Parse(cyq.CYQWatertankWaterlevel);
  148. level = level - (float)CommonDefine.Instance.lowerLimit_SGT_level;
  149. level = (level / (float)(CommonDefine.Instance.upperLimit_CYQ_WaterLevel - CommonDefine.Instance.lowerLimit_CYQ_WaterLevel)) * 140;
  150. CYQ_Level.GetComponent<MeshRenderer>().material.SetFloat("_FillAmount", 70 - level);
  151. }
  152. private void OnDestroy()
  153. {
  154. MessageManager.Instance.OnDestory((int)MessageId.MainBoilerLevel);
  155. MessageManager.Instance.OnDestory((int)MessageId.MainBoilerWaterLevel);
  156. MessageManager.Instance.OnDestory((int)MessageId.CYQData_Color);
  157. MessageManager.Instance.OnDestory((int)MessageId.CYQData_Model );
  158. MessageManager.Instance.OnDestory((int)MessageId.JJQData_Model );
  159. MessageManager.Instance.OnDestory((int)MessageId.GRQData_Model);
  160. MessageManager.Instance.OnDestory((int)MessageId.SGGData_Model);
  161. }
  162. }