JinRuRenwu.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. //RoadManager.Instance.gameObject.SetActive(false);
  105. }
  106. public List<GameObject> getResGo()
  107. {
  108. List<GameObject> list = new List<GameObject>();
  109. int img = 0;
  110. for (int i = 0; i < rwitem.typeList.Count; i++)
  111. {
  112. switch (rwitem.typeList[i].type)
  113. {
  114. case RenWuType.Image:
  115. if (img == 0)
  116. {
  117. list.Add(Image);
  118. }
  119. else
  120. {
  121. list.Add(Image2);
  122. }
  123. img++;
  124. break;
  125. case RenWuType.Model:
  126. list.Add(Model);
  127. break;
  128. case RenWuType.Text:
  129. list.Add(Text);
  130. break;
  131. case RenWuType.Video:
  132. list.Add(Video);
  133. break;
  134. }
  135. }
  136. return list;
  137. }
  138. public void gotoRTC()
  139. {
  140. WindowsManager.Instance.show(WindowConfig.windowType.Tip2, false, "¾´ÇëÆÚ´ý!");
  141. /*
  142. List<string> backTip = new List<string>();
  143. backTip.Add("test1");
  144. backTip.Add("test2");
  145. backTip.Add("test3");
  146. WindowsManager.Instance.show(WindowConfig.windowType.Tip, false, WindowsManager.Instance.getTip1Data("Ìáʾ", "¾´ÇëÆÚ´ý!", true, true, "icon", Color.gray, backTip).ToJson());*/
  147. }
  148. public void showAll()
  149. {
  150. List<GameObject> list = getResGo();
  151. bool isOpen=false;
  152. for (int i = 0; i < list.Count; i++)
  153. {
  154. if(!list[i].activeSelf)
  155. {
  156. isOpen = true;
  157. }
  158. }
  159. for (int i = 0; i < list.Count; i++)
  160. {
  161. list[i].SetActive(isOpen);
  162. }
  163. }
  164. public void closeAll()
  165. {
  166. List<GameObject> list = getResGo();
  167. for (int i = 0; i < list.Count; i++)
  168. {
  169. list[i].SetActive(false);
  170. }
  171. }
  172. public void showText()
  173. {
  174. Text.SetActive(!Text.activeSelf);
  175. Text.transform.SetAsFirstSibling();
  176. }
  177. public void showImage()
  178. {
  179. Image.SetActive(!Image.activeSelf);
  180. Image.transform.SetAsFirstSibling();
  181. }
  182. public void showImage2()
  183. {
  184. Image2.SetActive(!Image2.activeSelf);
  185. Image2.transform.SetAsFirstSibling();
  186. }
  187. public void showModel()
  188. {
  189. Model.SetActive(!Model.activeSelf);
  190. Model.transform.SetAsFirstSibling();
  191. }
  192. public void showVideo()
  193. {
  194. Video.SetActive(!Video.activeSelf);
  195. Video.transform.SetAsFirstSibling();
  196. }
  197. public void GotoPaiZhao()
  198. {
  199. PaiZhaoGo.SetActive(!PaiZhaoGo.activeSelf);
  200. }
  201. public void GotoTask()
  202. {
  203. TaskGo.SetActive(!TaskGo.activeSelf);
  204. }
  205. public void GotoLieBiao()
  206. {
  207. WindowsManager.Instance.show(WindowConfig.windowType.XunJianLB);
  208. }
  209. public void successItem()
  210. {
  211. rwitem.state = RenWuState.Success;
  212. gotoNextItem();
  213. }
  214. public void failItem()
  215. {
  216. rwitem.state = RenWuState.Fail;
  217. gotoNextItem();
  218. }
  219. public void gotoNextItem()
  220. {
  221. XunJianDataManager.Instance.gotoNext();
  222. }
  223. public void updateListRef()
  224. {
  225. for (int i = updateList.Count-1; i >=0; i--)
  226. {
  227. if ((updateList[i].GetComponent<ContentSizeFitter>()))
  228. {
  229. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutVertical();
  230. updateList[i].GetComponent<ContentSizeFitter>().SetLayoutHorizontal();
  231. }
  232. if (updateList[i].GetComponent<HorizontalLayoutGroup>())
  233. {
  234. updateList[i].GetComponent<HorizontalLayoutGroup>().SetLayoutHorizontal();
  235. updateList[i].GetComponent<HorizontalLayoutGroup>().CalculateLayoutInputHorizontal();
  236. }
  237. if ((updateList[i].GetComponent<VerticalLayoutGroup>()))
  238. {
  239. updateList[i].GetComponent<VerticalLayoutGroup>().SetLayoutVertical();
  240. updateList[i].GetComponent<VerticalLayoutGroup>().CalculateLayoutInputVertical();
  241. }
  242. }
  243. }
  244. }