JinRuRenwu.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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 PaiZhaoGo;
  16. public GameObject VideoBT;
  17. public GameObject ModelBT;
  18. public GameObject ImageBT;
  19. public GameObject Image2BT;
  20. public GameObject TextBT;
  21. public GameObject AllBT;
  22. public GameObject Video;
  23. public GameObject Model;
  24. public GameObject Image;
  25. public GameObject Image2;
  26. public GameObject Text;
  27. public TextMeshProUGUI indexText;
  28. public List<GameObject> updateList;
  29. public GameObject kong;
  30. public override void OnEnable()
  31. {
  32. base.OnEnable();
  33. //RoadManager.Instance.gameObject.SetActive(true);
  34. updateListRef();
  35. TimerMgr.Instance.CreateTimer(()=> {
  36. kong.SetActive(!kong.activeSelf);
  37. },0.01f,6);
  38. if(XunJianDataManager.Instance.chooseXunJian!=null)
  39. UpdateData();
  40. }
  41. public override void UpdateData()
  42. {
  43. base.UpdateData();
  44. VideoBT.SetActive(false);
  45. ModelBT.SetActive(false);
  46. ImageBT.SetActive(false);
  47. Image2BT.SetActive(false);
  48. TextBT.SetActive(false);
  49. rwitem = XunJianDataManager.Instance.chooseXunJian.itemList[XunJianDataManager.Instance.chooseXunJian.nowIndex];
  50. LineManager.Instance.setRoad(rwitem.roadList);
  51. indexText.text = (rwitem.index+1).ToString();
  52. info.text = rwitem.info;
  53. if (rwitem.typeList.Count > 0)
  54. {
  55. int img = 0;
  56. for (int i = 0; i < rwitem.typeList.Count; i++)
  57. {
  58. switch (rwitem.typeList[i].type)
  59. {
  60. case RenWuType.Image:
  61. if(img==0)
  62. {
  63. ImageBT.SetActive(true);
  64. Image.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  65. }
  66. else
  67. {
  68. Image2BT.SetActive(false);
  69. Image2.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  70. }
  71. img++;
  72. break;
  73. case RenWuType.Model:
  74. ModelBT.SetActive(true);
  75. Model.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  76. break;
  77. case RenWuType.Text:
  78. TextBT.SetActive(true);
  79. Text.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  80. break;
  81. case RenWuType.Video:
  82. VideoBT.SetActive(true);
  83. Video.GetComponent<RenWuTypeWindow>().updateData(rwitem.typeList[i]);
  84. break;
  85. }
  86. }
  87. if(rwitem.typeList.Count < 2)
  88. {
  89. AllBT.SetActive(false);
  90. }else
  91. {
  92. AllBT.SetActive(true);
  93. }
  94. WenJianLan.SetActive(true);
  95. }
  96. else
  97. {
  98. WenJianLan.SetActive(false);
  99. }
  100. }
  101. private void OnDisable()
  102. {
  103. LineManager.Instance.stop();
  104. WindowGenSui.Instance.jd = 30;
  105. //RoadManager.Instance.gameObject.SetActive(false);
  106. }
  107. public List<GameObject> getResGo()
  108. {
  109. List<GameObject> list = new List<GameObject>();
  110. int img = 0;
  111. for (int i = 0; i < rwitem.typeList.Count; i++)
  112. {
  113. switch (rwitem.typeList[i].type)
  114. {
  115. case RenWuType.Image:
  116. if (img == 0)
  117. {
  118. list.Add(Image);
  119. }
  120. else
  121. {
  122. list.Add(Image2);
  123. }
  124. img++;
  125. break;
  126. case RenWuType.Model:
  127. list.Add(Model);
  128. break;
  129. case RenWuType.Text:
  130. list.Add(Text);
  131. break;
  132. case RenWuType.Video:
  133. list.Add(Video);
  134. break;
  135. }
  136. }
  137. return list;
  138. }
  139. public void gotoRTC()
  140. {
  141. WindowsManager.Instance.show(WindowConfig.windowType.Tip2, false, "¾´ÇëÆÚ´ý!");
  142. /*
  143. List<string> backTip = new List<string>();
  144. backTip.Add("test1");
  145. backTip.Add("test2");
  146. backTip.Add("test3");
  147. WindowsManager.Instance.show(WindowConfig.windowType.Tip, false, WindowsManager.Instance.getTip1Data("Ìáʾ", "¾´ÇëÆÚ´ý!", true, true, "icon", Color.gray, backTip).ToJson());*/
  148. }
  149. public void showAll()
  150. {
  151. List<GameObject> list = getResGo();
  152. bool isOpen=false;
  153. for (int i = 0; i < list.Count; i++)
  154. {
  155. if(!list[i].activeSelf)
  156. {
  157. isOpen = true;
  158. }
  159. }
  160. for (int i = 0; i < list.Count; i++)
  161. {
  162. list[i].SetActive(isOpen);
  163. }
  164. checkJd();
  165. }
  166. void checkJd()
  167. {
  168. List<GameObject> list = getResGo();
  169. int ct=0;
  170. for (int i = 0; i < list.Count; i++)
  171. {
  172. if (list[i].activeSelf)
  173. {
  174. ct++;
  175. }
  176. }
  177. if (ct >3)
  178. WindowGenSui.Instance.jd = 60;
  179. else if (ct > 0)
  180. WindowGenSui.Instance.jd = 45;
  181. else
  182. {
  183. WindowGenSui.Instance.jd = 30;
  184. }
  185. }
  186. public void closeAll()
  187. {
  188. List<GameObject> list = getResGo();
  189. for (int i = 0; i < list.Count; i++)
  190. {
  191. list[i].SetActive(false);
  192. }
  193. }
  194. public void showText()
  195. {
  196. Text.SetActive(!Text.activeSelf);
  197. Text.transform.SetAsFirstSibling();
  198. checkJd();
  199. }
  200. public void showImage()
  201. {
  202. Image.SetActive(!Image.activeSelf);
  203. Image.transform.SetAsFirstSibling();
  204. checkJd();
  205. }
  206. public void showImage2()
  207. {
  208. Image2.SetActive(!Image2.activeSelf);
  209. Image2.transform.SetAsFirstSibling();
  210. checkJd();
  211. }
  212. public void showModel()
  213. {
  214. Model.SetActive(!Model.activeSelf);
  215. Model.transform.SetAsFirstSibling();
  216. checkJd();
  217. }
  218. public void showVideo()
  219. {
  220. Video.SetActive(!Video.activeSelf);
  221. Video.transform.SetAsFirstSibling();
  222. checkJd();
  223. }
  224. public void GotoPaiZhao()
  225. {
  226. PaiZhaoGo.SetActive(!PaiZhaoGo.activeSelf);
  227. }
  228. public void GotoTask()
  229. {
  230. TaskGo.SetActive(!TaskGo.activeSelf);
  231. }
  232. public void GotoLieBiao()
  233. {
  234. WindowsManager.Instance.show(WindowConfig.windowType.XunJianLB);
  235. }
  236. public void successItem()
  237. {
  238. rwitem.state = RenWuState.Success;
  239. gotoNextItem();
  240. }
  241. public void failItem()
  242. {
  243. rwitem.state = RenWuState.Fail;
  244. gotoNextItem();
  245. }
  246. public void gotoNextItem()
  247. {
  248. XunJianDataManager.Instance.gotoNext();
  249. }
  250. public void updateListRef()
  251. {
  252. for (int i = updateList.Count-1; i >=0; i--)
  253. {
  254. if ((updateList[i].GetComponent<ContentSizeFitter>()))
  255. {
  256. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutVertical();
  257. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutHorizontal();
  258. }
  259. if (updateList[i].GetComponent<HorizontalLayoutGroup>())
  260. {
  261. updateList[i].GetComponent<HorizontalLayoutGroup>().SetLayoutHorizontal();
  262. updateList[i].GetComponent<HorizontalLayoutGroup>().CalculateLayoutInputHorizontal();
  263. }
  264. if ((updateList[i].GetComponent<VerticalLayoutGroup>()))
  265. {
  266. updateList[i].GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  267. updateList[i].GetComponent<VerticalLayoutGroup>().CalculateLayoutInputVertical();
  268. }
  269. }
  270. }
  271. }