XunJianDataManager.cs 6.7 KB

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