JinRuRenwu.cs 9.1 KB

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