XunJianDataManager.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using XRTool.Util;
  6. public class XunJianDataManager : Singleton<XunJianDataManager>
  7. {
  8. public XunJianListData chooseXunJian;
  9. public List<XunJianListData> xjDataList = new List<XunJianListData>();
  10. public void GetXunJianList(Action<List<XunJianListData>> callback)
  11. {
  12. WindowsManager.Instance.StartCoroutine(testBack(callback));
  13. }
  14. IEnumerator testBack(Action<List<XunJianListData>> callback)
  15. {
  16. xjDataList = new List<XunJianListData>();
  17. for (int i = 0; i < 7; i++)
  18. {
  19. XunJianListData xj = new XunJianListData();
  20. xj.id = i.ToString();
  21. xj.projectname = "projectname " + i.ToString();
  22. xj.inarea = "inarea " + i.ToString();
  23. xj.updateState = "updateState " + i.ToString();
  24. xj.projectState = "projectState " + i.ToString();
  25. xj.projectType = "projectType " + i.ToString();
  26. xj.projectTime = "projectTime " + i.ToString();
  27. switch(i)
  28. {
  29. case 0:
  30. xj.renwuModelType = RenWuModelType.DianYun;
  31. break;
  32. case 1:
  33. xj.renwuModelType = RenWuModelType.DingWeiBan;
  34. break;
  35. default:
  36. xj.renwuModelType = RenWuModelType.SaoTu;
  37. break;
  38. }
  39. xj.itemList = new List<RenWuItem>();
  40. for (int j = 0; j < 7; j++)
  41. {
  42. RenWuItem rw = new RenWuItem();
  43. //任务路线 (空间定位时才有)
  44. rw.roadList = new List<Vector3>();
  45. Vector3 v3 = new Vector3(UnityEngine.Random.Range(-3.1f, 3.1f), 0, UnityEngine.Random.Range(-3.1f, 3.1f));
  46. rw.roadList.Add(v3);
  47. rw.roadList.Add(new Vector3(v3.x + UnityEngine.Random.Range(-2.1f, 2.1f), 0, v3.z + UnityEngine.Random.Range(-2.1f, 2.1f)));
  48. //任务id
  49. rw.id = j.ToString();
  50. //任务索引
  51. rw.index = j;
  52. //任务介绍
  53. rw.info = "info" + j;
  54. //拍照按钮
  55. int randomInt = UnityEngine.Random.Range(0, 10);
  56. rw.isPaiZhao = randomInt > 5 ? true : false;
  57. //RTC按钮
  58. int randomInt2 = UnityEngine.Random.Range(0, 10);
  59. rw.isYuanCheng = randomInt2 > 5 ? true : false;
  60. //单个任务素材
  61. rw.typeList = new List<RenWuTypeModel>();
  62. RenWuTypeModel rwtm = new RenWuTypeModel();
  63. rwtm.id = "1";
  64. rwtm.type = RenWuType.Image;
  65. rwtm.url = Application.streamingAssetsPath+ "/Art/16:9.jpg";
  66. rw.typeList.Add(rwtm);
  67. RenWuTypeModel rwtm2 = new RenWuTypeModel();
  68. rwtm2.id = "2";
  69. rwtm2.type = RenWuType.Video;
  70. rwtm2.url = Application.streamingAssetsPath + "/Art/Video.mp4";
  71. rw.typeList.Add(rwtm2);
  72. RenWuTypeModel rwtm3 = new RenWuTypeModel();
  73. rwtm3.id = "3";
  74. rwtm3.type = RenWuType.Model;
  75. rwtm3.url = Application.streamingAssetsPath + "/Art/ExampleCar.fbx";
  76. rw.typeList.Add(rwtm3);
  77. RenWuTypeModel rwtm4 = new RenWuTypeModel();
  78. rwtm4.id = "4";
  79. rwtm4.type = RenWuType.Text;
  80. rwtm4.info = "Text12344566788";
  81. rw.typeList.Add(rwtm4);
  82. xj.itemList.Add(rw);
  83. }
  84. xjDataList.Add(xj);
  85. }
  86. yield return null;
  87. callback.Invoke(xjDataList);
  88. }
  89. public class XunJianListData
  90. {
  91. public int nowIndex = 0;
  92. public string id;
  93. public string projectname;
  94. public string inarea;
  95. public string updateState;
  96. public string projectState;
  97. public string projectType;
  98. public string projectTime;
  99. public List<RenWuItem> itemList;
  100. public RenWuModelType renwuModelType;
  101. }
  102. public void GotoXunJian(XunJianListData xjld)
  103. {
  104. chooseXunJian = xjld;
  105. WindowsManager.Instance.show(WindowConfig.windowType.XunJianStart);
  106. JinRuRenwu.Instance.initStart();
  107. }
  108. public void gotoNext()
  109. {
  110. if(chooseXunJian.itemList.Count-1 > chooseXunJian.nowIndex)
  111. {
  112. chooseXunJian.nowIndex++;
  113. if (JinRuRenwu.Instance != null)
  114. {
  115. JinRuRenwu.Instance.UpdateData();
  116. }
  117. if (RenWuListWindow.Instance != null)
  118. {
  119. RenWuListWindow.Instance.UpdateData();
  120. }
  121. }else
  122. {
  123. List<string> backTip = new List<string>();
  124. backTip.Add("1");
  125. backTip.Add("2");
  126. backTip.Add("3");
  127. WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "已经是最后一步了!", Color.gray, "icon", backTip, false, "敬请期待", 5).ToJson());
  128. }
  129. }
  130. public void chooseItem(int i)
  131. {
  132. chooseXunJian.nowIndex = i;
  133. if (JinRuRenwu.Instance != null)
  134. {
  135. JinRuRenwu.Instance.UpdateData();
  136. }
  137. if (RenWuListWindow.Instance != null)
  138. {
  139. RenWuListWindow.Instance.UpdateData();
  140. }
  141. }
  142. public class RenWuItem
  143. {
  144. public string id;
  145. public int index;
  146. public bool isPaiZhao;
  147. public bool isYuanCheng;
  148. public string info;
  149. public List<RenWuTypeModel> typeList;
  150. public List<Vector3> roadList;
  151. public RenWuState state = RenWuState.None;
  152. }
  153. public class RenWuTypeModel
  154. {
  155. public RenWuType type;
  156. public string id;
  157. public string url;
  158. public string info;
  159. }
  160. public enum RenWuState
  161. {
  162. None = 100001, // 未处理
  163. Success = 100002, // 成功
  164. Fail = 100003, // 失败
  165. }
  166. public enum RenWuType
  167. {
  168. Text = 100001, // 文字
  169. Image = 100002, // 图片
  170. Video = 100003, // 视频
  171. Model = 100004, // 模型
  172. }
  173. public enum RenWuModelType
  174. {
  175. SaoTu = 100001, // 扫图
  176. DingWeiBan = 100002, // 定位板
  177. DianYun = 100003, // 点云
  178. }
  179. }