NewUserGuiderManager.cs 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using UnityEngine.SceneManagement;
  7. using JC.Unity.UI;
  8. public class NewUserGuiderManager : MonoBehaviour
  9. {
  10. [SerializeField] GameObject prefab_NewUserGuider;
  11. public static NewUserGuiderManager ins;
  12. void Awake()
  13. {
  14. if (ins) {
  15. Destroy(gameObject);
  16. return;
  17. }
  18. ins = this;
  19. DontDestroyOnLoad(gameObject);
  20. }
  21. void OnDestroy()
  22. {
  23. if (ins == this) ins = null;
  24. if (onSceneLoaded_added) SceneManager.sceneLoaded -= onSceneLoaded;
  25. }
  26. void Start()
  27. {
  28. SceneManager.sceneLoaded += onSceneLoaded; onSceneLoaded_added = true;
  29. }
  30. bool onSceneLoaded_added = false;
  31. void onSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //初始话的场景不会触发
  32. if (scene.name == "Game" && GameMgr.gameType == 1) {
  33. switch (curConfigKey) {
  34. case "开始-限时游戏":
  35. OnClickedDestroyed(curConfigKey);
  36. break;
  37. case "限时游戏-选择距离":
  38. ExecuteCurConfig();
  39. break;
  40. }
  41. }
  42. }
  43. public void OnSkip()
  44. {
  45. curConfigKey = null;
  46. LoginMgr.myUserInfo.SaveGuideFinish(0);
  47. }
  48. public void OnEnd()
  49. {
  50. curConfigKey = null;
  51. LoginMgr.myUserInfo.SaveGuideFinish(0);
  52. }
  53. public void ReviewNewUserGuide()
  54. {
  55. int viewCount = PersistenHandler.ins.menuBackCtr.views.Count;
  56. for (int i = 0; i < viewCount; i++) {
  57. PersistenHandler.ins.menuBackCtr.OnOnceBack();
  58. }
  59. foreach (var item in FindObjectsOfType<NewUserGuider>()) Destroy(item);
  60. curConfigKey = "模块开机";
  61. ExecuteCurConfig();
  62. LoginMgr.myUserInfo.SaveGuideFinish(0);
  63. }
  64. void InitConfigs()
  65. {
  66. if (configsInited) return;
  67. configsInited = true;
  68. NewUserGuiderConfig config = new NewUserGuiderConfig();
  69. config.key = "模块开机";
  70. config.hitPosType = 1;
  71. config.hitPos = new Vector2(-138.9f, -56.1f);
  72. config.pointerRotZ = 120;
  73. config.pointerPosType = 1;
  74. config.pointerPos = new Vector2(-205, 4);
  75. config.frameTipPivot = "lc";
  76. config.frameTipPosType = 1;
  77. config.frameTipPos = new Vector2(0, 0);
  78. config.onStart = (g) => {
  79. RectTransform iconModule = g.transform.Find("IconModule") as RectTransform;
  80. iconModule.anchoredPosition = new Vector2(-146, -39);
  81. iconModule.gameObject.SetActive(true);
  82. g.SetIconPointerHitOpacity(0.2f);
  83. };
  84. configs.Add(config.key, config);
  85. config = new NewUserGuiderConfig();
  86. config.key = "连接设备";
  87. config.frameTipPivot = "lb";
  88. config.onPrepare = (g) => {
  89. RectTransform btn = GameObject.Find("HomeView/RenderBow/BtnConnectBLE").GetComponent<RectTransform>();
  90. g.hollowOutMask.SetTarget(btn);
  91. // g.hollowOutMask.isTargetRectCanThrough = false;
  92. g.SetIconPointerHitOpacity(0.5f);
  93. g.config.hitPos = btn.position;
  94. g.config.pointerPos = btn.position + RectTransformUtils.CanvasV3ToScreenV3(Vector3.up * 80f, btn);
  95. g.config.frameTipPos = btn.position + RectTransformUtils.CanvasV3ToScreenV3(Vector3.up * 150f, btn);
  96. g.hollowOutMask.autoUpdate = true;
  97. };
  98. config.onStart = (g) => {
  99. g.GetMaskClickedEvent().RemoveAllListeners();
  100. g.GetMaskClickedEvent().AddListener(() => {
  101. if (BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess) {
  102. g.OnClick_ToNext();
  103. }
  104. });
  105. Func<bool> action_DoConnectInterceptor = () => {
  106. bool isConnected = BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
  107. if (isConnected) {
  108. g.OnClick_ToNext();
  109. }
  110. return isConnected;
  111. };
  112. BluetoothAim.ins.action_DoConnectInterceptor += action_DoConnectInterceptor;
  113. g.action_OnDestroy += () => BluetoothAim.ins.action_DoConnectInterceptor -= action_DoConnectInterceptor;
  114. };
  115. configs.Add(config.key, config);
  116. config = new NewUserGuiderConfig();
  117. config.key = "弓箭详情";
  118. config.frameTipPivot = "lt";
  119. config.onPrepare = (g) => {
  120. RectTransform btn = GameObject.Find("HomeView/RenderBow/BtnShowDetail").GetComponent<RectTransform>();
  121. g.hollowOutMask.SetTarget(btn);
  122. g.hollowOutMask.isTargetRectCanThrough = false;
  123. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  124. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.7f));
  125. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.5f));
  126. };
  127. config.onStart = (g) => {
  128. g.GetMaskClickedEvent().RemoveAllListeners();
  129. g.GetNewUserGuiderButton().onClick += () => {
  130. HomeView.ins.OnClick_ShowDeviceView();
  131. g.clickedWillPlayAudioBtn = false;
  132. g.OnClick_ToNext();
  133. };
  134. };
  135. configs.Add(config.key, config);
  136. config = new NewUserGuiderConfig();
  137. config.key = "设备-陀螺仪校准";
  138. config.frameTipPivot = "rt";
  139. config.onPrepare = (g) => {
  140. if (!DeviceView1.ins) {
  141. g.customPreparePass = false;
  142. return;
  143. }
  144. g.customPreparePass = true;
  145. RectTransform btn = DeviceView1.ins.transform.Find("ItemInfo/BowOptions/GyrCalibrate") as RectTransform;
  146. g.hollowOutMask.SetTarget(btn);
  147. // g.hollowOutMask.isTargetRectCanThrough = false;
  148. g.SetIconPointerHitOpacity(0.8f);
  149. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  150. g.config.pointerRotZ = 180;
  151. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f));
  152. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, 0))
  153. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  154. };
  155. config.onStart = (g) => {
  156. g.GetMaskClickedEvent().RemoveAllListeners();
  157. Action onclickTarget = () => {
  158. g.clickedWillPlayAudioBtn = false;
  159. g.OnClick_ToNext();
  160. };
  161. DeviceView1.ins.action_OnClickGyr += onclickTarget;
  162. g.action_OnDestroy += () => DeviceView1.ins.action_OnClickGyr -= onclickTarget;
  163. };
  164. configs.Add(config.key, config);
  165. config = new NewUserGuiderConfig();
  166. config.key = "陀螺仪校准-开始";
  167. config.frameTipPivot = "rt";
  168. config.frameTipText = "";
  169. config.delayExecute = false;
  170. config.onPrepare = (g) => {
  171. g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent<Canvas>().sortingOrder + 1);
  172. RectTransform btn = DeviceCalibrateView.ins.transform.Find("Gyr/Button") as RectTransform;
  173. g.hollowOutMask.SetTarget(btn);
  174. g.SetIconPointerHitOpacity(0.8f);
  175. g.SetMaskOpacity(0.33f);
  176. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  177. g.config.pointerRotZ = 180;
  178. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f));
  179. g.frameTip.gameObject.SetActive(false);
  180. };
  181. config.onStart = (g) => {
  182. g.GetMaskClickedEvent().RemoveAllListeners();
  183. g.action_Update += () => {
  184. bool doing = DeviceCalibrateView.ins.gyrCalibrating;
  185. g.iconPointer.gameObject.SetActive(!doing);
  186. g.iconPointerHit.gameObject.SetActive(!doing);
  187. };
  188. Func<bool> interceptor = () => {
  189. return DeviceCalibrateView.ins.gyrCalibrating;
  190. };
  191. Action operateFinished = () => {
  192. g.hollowOutMask.isTargetRectCanThrough = false;
  193. g.OnClick_ToNext();
  194. };
  195. DeviceCalibrateView.ins.action_OnClickGyrCalibrateInterceptor += interceptor;
  196. DeviceCalibrateView.ins.action_GyrCalibarateOperateAndFinish += operateFinished;
  197. g.action_OnDestroy += () => {
  198. DeviceCalibrateView.ins.action_OnClickGyrCalibrateInterceptor -= interceptor;
  199. DeviceCalibrateView.ins.action_GyrCalibarateOperateAndFinish -= operateFinished;
  200. };
  201. };
  202. configs.Add(config.key, config);
  203. config = new NewUserGuiderConfig();
  204. config.key = "陀螺仪校准-完成";
  205. config.frameTipPivot = "rt";
  206. config.frameTipText = "";
  207. config.onPrepare = (g) => {
  208. g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent<Canvas>().sortingOrder + 1);
  209. RectTransform btn = DeviceCalibrateView.ins.transform.Find("BtnFinish") as RectTransform;
  210. g.hollowOutMask.SetTarget(btn);
  211. g.SetIconPointerHitOpacity(0.8f);
  212. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  213. g.config.pointerRotZ = 120;
  214. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.2f, 1.2f));
  215. g.frameTip.gameObject.SetActive(false);
  216. };
  217. config.onStart = (g) => {
  218. g.GetMaskClickedEvent().RemoveAllListeners();
  219. Action operateFinished = () => {
  220. g.clickedWillPlayAudioBtn = false;
  221. g.OnClick_ToNext();
  222. };
  223. DeviceCalibrateView.ins.action_OnDestroy += operateFinished;
  224. };
  225. configs.Add(config.key, config);
  226. config = new NewUserGuiderConfig();
  227. config.key = "设备-地磁计校准";
  228. config.frameTipPivot = "rt";
  229. config.onPrepare = (g) => {
  230. if (!DeviceView1.ins) {
  231. g.customPreparePass = false;
  232. return;
  233. }
  234. g.customPreparePass = true;
  235. RectTransform btn = DeviceView1.ins.transform.Find("ItemInfo/BowOptions/MagCalibrate") as RectTransform;
  236. g.hollowOutMask.SetTarget(btn);
  237. // g.hollowOutMask.isTargetRectCanThrough = false;
  238. g.SetIconPointerHitOpacity(0.8f);
  239. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  240. g.config.pointerRotZ = 180;
  241. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f));
  242. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, 0))
  243. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 45f, g.iconPointer);
  244. };
  245. config.onStart = (g) => {
  246. g.GetMaskClickedEvent().RemoveAllListeners();
  247. Action onclickTarget = () => {
  248. g.clickedWillPlayAudioBtn = false;
  249. g.OnClick_ToNext();
  250. };
  251. DeviceView1.ins.action_OnClickMag += onclickTarget;
  252. g.action_OnDestroy += () => DeviceView1.ins.action_OnClickMag -= onclickTarget;
  253. };
  254. configs.Add(config.key, config);
  255. config = new NewUserGuiderConfig();
  256. config.key = "地磁计校准-开始";
  257. config.frameTipPivot = "rt";
  258. config.frameTipText = "";
  259. config.delayExecute = false;
  260. config.onPrepare = (g) => {
  261. g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent<Canvas>().sortingOrder + 1);
  262. RectTransform btn = DeviceCalibrateView.ins.transform.Find("Mag/MagReset") as RectTransform;
  263. g.hollowOutMask.SetTarget(btn);
  264. g.SetIconPointerHitOpacity(0.8f);
  265. g.SetMaskOpacity(0.33f);
  266. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  267. g.config.pointerRotZ = 180;
  268. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f));
  269. g.frameTip.gameObject.SetActive(false);
  270. };
  271. config.onStart = (g) => {
  272. g.GetMaskClickedEvent().RemoveAllListeners();
  273. g.action_Update += () => {
  274. bool doing = DeviceCalibrateView.ins.calibrateMagDoing;
  275. g.iconPointer.gameObject.SetActive(!doing);
  276. g.iconPointerHit.gameObject.SetActive(!doing);
  277. };
  278. Func<bool> interceptor = () => {
  279. return DeviceCalibrateView.ins.calibrateMagDoing;
  280. };
  281. Action operateFinished = () => {
  282. g.hollowOutMask.isTargetRectCanThrough = false;
  283. g.OnClick_ToNext();
  284. };
  285. DeviceCalibrateView.ins.action_OnClickMagCalibrateInterceptor += interceptor;
  286. DeviceCalibrateView.ins.action_MagCalibarateOperateAndFinish += operateFinished;
  287. g.action_OnDestroy += () => {
  288. DeviceCalibrateView.ins.action_OnClickMagCalibrateInterceptor -= interceptor;
  289. DeviceCalibrateView.ins.action_MagCalibarateOperateAndFinish -= operateFinished;
  290. };
  291. };
  292. configs.Add(config.key, config);
  293. config = new NewUserGuiderConfig();
  294. config.key = "地磁计校准-完成";
  295. config.frameTipPivot = "rt";
  296. config.frameTipText = "";
  297. config.onPrepare = (g) => {
  298. g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent<Canvas>().sortingOrder + 1);
  299. RectTransform btn = DeviceCalibrateView.ins.transform.Find("BtnFinish") as RectTransform;
  300. g.hollowOutMask.SetTarget(btn);
  301. g.SetIconPointerHitOpacity(0.8f);
  302. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  303. g.config.pointerRotZ = 120;
  304. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.2f, 1.2f));
  305. g.frameTip.gameObject.SetActive(false);
  306. };
  307. config.onStart = (g) => {
  308. g.GetMaskClickedEvent().RemoveAllListeners();
  309. Action operateFinished = () => {
  310. FindObjectOfType<DeviceView1>()?.OnClick_Back();
  311. g.clickedWillPlayAudioBtn = false;
  312. g.OnClick_ToNext();
  313. };
  314. DeviceCalibrateView.ins.action_OnDestroy += operateFinished;
  315. };
  316. configs.Add(config.key, config);
  317. config = new NewUserGuiderConfig();
  318. config.key = "查看设置";
  319. config.frameTipPivot = "rt";
  320. config.onPrepare = (g) => {
  321. RectTransform btn = GameObject.Find("TopBarView/TopBar/IconSetUp").GetComponent<RectTransform>();
  322. g.hollowOutMask.SetTarget(btn);
  323. g.hollowOutMask.isTargetRectCanThrough = false;
  324. g.SetIconPointerHitOpacity(0.6f);
  325. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  326. g.config.pointerRotZ = 180;
  327. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f);
  328. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  329. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  330. };
  331. configs.Add(config.key, config);
  332. config = new NewUserGuiderConfig();
  333. config.key = "查看商城";
  334. config.frameTipPivot = "rt";
  335. config.onPrepare = (g) => {
  336. RectTransform btn = GameObject.Find("TopBarView/TopBar/IconShop").GetComponent<RectTransform>();
  337. g.hollowOutMask.SetTarget(btn);
  338. g.hollowOutMask.isTargetRectCanThrough = false;
  339. g.SetIconPointerHitOpacity(0.6f);
  340. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  341. g.config.pointerRotZ = 180;
  342. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f);
  343. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  344. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  345. };
  346. configs.Add(config.key, config);
  347. config = new NewUserGuiderConfig();
  348. config.key = "切换好友/排行榜";
  349. config.frameTipPivot = "lt";
  350. config.onPrepare = (g) => {
  351. RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnTop").GetComponent<RectTransform>();
  352. g.hollowOutMask.SetTarget(btn);
  353. g.hollowOutMask.isTargetRectCanThrough = false;
  354. g.SetIconPointerHitOpacity(0.6f);
  355. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  356. g.config.pointerRotZ = -30;
  357. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0.9f));
  358. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0));
  359. };
  360. configs.Add(config.key, config);
  361. config = new NewUserGuiderConfig();
  362. config.key = "展开好友/排行榜";
  363. config.frameTipPivot = "lc";
  364. config.onPrepare = (g) => {
  365. RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnBottom").GetComponent<RectTransform>();
  366. g.hollowOutMask.SetTarget(btn);
  367. g.hollowOutMask.isTargetRectCanThrough = false;
  368. g.SetIconPointerHitOpacity(0.8f);
  369. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  370. g.config.pointerRotZ = -30;
  371. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1, 0.9f));
  372. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.5f, 0.5f));
  373. };
  374. configs.Add(config.key, config);
  375. config = new NewUserGuiderConfig();
  376. config.key = "联机游戏";
  377. config.frameTipPivot = "lt";
  378. config.onPrepare = (g) => {
  379. RectTransform btn = GameObject.Find("HomeView/RightPanel/Item (1)").GetComponent<RectTransform>();
  380. g.hollowOutMask.SetTarget(btn);
  381. g.hollowOutMask.isTargetRectCanThrough = false;
  382. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f));
  383. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f));
  384. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  385. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  386. };
  387. configs.Add(config.key, config);
  388. config = new NewUserGuiderConfig();
  389. config.key = "开始游戏";
  390. config.frameTipPivot = "lt";
  391. config.onPrepare = (g) => {
  392. RectTransform btn = GameObject.Find("HomeView/RightPanel/Item").GetComponent<RectTransform>();
  393. g.hollowOutMask.SetTarget(btn);
  394. // g.hollowOutMask.isTargetRectCanThrough = false;
  395. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f));
  396. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f));
  397. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  398. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  399. };
  400. config.onStart = (g) => {
  401. g.GetMaskClickedEvent().RemoveAllListeners();
  402. Action onClickTarget = () => {
  403. g.clickedWillPlayAudioBtn = false;
  404. g.OnClick_ToNext();
  405. };
  406. HomeView.ins.action_OnClickStartGame += onClickTarget;
  407. g.action_OnDestroy += () => HomeView.ins.action_OnClickStartGame -= onClickTarget;
  408. };
  409. configs.Add(config.key, config);
  410. config = new NewUserGuiderConfig();
  411. config.key = "开始-限时游戏";
  412. config.frameTipPivot = "lt";
  413. config.onPrepare = (g) => {
  414. if (!GameStartView.ins) {
  415. g.customPreparePass = false;
  416. return;
  417. }
  418. g.customPreparePass = true;
  419. RectTransform btn = GameStartView.ins.transform.Find("EntryList/Item (1)") as RectTransform;
  420. g.hollowOutMask.SetTarget(btn);
  421. // g.hollowOutMask.isTargetRectCanThrough = false;
  422. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  423. g.config.pointerRotZ = 180;
  424. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.2f, 0.3f));
  425. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.4f, 0.15f))
  426. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  427. };
  428. config.onStart = (g) => {
  429. g.GetMaskClickedEvent().RemoveAllListeners();
  430. };
  431. configs.Add(config.key, config);
  432. config = new NewUserGuiderConfig();
  433. config.key = "限时游戏-选择距离";
  434. config.frameTipPivot = "lc";
  435. config.onPrepare = (g) => {
  436. if (g.hollowOutMask.enabled) g.hollowOutMask.enabled = false;
  437. g.ActiveBtnSkip(false);
  438. if (!TimeLimitGameDistanceSelectView.ins) {
  439. g.customPreparePass = false;
  440. return;
  441. }
  442. //马上重构布局,否则引导初始化获取到的目标坐标不对
  443. LayoutRebuilder.ForceRebuildLayoutImmediate(TimeLimitGameDistanceSelectView.ins.transform.Find("Layout") as RectTransform);
  444. g.customPreparePass = true;
  445. g.hollowOutMask.enabled = true;
  446. g.ActiveBtnSkip(true);
  447. RectTransform btn = TimeLimitGameDistanceSelectView.ins.transform.Find("Layout/Item") as RectTransform;
  448. g.hollowOutMask.SetTarget(btn);
  449. // g.hollowOutMask.isTargetRectCanThrough = false;
  450. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  451. g.config.pointerRotZ = -30;
  452. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.85f, 0.5f));
  453. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.15f, 0.4f));
  454. };
  455. config.onStart = (g) => {
  456. g.GetMaskClickedEvent().RemoveAllListeners();
  457. Action onClickTarget = () => {
  458. g.clickedWillPlayAudioBtn = false;
  459. g.OnClick_ToNext();
  460. };
  461. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance += onClickTarget;
  462. g.action_OnDestroy += () => {
  463. if (!TimeLimitGameDistanceSelectView.ins) return;
  464. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance -= onClickTarget;
  465. };
  466. };
  467. configs.Add(config.key, config);
  468. config = new NewUserGuiderConfig();
  469. config.key = "视角归位-触发";
  470. config.frameTipPivot = "rb";
  471. config.frameTipPos = Vector2.zero;
  472. config.onPrepare = (g) => {
  473. RectTransform btn4 = GameAssistUI.ins.transform.Find("Button4") as RectTransform;
  474. g.hollowOutMask.SetTarget(btn4);
  475. RectTransform btn4_img = btn4.Find("Image") as RectTransform;
  476. g.config.hitPos = btn4_img.position;
  477. g.config.pointerRotZ = 120;
  478. g.config.pointerPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-60, 60), btn4);
  479. g.config.frameTipPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-120, 120), btn4);
  480. RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
  481. iconHumanShoot.pivot = Vector2.one * 0.5f;
  482. iconHumanShoot.anchoredPosition = new Vector2(-350, -85);
  483. iconHumanShoot.gameObject.SetActive(true);
  484. GameMode gameMode = GameMgr.ins.gameMode;
  485. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  486. gameMode.PauseTimeCounting(g);
  487. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  488. }
  489. };
  490. config.onStart = (g) => {
  491. g.GetMaskClickedEvent().RemoveAllListeners();
  492. Action onClickTarget = () => {
  493. g.gameObject.SetActive(false);
  494. AutoResetView.ins.action_OnDestroy += () => {
  495. if (!g) return;
  496. g.clickedWillPlayAudioBtn = false;
  497. g.OnClick_ToNext();
  498. };
  499. };
  500. GameAssistUI.ins.action_OnClickBtnIdentity += onClickTarget;
  501. g.action_OnDestroy += () => GameAssistUI.ins.action_OnClickBtnIdentity -= onClickTarget;
  502. };
  503. configs.Add(config.key, config);
  504. // config = new NewUserGuiderConfig();
  505. // config.key = "视角归位-瞄准";
  506. // config.frameTipPivot = "lc";
  507. // config.onPrepare = (g) => {
  508. // float rectSideLen = RectTransformUtils.ScreenV3ToCanvasV3(Vector3.right * Screen.height * 100 / 720f, g.GetComponent<RectTransform>()).x;
  509. // Vector2 rectSize = new Vector2(rectSideLen, rectSideLen);
  510. // RectTransform iconRect = g.transform.Find("IconRect") as RectTransform;
  511. // iconRect.sizeDelta = rectSize;
  512. // iconRect.gameObject.SetActive(true);
  513. // g.hollowOutMask.isTargetRectCanThrough = false;
  514. // g.hollowOutMask.SetTarget(iconRect);
  515. // g.config.hitPosType = 1;
  516. // g.config.hitPos = Vector2.zero;
  517. // g.config.pointerPosType = 1;
  518. // g.config.pointerRotZ = 120;
  519. // g.config.pointerPos = new Vector2(-rectSideLen / 2 * 1.2f, rectSideLen / 2 * 1.1f);
  520. // RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
  521. // iconHumanShoot.anchoredPosition = g.config.pointerPos;
  522. // iconHumanShoot.gameObject.SetActive(true);
  523. // g.config.frameTipPosType = 1;
  524. // g.config.frameTipPos = new Vector2(rectSideLen / 2 * 1.3f, 0);
  525. // GameMode gameMode = GameMgr.ins.gameMode;
  526. // if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  527. // gameMode.PauseTimeCounting(g);
  528. // g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  529. // }
  530. // };
  531. // configs.Add(config.key, config);
  532. config = new NewUserGuiderConfig();
  533. config.key = "准心高亮";
  534. config.hitActive = false;
  535. config.pointerActive = false;
  536. config.frameTipText = "";
  537. config.onStart = (g) => {
  538. g.GetMaskClickedEvent().RemoveAllListeners();
  539. GameMode gameMode = GameMgr.ins.gameMode;
  540. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  541. gameMode.PauseTimeCounting(g);
  542. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  543. }
  544. RectTransform iconRect = g.transform.Find("IconRect") as RectTransform;
  545. iconRect.gameObject.SetActive(true);
  546. g.hollowOutMask.isTargetRectCanThrough = false;
  547. g.hollowOutMask.SetTarget(iconRect);
  548. Transform centerPoint = TargetBody.ins.transform.Find("CenterPoint");
  549. Transform sidePoint = TargetBody.ins.transform.Find("SidePoint");
  550. RectTransform crossHairLight = g.transform.Find("CrossHair-Light") as RectTransform;
  551. crossHairLight.gameObject.SetActive(true);
  552. float countDown = 5;
  553. g.action_Update += () => {
  554. Vector3 centerPos = RectTransformUtility.WorldToScreenPoint(Camera.main, centerPoint.position);
  555. Vector3 sidePos = RectTransformUtility.WorldToScreenPoint(Camera.main, sidePoint.position);
  556. float sizeLen = Mathf.Abs(centerPos.x - sidePos.x) * 2;
  557. iconRect.position = centerPos;
  558. iconRect.sizeDelta = JC.Unity.UI.RectTransformUtils.ScreenV3ToCanvasV3(Vector3.one * sizeLen, iconRect);
  559. g.hollowOutMask.RefreshViewImmediate();
  560. countDown -= Time.deltaTime;
  561. if (countDown <= 0) {
  562. g.clickedWillPlayAudioBtn = false;
  563. g.OnClick_ToNext();
  564. }
  565. };
  566. Action a_updateCrossHair = () => {
  567. crossHairLight.position = CrossHair.ins.transform.position;
  568. };
  569. CrossHair.ins.action_UpdatePostionWhenFixedCamera += a_updateCrossHair;
  570. g.action_OnDestroy += () => {
  571. if (CrossHair.ins) CrossHair.ins.action_UpdatePostionWhenFixedCamera -= a_updateCrossHair;
  572. };
  573. };
  574. configs.Add(config.key, config);
  575. config = new NewUserGuiderConfig();
  576. config.key = "教程结束";
  577. config.hitActive = false;
  578. config.pointerActive = false;
  579. config.frameTipPivot = "ct";
  580. config.frameTipPosType = 1;
  581. config.frameTipPos = Vector2.zero;
  582. config.onStart = (g) => {
  583. g.GetMaskClickedEvent().AddListener(() => {
  584. OnEnd();
  585. });
  586. GameMode gameMode = GameMgr.ins.gameMode;
  587. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  588. gameMode.PauseTimeCounting(g);
  589. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  590. }
  591. };
  592. configs.Add(config.key, config);
  593. }
  594. #if UNITY_EDITOR
  595. bool warn_test = false;
  596. void Update() {
  597. if (!warn_test) {
  598. warn_test = true;
  599. Debug.LogWarning("F3-重置设备校准引导,规则引导");
  600. Debug.LogWarning("F4-重置新手引导记录");
  601. Debug.LogWarning("F5-新手引导强行下一步");
  602. }
  603. if (Input.GetKeyDown(KeyCode.F3)) {
  604. Debug.Log("重置设备校准引导,规则引导");
  605. AimHandler.ins.ResetMag();
  606. UserSettings.ins.deviceCalibrateGuideFinish = false;
  607. UserSettings.ins.gameRuleGuideFinish = new HashSet<int>();
  608. }
  609. if (Input.GetKeyDown(KeyCode.F4)) {
  610. Debug.Log("重置新手引导记录");
  611. LoginMgr.myUserInfo.SaveGuideFinish(0);
  612. }
  613. if (Input.GetKeyDown(KeyCode.F5)) {
  614. Debug.Log("新手引导强行下一步");
  615. FindObjectOfType<NewUserGuider>()?.OnClick_ToNext();
  616. }
  617. }
  618. #endif
  619. private Dictionary<string, NewUserGuiderConfig> configs = new Dictionary<string, NewUserGuiderConfig>();
  620. private bool configsInited = false;
  621. [SerializeField] public string curConfigKey = "模块开机";
  622. private List<string> configKeyList = new List<string>(new string[]{
  623. "模块开机",
  624. "连接设备",
  625. "弓箭详情",
  626. "设备-陀螺仪校准",
  627. "陀螺仪校准-开始",
  628. "陀螺仪校准-完成",
  629. "设备-地磁计校准",
  630. "地磁计校准-开始",
  631. "地磁计校准-完成",
  632. "查看设置",
  633. "查看商城",
  634. "切换好友/排行榜",
  635. "展开好友/排行榜",
  636. "联机游戏",
  637. "开始游戏",
  638. "开始-限时游戏",
  639. "限时游戏-选择距离",
  640. "视角归位-触发",
  641. // "视角归位-瞄准",
  642. "准心高亮",
  643. "教程结束",
  644. });
  645. [ContextMenu("执行当前配置")]
  646. void ExecuteCurConfig() {
  647. InitConfigs();
  648. NewUserGuiderConfig config = configs[curConfigKey];
  649. NewUserGuider guider = Instantiate(prefab_NewUserGuider).GetComponent<NewUserGuider>();
  650. guider.config = config;
  651. }
  652. public void OnClickedDestroyed(string configKey) {
  653. int nextIndex = configKeyList.IndexOf(configKey) + 1;
  654. if (nextIndex >= configKeyList.Count) return;
  655. curConfigKey = configKeyList[nextIndex];
  656. ExecuteCurConfig();
  657. }
  658. }
  659. public class NewUserGuiderConfig
  660. {
  661. public string key;
  662. //0:position,1:anchoredPosition
  663. public int hitPosType = 0;
  664. public Vector2 hitPos;
  665. public bool hitActive = true;
  666. //icon pointer rotation z
  667. public float pointerRotZ;
  668. public int pointerPosType = 0;
  669. public Vector2 pointerPos;
  670. public bool pointerActive = true;
  671. //frameTip-Pivot l:left,r:right,t:top,b:bottom,ct:center
  672. public string frameTipPivot = "lt";
  673. public int frameTipPosType = 0;
  674. public Vector2 frameTipPos;
  675. //frameTip text
  676. public string frameTipText = null;
  677. public string frameTipTextKey = null;
  678. public Action<NewUserGuider> onPrepare;
  679. public Action<NewUserGuider> onStart;
  680. public bool delayExecute = true;
  681. }