JinRuRenwu.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. using LitJson;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using TMPro;
  5. using UnityEngine;
  6. using UnityEngine.UI;
  7. using XRTool.Util;
  8. using static XunJianDataManager;
  9. public class JinRuRenwu : WindowSingleton<JinRuRenwu>
  10. {
  11. RenWuItem rwitem;
  12. public GameObject WenJianLan;
  13. public TextMeshProUGUI info;
  14. public GameObject TaskGo;
  15. public GameObject VideoBT;
  16. public GameObject ModelBT;
  17. public GameObject ImageBT;
  18. public GameObject Image2BT;
  19. public GameObject TextBT;
  20. public GameObject AllBT;
  21. public GameObject Video;
  22. public GameObject Model;
  23. public GameObject Image;
  24. public GameObject Image2;
  25. public GameObject Text;
  26. public GameObject paizhaoGo;
  27. public TextMeshProUGUI indexText;
  28. public List<GameObject> updateList;
  29. public GameObject kong;
  30. public GameObject saotuTip;
  31. public GameObject StartGo;
  32. public GameObject paizhaoanniu;
  33. public int PaiZhaoIndex=0;
  34. public override void OnEnable()
  35. {
  36. base.OnEnable();
  37. }
  38. public void isPaiZhao(bool isPaizhao)
  39. {
  40. if(isPaizhao)
  41. {
  42. changIndex(0);
  43. }
  44. else
  45. {
  46. changIndex(1);
  47. }
  48. }
  49. public void changIndex(int i)
  50. {
  51. PaiZhaoIndex = i;
  52. if(PaiZhaoIndex==0)
  53. {
  54. if (ChangeCameraSaoMiao.Instance)
  55. ChangeCameraSaoMiao.Instance.showpaizhao();
  56. }else
  57. {
  58. if (ChangeCameraSaoMiao.Instance)
  59. ChangeCameraSaoMiao.Instance.showluxiang();
  60. }
  61. }
  62. public void initStart()
  63. {
  64. saotuTip.SetActive(true);
  65. StartGo.SetActive(false);
  66. saotuTip.GetComponent<SaoTuManager>().showSaoTu();
  67. }
  68. public void GotoStart()
  69. {
  70. XunJianDataManager.Instance.chooseXunJian.nowIndex = -1;
  71. switch (XunJianDataManager.Instance.chooseXunJian.renwuModelType)
  72. {
  73. case RenWuModelType.SaoTu:
  74. ChangeCameraSaoMiao.Instance.showsaomiao(XunJianDataManager.Instance.chooseXunJian.itemList[0]);
  75. break;
  76. case RenWuModelType.DianYun:
  77. break;
  78. case RenWuModelType.DingWeiBan:
  79. break;
  80. }
  81. // TimerMgr.Instance.CreateTimer(()=> { showInit(); },5f);
  82. }
  83. public void show()
  84. {
  85. Debug.Log("showshowshowshowshowshow");
  86. saotuTip.SetActive(false);
  87. StartGo.SetActive(true);
  88. //updateListRef();
  89. TimerMgr.Instance.CreateTimer(() => {
  90. kong.SetActive(!kong.activeSelf);
  91. }, 0.01f, 6);
  92. gotoNextItem();
  93. // if (XunJianDataManager.Instance.chooseXunJian != null)
  94. // UpdateData();
  95. }
  96. public override void UpdateData()
  97. {
  98. base.UpdateData();
  99. ChangeCameraSaoMiao.Instance.close();
  100. VideoBT.SetActive(false);
  101. ModelBT.SetActive(false);
  102. ImageBT.SetActive(false);
  103. Image2BT.SetActive(false);
  104. TextBT.SetActive(false);
  105. rwitem = XunJianDataManager.Instance.chooseXunJian.itemList[XunJianDataManager.Instance.chooseXunJian.nowIndex];
  106. if(XunJianDataManager.Instance.chooseXunJian.renwuModelType== RenWuModelType.DianYun)
  107. {
  108. LineManager.Instance.setRoad(rwitem.roadList);
  109. }
  110. indexText.text = (rwitem.index+1).ToString();
  111. info.text = rwitem.info;
  112. if (rwitem.typeList.Count > 0)
  113. {
  114. int img = 0;
  115. for (int i = 0; i < rwitem.typeList.Count; i++)
  116. {
  117. switch (rwitem.typeList[i].type)
  118. {
  119. case RenWuType.Image:
  120. if(img==0)
  121. {
  122. ImageBT.SetActive(true);
  123. Image.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  124. }
  125. else
  126. {
  127. Image2BT.SetActive(false);
  128. Image2.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  129. }
  130. img++;
  131. break;
  132. case RenWuType.Model:
  133. ModelBT.SetActive(true);
  134. Model.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  135. break;
  136. case RenWuType.Text:
  137. TextBT.SetActive(true);
  138. Text.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  139. break;
  140. case RenWuType.Video:
  141. VideoBT.SetActive(true);
  142. Video.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  143. break;
  144. }
  145. }
  146. if(rwitem.typeList.Count < 2)
  147. {
  148. AllBT.SetActive(false);
  149. }else
  150. {
  151. AllBT.SetActive(true);
  152. }
  153. WenJianLan.SetActive(true);
  154. }
  155. else
  156. {
  157. WenJianLan.SetActive(false);
  158. }
  159. }
  160. private void OnDisable()
  161. {
  162. if(ChangeCameraSaoMiao.Instance)
  163. {
  164. ChangeCameraSaoMiao.Instance.close();
  165. ChangeCameraSaoMiao.Instance.checkLuXiang();
  166. }
  167. LineManager.Instance.stop();
  168. WindowGenSui.Instance.jd = 30;
  169. //RoadManager.Instance.gameObject.SetActive(false);
  170. }
  171. public List<GameObject> getResGo()
  172. {
  173. List<GameObject> list = new List<GameObject>();
  174. int img = 0;
  175. for (int i = 0; i < rwitem.typeList.Count; i++)
  176. {
  177. switch (rwitem.typeList[i].type)
  178. {
  179. case RenWuType.Image:
  180. if (img == 0)
  181. {
  182. list.Add(Image);
  183. }
  184. else
  185. {
  186. list.Add(Image2);
  187. }
  188. img++;
  189. break;
  190. case RenWuType.Model:
  191. list.Add(Model);
  192. break;
  193. case RenWuType.Text:
  194. list.Add(Text);
  195. break;
  196. case RenWuType.Video:
  197. list.Add(Video);
  198. break;
  199. }
  200. }
  201. return list;
  202. }
  203. public void gotoRTC()
  204. {
  205. WindowsManager.Instance.show(WindowConfig.windowType.Tip2, false, "¾´ÇëÆÚ´ý!");
  206. /*
  207. List<string> backTip = new List<string>();
  208. backTip.Add("test1");
  209. backTip.Add("test2");
  210. backTip.Add("test3");
  211. WindowsManager.Instance.show(WindowConfig.windowType.Tip, false, WindowsManager.Instance.getTip1Data("Ìáʾ", "¾´ÇëÆÚ´ý!", true, true, "icon", Color.gray, backTip).ToJson());*/
  212. }
  213. public void showAll()
  214. {
  215. List<GameObject> list = getResGo();
  216. bool isOpen=false;
  217. for (int i = 0; i < list.Count; i++)
  218. {
  219. if(!list[i].activeSelf)
  220. {
  221. isOpen = true;
  222. }
  223. }
  224. for (int i = 0; i < list.Count; i++)
  225. {
  226. list[i].SetActive(isOpen);
  227. }
  228. checkJd();
  229. }
  230. void checkJd()
  231. {
  232. List<GameObject> list = getResGo();
  233. int ct=0;
  234. for (int i = 0; i < list.Count; i++)
  235. {
  236. if (list[i].activeSelf)
  237. {
  238. ct++;
  239. }
  240. }
  241. if (JinRuRenwu.Instance.paizhaoGo.activeSelf)
  242. {
  243. ct += 1;
  244. }
  245. if (ct >3)
  246. WindowGenSui.Instance.jd = 60;
  247. else if (ct > 0)
  248. WindowGenSui.Instance.jd = 45;
  249. else
  250. {
  251. WindowGenSui.Instance.jd = 30;
  252. }
  253. }
  254. public void closeAll()
  255. {
  256. List<GameObject> list = getResGo();
  257. for (int i = 0; i < list.Count; i++)
  258. {
  259. list[i].SetActive(false);
  260. }
  261. }
  262. public void showText()
  263. {
  264. Text.SetActive(!Text.activeSelf);
  265. if (!JinRuRenwu.Instance.paizhaoGo.activeSelf)
  266. {
  267. Text.transform.SetAsFirstSibling();
  268. }
  269. else
  270. {
  271. Video.transform.SetSiblingIndex(1);
  272. }
  273. checkJd();
  274. }
  275. public void showImage()
  276. {
  277. Image.SetActive(!Image.activeSelf);
  278. if (!JinRuRenwu.Instance.paizhaoGo.activeSelf)
  279. {
  280. Image.transform.SetAsFirstSibling();
  281. }
  282. else
  283. {
  284. Video.transform.SetSiblingIndex(1);
  285. }
  286. checkJd();
  287. }
  288. public void showImage2()
  289. {
  290. Image2.SetActive(!Image2.activeSelf);
  291. if (!JinRuRenwu.Instance.paizhaoGo.activeSelf)
  292. {
  293. Image2.transform.SetAsFirstSibling();
  294. }
  295. else
  296. {
  297. Video.transform.SetSiblingIndex(1);
  298. }
  299. checkJd();
  300. }
  301. public void showModel()
  302. {
  303. Model.SetActive(!Model.activeSelf);
  304. if (!JinRuRenwu.Instance.paizhaoGo.activeSelf)
  305. {
  306. Model.transform.SetAsFirstSibling();
  307. }
  308. else
  309. {
  310. Video.transform.SetSiblingIndex(1);
  311. }
  312. checkJd();
  313. }
  314. public void showVideo()
  315. {
  316. Video.SetActive(!Video.activeSelf);
  317. if (!JinRuRenwu.Instance.paizhaoGo.activeSelf)
  318. {
  319. Video.transform.SetAsFirstSibling();
  320. }
  321. else
  322. {
  323. Video.transform.SetSiblingIndex(1);
  324. }
  325. checkJd();
  326. }
  327. public Toggle paizhaoToggle;
  328. public void GotoPaiZhao()
  329. {
  330. if(!JinRuRenwu.Instance.paizhaoGo.activeSelf)
  331. {
  332. PaiZhaoIndex = 0;
  333. ChangeCameraSaoMiao.Instance.showpaizhao();
  334. }else
  335. {
  336. paizhaoToggle.isOn = true;
  337. ChangeCameraSaoMiao.Instance.close();
  338. }
  339. checkJd();
  340. // PaiZhaoGo.SetActive(!PaiZhaoGo.activeSelf);
  341. }
  342. public void paizhaoAndLuxiang()
  343. {
  344. if (PaiZhaoIndex == 0)
  345. {
  346. ChangeCameraSaoMiao.Instance.paizhaoclick();
  347. }
  348. else
  349. {
  350. ChangeCameraSaoMiao.Instance.luxiangClick();
  351. }
  352. }
  353. public void GotoTask()
  354. {
  355. TaskGo.SetActive(!TaskGo.activeSelf);
  356. }
  357. public void updateListRef()
  358. {
  359. for (int i = updateList.Count-1; i >=0; i--)
  360. {
  361. if ((updateList[i].GetComponent<ContentSizeFitter>()))
  362. {
  363. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutVertical();
  364. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutHorizontal();
  365. }
  366. if (updateList[i].GetComponent<HorizontalLayoutGroup>())
  367. {
  368. updateList[i].GetComponent<HorizontalLayoutGroup>().SetLayoutHorizontal();
  369. updateList[i].GetComponent<HorizontalLayoutGroup>().CalculateLayoutInputHorizontal();
  370. }
  371. if ((updateList[i].GetComponent<VerticalLayoutGroup>()))
  372. {
  373. updateList[i].GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  374. updateList[i].GetComponent<VerticalLayoutGroup>().CalculateLayoutInputVertical();
  375. }
  376. }
  377. }
  378. public void successItem()
  379. {
  380. rwitem.state = RenWuState.Success;
  381. }
  382. public void failItem()
  383. {
  384. rwitem.state = RenWuState.Fail;
  385. }
  386. public void gotoNextItem()
  387. {
  388. XunJianDataManager.Instance.gotoNext();
  389. }
  390. public void GotoLieBiao()
  391. {
  392. WindowsManager.Instance.show(WindowConfig.windowType.XunJianLB);
  393. }
  394. }