XunJianDataManager.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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. XunJianListData testData()
  17. {
  18. XunJianListData xj = new XunJianListData();
  19. xj.id = "saotu";
  20. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  21. xj.projectname = "(扫图版本)GHZ-巡检测试";
  22. xj.inarea = "杨浦区";
  23. xj.updateState = "新项目";
  24. xj.projectState = "测试巡检 ";
  25. xj.projectType = "未开始 ";
  26. xj.projectTime = "2023/11/23 10:53 ";
  27. xj.renwuModelType = RenWuModelType.SaoTu;
  28. xj.itemList = getRenwuData();
  29. return xj;
  30. }
  31. XunJianListData testData2()
  32. {
  33. XunJianListData xj = new XunJianListData();
  34. xj.id = "saotu";
  35. xj.url = Application.streamingAssetsPath + "/DianYun/85471-ghzoffice (2).bytes";
  36. xj.projectname = "(点云版本)GHZ-巡检测试";
  37. xj.inarea = "杨浦区";
  38. xj.updateState = "新项目";
  39. xj.projectState = "测试巡检 ";
  40. xj.projectType = "未开始 ";
  41. xj.projectTime = "2023/11/23 10:53 ";
  42. xj.renwuModelType = RenWuModelType.DianYun;
  43. xj.itemList = getRenwuData();
  44. return xj;
  45. }
  46. List<RenWuItem> getRenwuData()
  47. {
  48. List < RenWuItem > itemlist = new List<RenWuItem>();
  49. for (int j = 0; j < 7; j++)
  50. {
  51. RenWuItem rw = new RenWuItem();
  52. rw.imageUrl = Application.streamingAssetsPath + "/ARTargetImage/" + (j + 1) + ".png";
  53. //任务id
  54. rw.id = j.ToString();
  55. //任务索引
  56. rw.index = j;
  57. switch(j)
  58. {
  59. case 0:
  60. //任务路线 (空间定位时才有)
  61. rw.roadList = new List<Vector3>();
  62. rw.roadList.Add(new Vector3(-4.2f+0.5f, 0, 0.92f));
  63. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 2));
  64. rw.roadList.Add(new Vector3(-5 + 0.5f, 0, 2));
  65. rw.info = "请检查办公室大门------并拍照/录像记录";
  66. break;
  67. case 1:
  68. //任务路线 (空间定位时才有)
  69. rw.roadList = new List<Vector3>();
  70. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.92f));
  71. rw.info = "查看垃圾桶是否有垃圾------并拍照/录像记录";
  72. break;
  73. case 2:
  74. //任务路线 (空间定位时才有)
  75. rw.roadList = new List<Vector3>();
  76. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, -1.6f));
  77. rw.info = "检查空调是否正常------并拍照/录像记录";
  78. break;
  79. case 3:
  80. //任务路线 (空间定位时才有)
  81. rw.roadList = new List<Vector3>();
  82. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  83. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  84. rw.roadList.Add(new Vector3(-1.78f, 0, -1.6f));
  85. rw.info = "请打开窗户并处于通风状态------并拍照/录像记录";
  86. break;
  87. case 4:
  88. //任务路线 (空间定位时才有)
  89. rw.roadList = new List<Vector3>();
  90. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  91. rw.roadList.Add(new Vector3(-5.18f + 0.5f, 0, 0.52f));
  92. rw.info = "冰箱内是否有过期食品------并拍照/录像记录";
  93. break;
  94. case 5:
  95. //任务路线 (空间定位时才有)
  96. rw.roadList = new List<Vector3>();
  97. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  98. rw.info = "确保所有眼镜都在充电------并拍照/录像记录";
  99. break;
  100. case 6:
  101. //任务路线 (空间定位时才有)
  102. rw.roadList = new List<Vector3>();
  103. rw.roadList.Add(new Vector3(-4.2f + 0.5f, 0, 0.52f));
  104. rw.roadList.Add(new Vector3(-1.78f, 0, 0.52f));
  105. rw.roadList.Add(new Vector3(-1.78f, 0, -1f));
  106. rw.info = "请回到工位继续工作------并拍照/录像记录";
  107. break;
  108. }
  109. //任务介绍
  110. //拍照按钮
  111. int randomInt = UnityEngine.Random.Range(0, 10);
  112. rw.isPaiZhao = randomInt > 5 ? true : false;
  113. //RTC按钮
  114. int randomInt2 = UnityEngine.Random.Range(0, 10);
  115. rw.isYuanCheng = randomInt2 > 5 ? true : false;
  116. //单个任务素材
  117. rw.typeList = new List<RenWuTypeModel>();
  118. RenWuTypeModel rwtm = new RenWuTypeModel();
  119. rwtm.id = "1";
  120. rwtm.type = RenWuType.Image;
  121. rwtm.url = Application.streamingAssetsPath + "/Art/16:9.jpg";
  122. rw.typeList.Add(rwtm);
  123. RenWuTypeModel rwtm2 = new RenWuTypeModel();
  124. rwtm2.id = "2";
  125. rwtm2.type = RenWuType.Video;
  126. rwtm2.url = Application.streamingAssetsPath + "/Art/Video.mp4";
  127. rw.typeList.Add(rwtm2);
  128. RenWuTypeModel rwtm3 = new RenWuTypeModel();
  129. rwtm3.id = "3";
  130. rwtm3.type = RenWuType.Model;
  131. rwtm3.url = Application.streamingAssetsPath + "/Art/ExampleCar.fbx";
  132. rw.typeList.Add(rwtm3);
  133. RenWuTypeModel rwtm4 = new RenWuTypeModel();
  134. rwtm4.id = "4";
  135. rwtm4.type = RenWuType.Text;
  136. rwtm4.info = rw.info;
  137. rw.typeList.Add(rwtm4);
  138. itemlist.Add(rw);
  139. }
  140. return itemlist;
  141. }
  142. IEnumerator testBack(Action<List<XunJianListData>> callback)
  143. {
  144. xjDataList = new List<XunJianListData>();
  145. xjDataList.Add(testData());
  146. xjDataList.Add(testData2());
  147. yield return null;
  148. callback.Invoke(xjDataList);
  149. }
  150. public class XunJianListData
  151. {
  152. public int nowIndex = 0;
  153. public string id;
  154. public string projectname;
  155. public string inarea;
  156. public string updateState;
  157. public string projectState;
  158. public string projectType;
  159. public string projectTime;
  160. public List<RenWuItem> itemList;
  161. public RenWuModelType renwuModelType;
  162. public string url;
  163. }
  164. public void GotoXunJian(XunJianListData xjld)
  165. {
  166. chooseXunJian = xjld;
  167. WindowsManager.Instance.show(WindowConfig.windowType.XunJianStart);
  168. JinRuRenwu.Instance.initStart();
  169. }
  170. public void gotoNext()
  171. {
  172. if(chooseXunJian.itemList.Count-1 > chooseXunJian.nowIndex)
  173. {
  174. chooseXunJian.nowIndex++;
  175. if (JinRuRenwu.Instance != null)
  176. {
  177. JinRuRenwu.Instance.UpdateData();
  178. }
  179. if (RenWuListWindow.Instance != null)
  180. {
  181. RenWuListWindow.Instance.UpdateData();
  182. }
  183. if (CaoZuoLanManager.Instance)
  184. CaoZuoLanManager.Instance.nextInteractable(false);
  185. }
  186. else
  187. {
  188. List<string> backTip = new List<string>();
  189. JsonData data = new JsonData();
  190. data["type"] = "30001";
  191. backTip.Add("1");
  192. backTip.Add(data.ToJson());
  193. backTip.Add("3");
  194. WindowsManager.Instance.show(WindowConfig.windowType.Error, false, WindowsManager.Instance.getErrorData("提示", "已经是最后一步了!", Color.gray, "icon", backTip, false, "自动退出", 5,"","退出巡检","返回").ToJson());
  195. }
  196. }
  197. public void chooseItem(int i)
  198. {
  199. chooseXunJian.nowIndex = i;
  200. if (JinRuRenwu.Instance != null)
  201. {
  202. JinRuRenwu.Instance.UpdateData();
  203. }
  204. if (RenWuListWindow.Instance != null)
  205. {
  206. RenWuListWindow.Instance.UpdateData();
  207. }
  208. }
  209. public class RenWuItem
  210. {
  211. public string id;
  212. public int index;
  213. public bool isPaiZhao;
  214. public bool isYuanCheng;
  215. public string info;
  216. public List<RenWuTypeModel> typeList;
  217. public List<Vector3> roadList;
  218. public string imageUrl;
  219. public ImageFileSourceData imageData;
  220. public RenWuState state = RenWuState.None;
  221. }
  222. public class RenWuTypeModel
  223. {
  224. public RenWuType type;
  225. public string id;
  226. public string url;
  227. public string info;
  228. }
  229. public enum RenWuState
  230. {
  231. None = 100001, // 未处理
  232. Success = 100002, // 成功
  233. Fail = 100003, // 失败
  234. }
  235. public enum RenWuType
  236. {
  237. Text = 100001, // 文字
  238. Image = 100002, // 图片
  239. Video = 100003, // 视频
  240. Model = 100004, // 模型
  241. }
  242. public enum RenWuModelType
  243. {
  244. SaoTu = 100001, // 扫图
  245. DingWeiBan = 100002, // 定位板
  246. DianYun = 100003, // 点云
  247. }
  248. }