NewUserGuiderManager.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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 JCUnityLib;
  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 (!DeviceView.ins) {
  141. g.customPreparePass = false;
  142. return;
  143. }
  144. g.customPreparePass = true;
  145. RectTransform btn = DeviceView.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. DeviceView.ins.action_OnClickGyr += onclickTarget;
  162. g.action_OnDestroy += () => DeviceView.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 = "rb";
  229. config.onPrepare = (g) => {
  230. if (!DeviceView.ins) {
  231. g.customPreparePass = false;
  232. return;
  233. }
  234. g.customPreparePass = true;
  235. RectTransform btn = DeviceView.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 = 210;
  241. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, -1));
  242. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0))
  243. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 220f, g.iconPointer);
  244. g.FixFrameTipWidth(930);
  245. };
  246. config.onStart = (g) => {
  247. g.GetMaskClickedEvent().RemoveAllListeners();
  248. Action onclickTarget = () => {
  249. g.clickedWillPlayAudioBtn = false;
  250. g.OnClick_ToNext();
  251. };
  252. DeviceView.ins.action_OnClickMag += onclickTarget;
  253. g.action_OnDestroy += () => DeviceView.ins.action_OnClickMag -= onclickTarget;
  254. };
  255. configs.Add(config.key, config);
  256. config = new NewUserGuiderConfig();
  257. config.key = "地磁计校准-开始";
  258. config.frameTipPivot = "rt";
  259. config.frameTipText = "";
  260. config.delayExecute = false;
  261. config.onPrepare = (g) => {
  262. g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent<Canvas>().sortingOrder + 1);
  263. RectTransform btn = DeviceCalibrateView.ins.transform.Find("Mag/MagReset") as RectTransform;
  264. g.hollowOutMask.SetTarget(btn);
  265. g.SetIconPointerHitOpacity(0.8f);
  266. g.SetMaskOpacity(0.33f);
  267. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  268. g.config.pointerRotZ = 180;
  269. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f));
  270. g.frameTip.gameObject.SetActive(false);
  271. };
  272. config.onStart = (g) => {
  273. g.GetMaskClickedEvent().RemoveAllListeners();
  274. g.action_Update += () => {
  275. bool doing = DeviceCalibrateView.ins.calibrateMagDoing;
  276. g.iconPointer.gameObject.SetActive(!doing);
  277. g.iconPointerHit.gameObject.SetActive(!doing);
  278. };
  279. Func<bool> interceptor = () => {
  280. return DeviceCalibrateView.ins.calibrateMagDoing;
  281. };
  282. Action operateFinished = () => {
  283. g.hollowOutMask.isTargetRectCanThrough = false;
  284. g.OnClick_ToNext();
  285. };
  286. DeviceCalibrateView.ins.action_OnClickMagCalibrateInterceptor += interceptor;
  287. DeviceCalibrateView.ins.action_MagCalibarateOperateAndFinish += operateFinished;
  288. g.action_OnDestroy += () => {
  289. DeviceCalibrateView.ins.action_OnClickMagCalibrateInterceptor -= interceptor;
  290. DeviceCalibrateView.ins.action_MagCalibarateOperateAndFinish -= operateFinished;
  291. };
  292. };
  293. configs.Add(config.key, config);
  294. config = new NewUserGuiderConfig();
  295. config.key = "地磁计校准-完成";
  296. config.frameTipPivot = "rb";
  297. // config.frameTipText = "";
  298. config.onPrepare = (g) => {
  299. g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent<Canvas>().sortingOrder + 1);
  300. RectTransform btn = DeviceCalibrateView.ins.transform.Find("BtnFinish") as RectTransform;
  301. g.hollowOutMask.SetTarget(btn);
  302. g.SetIconPointerHitOpacity(0.8f);
  303. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  304. g.config.pointerRotZ = 120;
  305. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.2f, 1.2f));
  306. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0, 1))
  307. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 100 + Vector3.up * 50f, g.iconPointer);
  308. g.FixFrameTipWidth(700);
  309. g.SetMaskOpacity(0.7f);
  310. };
  311. config.onStart = (g) => {
  312. g.GetMaskClickedEvent().RemoveAllListeners();
  313. Action operateFinished = () => {
  314. FindObjectOfType<DeviceView>()?.OnClick_Back();
  315. g.clickedWillPlayAudioBtn = false;
  316. g.OnClick_ToNext();
  317. };
  318. DeviceCalibrateView.ins.action_OnDestroy += operateFinished;
  319. };
  320. configs.Add(config.key, config);
  321. config = new NewUserGuiderConfig();
  322. config.key = "查看设置";
  323. config.frameTipPivot = "rt";
  324. config.onPrepare = (g) => {
  325. RectTransform btn = GameObject.Find("TopBarView/TopBar/IconSetUp").GetComponent<RectTransform>();
  326. g.hollowOutMask.SetTarget(btn);
  327. g.hollowOutMask.isTargetRectCanThrough = false;
  328. g.SetIconPointerHitOpacity(0.6f);
  329. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  330. g.config.pointerRotZ = 180;
  331. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f);
  332. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  333. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  334. };
  335. configs.Add(config.key, config);
  336. config = new NewUserGuiderConfig();
  337. config.key = "查看商城";
  338. config.frameTipPivot = "rt";
  339. config.onPrepare = (g) => {
  340. RectTransform btn = GameObject.Find("TopBarView/TopBar/IconShop").GetComponent<RectTransform>();
  341. g.hollowOutMask.SetTarget(btn);
  342. g.hollowOutMask.isTargetRectCanThrough = false;
  343. g.SetIconPointerHitOpacity(0.6f);
  344. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  345. g.config.pointerRotZ = 180;
  346. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f);
  347. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  348. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  349. };
  350. configs.Add(config.key, config);
  351. config = new NewUserGuiderConfig();
  352. config.key = "切换好友/排行榜";
  353. config.frameTipPivot = "lt";
  354. config.onPrepare = (g) => {
  355. RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnTop").GetComponent<RectTransform>();
  356. g.hollowOutMask.SetTarget(btn);
  357. g.hollowOutMask.isTargetRectCanThrough = false;
  358. g.SetIconPointerHitOpacity(0.6f);
  359. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  360. g.config.pointerRotZ = -30;
  361. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0.9f));
  362. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0));
  363. };
  364. configs.Add(config.key, config);
  365. config = new NewUserGuiderConfig();
  366. config.key = "展开好友/排行榜";
  367. config.frameTipPivot = "lc";
  368. config.onPrepare = (g) => {
  369. RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnBottom").GetComponent<RectTransform>();
  370. g.hollowOutMask.SetTarget(btn);
  371. g.hollowOutMask.isTargetRectCanThrough = false;
  372. g.SetIconPointerHitOpacity(0.8f);
  373. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  374. g.config.pointerRotZ = -30;
  375. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1, 0.9f));
  376. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.5f, 0.5f));
  377. };
  378. configs.Add(config.key, config);
  379. config = new NewUserGuiderConfig();
  380. config.key = "联机游戏";
  381. config.frameTipPivot = "lt";
  382. config.onPrepare = (g) => {
  383. RectTransform btn = GameObject.Find("HomeView/RightPanel/Item (1)").GetComponent<RectTransform>();
  384. g.hollowOutMask.SetTarget(btn);
  385. g.hollowOutMask.isTargetRectCanThrough = false;
  386. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f));
  387. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f));
  388. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  389. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  390. };
  391. configs.Add(config.key, config);
  392. config = new NewUserGuiderConfig();
  393. config.key = "开始游戏";
  394. config.frameTipPivot = "lt";
  395. config.onPrepare = (g) => {
  396. RectTransform btn = GameObject.Find("HomeView/RightPanel/Item").GetComponent<RectTransform>();
  397. g.hollowOutMask.SetTarget(btn);
  398. // g.hollowOutMask.isTargetRectCanThrough = false;
  399. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f));
  400. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f));
  401. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  402. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  403. };
  404. config.onStart = (g) => {
  405. g.GetMaskClickedEvent().RemoveAllListeners();
  406. Action onClickTarget = () => {
  407. g.clickedWillPlayAudioBtn = false;
  408. g.OnClick_ToNext();
  409. };
  410. HomeView.ins.action_OnClickStartGame += onClickTarget;
  411. g.action_OnDestroy += () => HomeView.ins.action_OnClickStartGame -= onClickTarget;
  412. };
  413. configs.Add(config.key, config);
  414. config = new NewUserGuiderConfig();
  415. config.key = "开始-限时游戏";
  416. config.frameTipPivot = "lt";
  417. config.onPrepare = (g) => {
  418. if (!GameStartView.ins) {
  419. g.customPreparePass = false;
  420. return;
  421. }
  422. g.customPreparePass = true;
  423. RectTransform btn = GameStartView.ins.transform.Find("EntryList/Item (1)") as RectTransform;
  424. g.hollowOutMask.SetTarget(btn);
  425. // g.hollowOutMask.isTargetRectCanThrough = false;
  426. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  427. g.config.pointerRotZ = 180;
  428. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.2f, 0.3f));
  429. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.4f, 0.15f))
  430. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  431. };
  432. config.onStart = (g) => {
  433. g.GetMaskClickedEvent().RemoveAllListeners();
  434. };
  435. configs.Add(config.key, config);
  436. config = new NewUserGuiderConfig();
  437. config.key = "限时游戏-选择距离";
  438. config.frameTipPivot = "lc";
  439. config.onPrepare = (g) => {
  440. if (g.hollowOutMask.enabled) g.hollowOutMask.enabled = false;
  441. g.ActiveBtnSkip(false);
  442. if (!TimeLimitGameDistanceSelectView.ins) {
  443. g.customPreparePass = false;
  444. return;
  445. }
  446. //马上重构布局,否则引导初始化获取到的目标坐标不对
  447. LayoutRebuilder.ForceRebuildLayoutImmediate(TimeLimitGameDistanceSelectView.ins.transform.Find("Layout") as RectTransform);
  448. g.customPreparePass = true;
  449. g.hollowOutMask.enabled = true;
  450. g.ActiveBtnSkip(true);
  451. RectTransform btn = TimeLimitGameDistanceSelectView.ins.transform.Find("Layout/Item") as RectTransform;
  452. g.hollowOutMask.SetTarget(btn);
  453. // g.hollowOutMask.isTargetRectCanThrough = false;
  454. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  455. g.config.pointerRotZ = -30;
  456. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.85f, 0.5f));
  457. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.15f, 0.4f));
  458. };
  459. config.onStart = (g) => {
  460. g.GetMaskClickedEvent().RemoveAllListeners();
  461. Action onClickTarget = () => {
  462. g.clickedWillPlayAudioBtn = false;
  463. g.OnClick_ToNext();
  464. };
  465. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance += onClickTarget;
  466. g.action_OnDestroy += () => {
  467. if (!TimeLimitGameDistanceSelectView.ins) return;
  468. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance -= onClickTarget;
  469. };
  470. };
  471. configs.Add(config.key, config);
  472. config = new NewUserGuiderConfig();
  473. config.key = "视角归位-触发";
  474. config.frameTipPivot = "rb";
  475. config.frameTipPos = Vector2.zero;
  476. config.onPrepare = (g) => {
  477. RectTransform btn4 = GameAssistUI.ins.transform.Find("Button4") as RectTransform;
  478. g.hollowOutMask.SetTarget(btn4);
  479. RectTransform btn4_img = btn4.Find("Image") as RectTransform;
  480. g.config.hitPos = btn4_img.position;
  481. g.config.pointerRotZ = 120;
  482. g.config.pointerPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-60, 60), btn4);
  483. g.config.frameTipPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-120, 120), btn4);
  484. RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
  485. iconHumanShoot.pivot = Vector2.one * 0.5f;
  486. iconHumanShoot.anchoredPosition = new Vector2(-350, -85);
  487. iconHumanShoot.gameObject.SetActive(true);
  488. GameMode gameMode = GameMgr.ins.gameMode;
  489. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  490. gameMode.PauseTimeCounting(g);
  491. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  492. }
  493. };
  494. config.onStart = (g) => {
  495. g.GetMaskClickedEvent().RemoveAllListeners();
  496. Action onClickTarget = () => {
  497. g.gameObject.SetActive(false);
  498. AutoResetView.ins.action_OnDestroy += () => {
  499. if (!g) return;
  500. g.clickedWillPlayAudioBtn = false;
  501. g.OnClick_ToNext();
  502. };
  503. };
  504. GameAssistUI.ins.action_OnClickBtnIdentity += onClickTarget;
  505. g.action_OnDestroy += () => GameAssistUI.ins.action_OnClickBtnIdentity -= onClickTarget;
  506. };
  507. configs.Add(config.key, config);
  508. // config = new NewUserGuiderConfig();
  509. // config.key = "视角归位-瞄准";
  510. // config.frameTipPivot = "lc";
  511. // config.onPrepare = (g) => {
  512. // float rectSideLen = RectTransformUtils.ScreenV3ToCanvasV3(Vector3.right * Screen.height * 100 / 720f, g.GetComponent<RectTransform>()).x;
  513. // Vector2 rectSize = new Vector2(rectSideLen, rectSideLen);
  514. // RectTransform iconRect = g.transform.Find("IconRect") as RectTransform;
  515. // iconRect.sizeDelta = rectSize;
  516. // iconRect.gameObject.SetActive(true);
  517. // g.hollowOutMask.isTargetRectCanThrough = false;
  518. // g.hollowOutMask.SetTarget(iconRect);
  519. // g.config.hitPosType = 1;
  520. // g.config.hitPos = Vector2.zero;
  521. // g.config.pointerPosType = 1;
  522. // g.config.pointerRotZ = 120;
  523. // g.config.pointerPos = new Vector2(-rectSideLen / 2 * 1.2f, rectSideLen / 2 * 1.1f);
  524. // RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
  525. // iconHumanShoot.anchoredPosition = g.config.pointerPos;
  526. // iconHumanShoot.gameObject.SetActive(true);
  527. // g.config.frameTipPosType = 1;
  528. // g.config.frameTipPos = new Vector2(rectSideLen / 2 * 1.3f, 0);
  529. // GameMode gameMode = GameMgr.ins.gameMode;
  530. // if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  531. // gameMode.PauseTimeCounting(g);
  532. // g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  533. // }
  534. // };
  535. // configs.Add(config.key, config);
  536. config = new NewUserGuiderConfig();
  537. config.key = "准心高亮";
  538. config.hitActive = false;
  539. config.pointerActive = false;
  540. config.frameTipText = "";
  541. config.onStart = (g) => {
  542. g.GetMaskClickedEvent().RemoveAllListeners();
  543. GameMode gameMode = GameMgr.ins.gameMode;
  544. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  545. gameMode.PauseTimeCounting(g);
  546. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  547. }
  548. RectTransform iconRect = g.transform.Find("IconRect") as RectTransform;
  549. iconRect.gameObject.SetActive(true);
  550. g.hollowOutMask.isTargetRectCanThrough = false;
  551. g.hollowOutMask.SetTarget(iconRect);
  552. Transform centerPoint = TargetBody.ins.transform.Find("CenterPoint");
  553. Transform sidePoint = TargetBody.ins.transform.Find("SidePoint");
  554. RectTransform crossHairLight = g.transform.Find("CrossHair-Light") as RectTransform;
  555. crossHairLight.gameObject.SetActive(true);
  556. float countDown = 5;
  557. g.action_Update += () => {
  558. Vector3 centerPos = RectTransformUtility.WorldToScreenPoint(Camera.main, centerPoint.position);
  559. Vector3 sidePos = RectTransformUtility.WorldToScreenPoint(Camera.main, sidePoint.position);
  560. float sizeLen = Mathf.Abs(centerPos.x - sidePos.x) * 2;
  561. iconRect.position = centerPos;
  562. iconRect.sizeDelta = JCUnityLib.RectTransformUtils.ScreenV3ToCanvasV3(Vector3.one * sizeLen, iconRect);
  563. g.hollowOutMask.RefreshViewImmediate();
  564. countDown -= Time.deltaTime;
  565. if (countDown <= 0) {
  566. g.clickedWillPlayAudioBtn = false;
  567. g.OnClick_ToNext();
  568. }
  569. };
  570. Action a_updateCrossHair = () => {
  571. crossHairLight.position = CrossHair.ins.transform.position;
  572. };
  573. CrossHair.ins.action_UpdatePostionWhenFixedCamera += a_updateCrossHair;
  574. g.action_OnDestroy += () => {
  575. if (CrossHair.ins) CrossHair.ins.action_UpdatePostionWhenFixedCamera -= a_updateCrossHair;
  576. };
  577. };
  578. configs.Add(config.key, config);
  579. config = new NewUserGuiderConfig();
  580. config.key = "教程结束";
  581. config.hitActive = false;
  582. config.pointerActive = false;
  583. config.frameTipPivot = "ct";
  584. config.frameTipPosType = 1;
  585. config.frameTipPos = Vector2.zero;
  586. config.onStart = (g) => {
  587. g.GetMaskClickedEvent().AddListener(() => {
  588. OnEnd();
  589. });
  590. GameMode gameMode = GameMgr.ins.gameMode;
  591. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  592. gameMode.PauseTimeCounting(g);
  593. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  594. }
  595. };
  596. configs.Add(config.key, config);
  597. }
  598. #if UNITY_EDITOR
  599. bool warn_test = false;
  600. void Update() {
  601. if (!warn_test) {
  602. warn_test = true;
  603. Debug.LogWarning("F3-重置设备校准引导,规则引导");
  604. Debug.LogWarning("F4-重置新手引导记录");
  605. Debug.LogWarning("F5-新手引导强行下一步");
  606. }
  607. if (Input.GetKeyDown(KeyCode.F3)) {
  608. Debug.Log("重置设备校准引导,规则引导");
  609. AimHandler.ins.ResetMag();
  610. UserSettings.ins.deviceCalibrateGuideFinish = false;
  611. UserSettings.ins.gameRuleGuideFinish = new HashSet<int>();
  612. }
  613. if (Input.GetKeyDown(KeyCode.F4)) {
  614. Debug.Log("重置新手引导记录");
  615. LoginMgr.myUserInfo.SaveGuideFinish(0);
  616. }
  617. if (Input.GetKeyDown(KeyCode.F5)) {
  618. Debug.Log("新手引导强行下一步");
  619. FindObjectOfType<NewUserGuider>()?.OnClick_ToNext();
  620. }
  621. }
  622. #endif
  623. private Dictionary<string, NewUserGuiderConfig> configs = new Dictionary<string, NewUserGuiderConfig>();
  624. private bool configsInited = false;
  625. [SerializeField] public string curConfigKey = "模块开机";
  626. private List<string> configKeyList = new List<string>(new string[]{
  627. "模块开机",
  628. "连接设备",
  629. "弓箭详情",
  630. "设备-陀螺仪校准",
  631. "陀螺仪校准-开始",
  632. "陀螺仪校准-完成",
  633. "设备-地磁计校准",
  634. "地磁计校准-开始",
  635. "地磁计校准-完成",
  636. "查看设置",
  637. "查看商城",
  638. "切换好友/排行榜",
  639. "展开好友/排行榜",
  640. "联机游戏",
  641. "开始游戏",
  642. "开始-限时游戏",
  643. "限时游戏-选择距离",
  644. "视角归位-触发",
  645. // "视角归位-瞄准",
  646. "准心高亮",
  647. "教程结束",
  648. });
  649. [ContextMenu("执行当前配置")]
  650. void ExecuteCurConfig() {
  651. InitConfigs();
  652. NewUserGuiderConfig config = configs[curConfigKey];
  653. NewUserGuider guider = Instantiate(prefab_NewUserGuider).GetComponent<NewUserGuider>();
  654. guider.config = config;
  655. }
  656. public void OnClickedDestroyed(string configKey) {
  657. int nextIndex = configKeyList.IndexOf(configKey) + 1;
  658. if (nextIndex >= configKeyList.Count) return;
  659. curConfigKey = configKeyList[nextIndex];
  660. ExecuteCurConfig();
  661. }
  662. }
  663. public class NewUserGuiderConfig
  664. {
  665. public string key;
  666. //0:position,1:anchoredPosition
  667. public int hitPosType = 0;
  668. public Vector2 hitPos;
  669. public bool hitActive = true;
  670. //icon pointer rotation z
  671. public float pointerRotZ;
  672. public int pointerPosType = 0;
  673. public Vector2 pointerPos;
  674. public bool pointerActive = true;
  675. //frameTip-Pivot l:left,r:right,t:top,b:bottom,ct:center
  676. public string frameTipPivot = "lt";
  677. public int frameTipPosType = 0;
  678. public Vector2 frameTipPos;
  679. //frameTip text
  680. public string frameTipText = null;
  681. public string frameTipTextKey = null;
  682. public Action<NewUserGuider> onPrepare;
  683. public Action<NewUserGuider> onStart;
  684. public bool delayExecute = true;
  685. }