GameManager.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using UnityEngine;
  6. using UnityTemplateProjects;
  7. using static DeMaConfig;
  8. using static InitTapList;
  9. public class GameManager : MonoBehaviour
  10. {
  11. public DeMaConfig config;
  12. public SimpleCameraController smp;
  13. [Serializable]
  14. public enum TuBiaoType
  15. {
  16. [ChineseDescription("总用电量")]
  17. 总用电量 =10001,
  18. [ChineseDescription("设备报警率")]
  19. 设备报警率=10002,
  20. [ChineseDescription("今日燃气流量")]
  21. 今日燃气流量=10003,
  22. [ChineseDescription("累计燃气用量")]
  23. 累计燃气用量=10004,
  24. [ChineseDescription("科技设备在线率")]
  25. 科技设备在线率 =20001,
  26. [ChineseDescription("科技设备利用率")]
  27. 科技设备利用率=20002,
  28. [ChineseDescription("工业设备在线率")]
  29. 工业设备在线率 =30001,
  30. [ChineseDescription("工业设备利用率")]
  31. 工业设备利用率=30002,
  32. }
  33. [Serializable]
  34. public enum GameObjectType
  35. {
  36. [ChineseDescription("园区")]
  37. 园区 =1,
  38. [ChineseDescription("科技车间")]
  39. 科技车间=2,
  40. [ChineseDescription("工业车间")]
  41. 工业车间=3,
  42. [ChineseDescription("电力")]
  43. 电力=4,
  44. [ChineseDescription("其他")]
  45. 其他=5,
  46. }
  47. // 定义枚举
  48. [Serializable]
  49. public enum TapName
  50. {
  51. [ChineseDescription("园区总览")]
  52. 园区总览=10001,
  53. [ChineseDescription("德马科技车间")]
  54. 德马科技车间=10002,
  55. [ChineseDescription("德马工业车间")]
  56. 德马工业车间=10003,
  57. [ChineseDescription("五期智慧工厂")]
  58. 五期智慧工厂=10004,
  59. [ChineseDescription("五期综合大楼")]
  60. 五期综合大楼=10005,
  61. [ChineseDescription("车间总览")]
  62. 科技车间总览=20001,
  63. [ChineseDescription("AMADA数控冲床")]
  64. AMADA数控冲床=20002,
  65. [ChineseDescription("1#AMADA数控折弯机")]
  66. AMADA数控折弯机1=20003,
  67. [ChineseDescription("2#AMADA数控折弯机")]
  68. AMADA数控折弯机2=20004,
  69. [ChineseDescription("数控折弯机")]
  70. 数控折弯机=20005,
  71. [ChineseDescription("电液伺服数控折弯机")]
  72. 电液伺服数控折弯机=20006,
  73. [ChineseDescription("电液伺服折弯机")]
  74. 电液伺服折弯机=20007,
  75. [ChineseDescription("百超激光切割机")]
  76. 百超激光切割机=20008,
  77. [ChineseDescription("辊轧冲")]
  78. 辊轧冲=20009,
  79. [ChineseDescription("数控带锯床")]
  80. 数控带锯床=20010,
  81. [ChineseDescription("涂装(生产线)系统")]
  82. 涂装生产线系统=20011,
  83. [ChineseDescription("抛丸机")]
  84. 抛丸机=20012,
  85. [ChineseDescription("车间总览")]
  86. 工业车间总览=30001,
  87. [ChineseDescription("1#激光切管倒角一体机")]
  88. 激光切管倒角一体机1=30002,
  89. [ChineseDescription("1#S11轴切割倒角冲耳机一体机")]
  90. S11轴切割倒角冲耳机一体机1=30003,
  91. [ChineseDescription("1#联线自动装配机")]
  92. 联线自动装配机1=30004,
  93. [ChineseDescription("2#激光切管倒角一体机")]
  94. 激光切管倒角一体机2=30005,
  95. [ChineseDescription("2#S11轴切割倒角冲耳机一体机")]
  96. S11轴切割倒角冲耳机一体机2=30006,
  97. [ChineseDescription("2#联线自动装配机")]
  98. 联线自动装配机2=30007,
  99. [ChineseDescription("3#激光切管倒角一体机")]
  100. 激光切管倒角一体机3=30008,
  101. [ChineseDescription("3#S11轴切割倒角冲耳机一体机")]
  102. S11轴切割倒角冲耳机一体机3=30009,
  103. [ChineseDescription("3#联线自动装配机")]
  104. 联线自动装配机3=30010,
  105. [ChineseDescription("15轴加工一体机")]
  106. 十五轴加工一体机=30011,
  107. [ChineseDescription("科技一车间")]
  108. 科技一车间=11001,
  109. [ChineseDescription("科技二车间")]
  110. 科技二车间=11002,
  111. [ChineseDescription("科技三车间")]
  112. 科技三车间=11003,
  113. [ChineseDescription("科技五车间")]
  114. 科技五车间=11004,
  115. [ChineseDescription("工业二期")]
  116. 工业二期=11005,
  117. [ChineseDescription("工业三期(1楼)")]
  118. 工业三期1=11006,
  119. [ChineseDescription("工业三期(2楼)")]
  120. 工业三期2=11007,
  121. [ChineseDescription("工业四期")]
  122. 工业四期=11008,
  123. [ChineseDescription("工业办公楼")]
  124. 工业办公楼=11009,
  125. [ChineseDescription("创新办公楼")]
  126. 创新办公楼=11010,
  127. }
  128. public static GameManager Instance;
  129. public void Awake() {
  130. Instance =this;
  131. for(var i=0;i<wlist.Count;i++)
  132. {
  133. wlist[i].GetComponent<GameType>().init();
  134. }
  135. }
  136. public List<GameObject> wlist;
  137. public List<GameObject> dlist;
  138. public List<GameObject> keji;
  139. public List<GameObject> gongye;
  140. void showkeji()
  141. {
  142. LoadModelAB.ModelDic["工业车间"].SetActive(false);
  143. LoadModelAB.ModelDic["科技车间"].SetActive(true);
  144. }
  145. void showgongye()
  146. {
  147. LoadModelAB.ModelDic["科技车间"].SetActive(false);
  148. LoadModelAB.ModelDic["工业车间"].SetActive(true);
  149. }
  150. void showyuanqu()
  151. {
  152. LoadModelAB.ModelDic["科技车间"].SetActive(true);
  153. LoadModelAB.ModelDic["工业车间"].SetActive(true);
  154. }
  155. public void showW(GameObjectType gameObjectType,TapName tapName)
  156. {
  157. if(LoadModelAB.ModelDic.ContainsKey("科技车间")&&LoadModelAB.ModelDic.ContainsKey("工业车间"))
  158. {
  159. switch(tapName)
  160. {
  161. case TapName.园区总览:
  162. Invoke("showyuanqu",1f);
  163. break;
  164. case TapName.德马工业车间:
  165. Invoke("showkeji",1f);
  166. break;
  167. case TapName.德马科技车间:
  168. Invoke("showgongye",1f);
  169. break;
  170. }
  171. }
  172. switch(gameObjectType)
  173. {
  174. case GameObjectType.园区:
  175. for(var i=0;i<wlist.Count;i++)
  176. {
  177. if(wlist[i].GetComponent<GameType>().tapName==tapName)
  178. {
  179. wlist[i].SetActive(true);
  180. }
  181. else
  182. {
  183. wlist[i].SetActive(false);
  184. }
  185. }
  186. for(var i=0;i<dlist.Count;i++)
  187. {
  188. dlist[i].SetActive(TapName.园区总览==tapName);
  189. }
  190. SimpleCameraController.smallclickct = 3;
  191. break;
  192. case GameObjectType.科技车间:
  193. keji[0].SetActive(tapName == TapName.科技车间总览);
  194. keji[1].SetActive(tapName != TapName.科技车间总览);
  195. for(var i=0;i<dlist.Count;i++)
  196. {
  197. dlist[i].SetActive(false);
  198. }
  199. if(tapName != TapName.科技车间总览)
  200. {
  201. SimpleCameraController.smallclickct = 2;
  202. }else
  203. {
  204. SimpleCameraController.smallclickct = 3;
  205. }
  206. break;
  207. case GameObjectType.工业车间:
  208. gongye[0].SetActive(tapName == TapName.工业车间总览);
  209. gongye[1].SetActive(tapName != TapName.工业车间总览);
  210. for(var i=0;i<dlist.Count;i++)
  211. {
  212. dlist[i].SetActive(false);
  213. }
  214. if(tapName != TapName.工业车间总览)
  215. {
  216. SimpleCameraController.smallclickct = 2;
  217. }else
  218. {
  219. SimpleCameraController.smallclickct = 3;
  220. }
  221. break;
  222. case GameObjectType.电力:
  223. for(var i=0;i<dlist.Count;i++)
  224. {
  225. if(dlist[i].GetComponent<GameType>().tapName==tapName)
  226. {
  227. dlist[i].SetActive(true);
  228. }
  229. else
  230. {
  231. dlist[i].SetActive(false);
  232. }
  233. }
  234. SimpleCameraController.smallclickct = 3;
  235. break;
  236. }
  237. smp.initpos();
  238. }
  239. public Camera cam;
  240. GameObject hitGo;
  241. void Update()
  242. {
  243. Ray ray = cam.ScreenPointToRay(Input.mousePosition); // 在鼠标点击位置创建一条射线
  244. RaycastHit hit; // 用于存储碰撞信息的结构体
  245. if (Physics.Raycast(ray, out hit)) // 进行射线检测
  246. {
  247. if (Input.GetMouseButtonDown(0)) // 当鼠标左键点击时
  248. {
  249. Debug.Log("点击物体: " + hit.transform.gameObject.name); // 输出碰撞的物体名称
  250. }
  251. else
  252. {
  253. if(hitGo)
  254. {
  255. if(hitGo.name!=hit.transform.gameObject.name)
  256. {
  257. hitGo = hit.transform.gameObject;
  258. Debug.Log("exit物体: " + hitGo.name); // 输出碰撞的物体名称
  259. Debug.Log("enter物体: " +hitGo.name); // 输出碰撞的物体名称
  260. }
  261. }
  262. else
  263. {
  264. hitGo = hit.transform.gameObject;
  265. Debug.Log("enter物体: " + hitGo.name); // 输出碰撞的物体名称
  266. }
  267. }
  268. }
  269. else
  270. {
  271. if(hitGo)
  272. {
  273. Debug.Log("exit物体: " + hitGo.name); // 输出碰撞的物体名称
  274. hitGo=null;
  275. }
  276. }
  277. }
  278. public string getID(TapName tapName)
  279. {
  280. for (int i = 0;i<GameManager.Instance.config.TaskList.Count;i++)
  281. {
  282. if(tapName == GameManager.Instance.config.TaskList[i].type)
  283. {
  284. return GameManager.Instance.config.TaskList[i].ID;
  285. }
  286. }
  287. return "";
  288. }
  289. }