NewUserGuiderManager.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575
  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. if (!IsUserGuideFinished()) {
  30. ExecuteCurConfig();
  31. SaveUserGuideFinished(true);
  32. }
  33. }
  34. bool onSceneLoaded_added = false;
  35. void onSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //初始话的场景不会触发
  36. if (scene.name == "Game" && GameMgr.gameType == 1) {
  37. switch (curConfigKey) {
  38. case "开始-限时游戏":
  39. OnClickedDestroyed(curConfigKey);
  40. break;
  41. case "限时游戏-选择距离":
  42. ExecuteCurConfig();
  43. break;
  44. }
  45. }
  46. }
  47. public void OnSkip()
  48. {
  49. curConfigKey = null;
  50. SaveUserGuideFinished(true);
  51. }
  52. public void OnEnd()
  53. {
  54. curConfigKey = null;
  55. SaveUserGuideFinished(true);
  56. }
  57. public void ReviewNewUserGuide()
  58. {
  59. int viewCount = PersistenHandler.ins.menuBackCtr.views.Count;
  60. for (int i = 0; i < viewCount; i++) {
  61. PersistenHandler.ins.menuBackCtr.OnOnceBack();
  62. }
  63. curConfigKey = "模块开机";
  64. ExecuteCurConfig();
  65. }
  66. void SaveUserGuideFinished(bool finished) {
  67. PlayerPrefs.SetInt("NewUserGuiderFinished", finished ? 1 : 0);
  68. }
  69. bool IsUserGuideFinished() {
  70. return PlayerPrefs.GetInt("NewUserGuiderFinished", 0) == 1 ? true : false;
  71. }
  72. void InitConfigs()
  73. {
  74. if (configsInited) return;
  75. configsInited = true;
  76. NewUserGuiderConfig config = new NewUserGuiderConfig();
  77. config.key = "模块开机";
  78. config.hitPosType = 1;
  79. config.hitPos = new Vector2(-138.9f, -56.1f);
  80. config.pointerRotZ = 120;
  81. config.pointerPosType = 1;
  82. config.pointerPos = new Vector2(-205, 4);
  83. config.frameTipPivot = "lc";
  84. config.frameTipPosType = 1;
  85. config.frameTipPos = new Vector2(0, 0);
  86. config.onStart = (g) => {
  87. RectTransform iconModule = g.transform.Find("IconModule") as RectTransform;
  88. iconModule.anchoredPosition = new Vector2(-146, -39);
  89. iconModule.gameObject.SetActive(true);
  90. g.SetIconPointerHitOpacity(0.2f);
  91. };
  92. configs.Add(config.key, config);
  93. config = new NewUserGuiderConfig();
  94. config.key = "连接设备";
  95. config.frameTipPivot = "lb";
  96. config.onPrepare = (g) => {
  97. RectTransform btn = GameObject.Find("HomeView/HomeViewRenderBow/Btn").GetComponent<RectTransform>();
  98. g.hollowOutMask.SetTarget(btn);
  99. // g.hollowOutMask.isTargetRectCanThrough = false;
  100. g.SetIconPointerHitOpacity(0.5f);
  101. g.config.hitPos = btn.position;
  102. g.config.pointerPos = btn.position + RectTransformUtils.CanvasV3ToScreenV3(Vector3.up * 80f, btn);
  103. g.config.frameTipPos = btn.position + RectTransformUtils.CanvasV3ToScreenV3(Vector3.up * 150f, btn);
  104. g.hollowOutMask.autoUpdate = true;
  105. };
  106. config.onStart = (g) => {
  107. g.GetMaskClickedEvent().RemoveAllListeners();
  108. g.GetMaskClickedEvent().AddListener(() => {
  109. if (BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess) {
  110. g.OnClick_ToNext();
  111. }
  112. });
  113. };
  114. configs.Add(config.key, config);
  115. config = new NewUserGuiderConfig();
  116. config.key = "弓箭详情";
  117. config.frameTipPivot = "lt";
  118. config.onPrepare = (g) => {
  119. RectTransform btn = GameObject.Find("HomeView/HomeViewRenderBow/BtnShowDetail").GetComponent<RectTransform>();
  120. g.hollowOutMask.SetTarget(btn);
  121. g.hollowOutMask.isTargetRectCanThrough = false;
  122. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  123. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.7f));
  124. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.5f));
  125. };
  126. config.onStart = (g) => {
  127. g.GetMaskClickedEvent().RemoveAllListeners();
  128. g.GetNewUserGuiderButton().onClick += () => {
  129. HomeViewRenderBow homeViewRenderBow = FindObjectOfType<HomeViewRenderBow>();
  130. if (homeViewRenderBow) {
  131. homeViewRenderBow.OnClick_ShowDeviceView();
  132. g.clickedWillPlayAudioBtn = false;
  133. g.OnClick_ToNext();
  134. }
  135. };
  136. };
  137. configs.Add(config.key, config);
  138. config = new NewUserGuiderConfig();
  139. config.key = "设备-陀螺仪校准";
  140. config.frameTipPivot = "rt";
  141. config.onPrepare = (g) => {
  142. if (!DeviceView1.ins) {
  143. g.customPreparePass = false;
  144. return;
  145. }
  146. g.customPreparePass = true;
  147. RectTransform btn = DeviceView1.ins.transform.Find("ItemInfo/BowOptions/GyrCalibrate") as RectTransform;
  148. g.hollowOutMask.SetTarget(btn);
  149. // g.hollowOutMask.isTargetRectCanThrough = false;
  150. g.SetIconPointerHitOpacity(0.8f);
  151. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  152. g.config.pointerRotZ = 180;
  153. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f));
  154. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, 0))
  155. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  156. };
  157. config.onStart = (g) => {
  158. g.GetMaskClickedEvent().RemoveAllListeners();
  159. Action onclickTarget = () => {
  160. g.gameObject.SetActive(false);
  161. DeviceCalibrateView.ins.action_OnDestroy += () => {
  162. g.clickedWillPlayAudioBtn = false;
  163. g.OnClick_ToNext();
  164. };
  165. };
  166. DeviceView1.ins.action_OnClickGyr += onclickTarget;
  167. g.action_OnDestroy += () => DeviceView1.ins.action_OnClickGyr -= onclickTarget;
  168. };
  169. configs.Add(config.key, config);
  170. config = new NewUserGuiderConfig();
  171. config.key = "设备-地磁计校准";
  172. config.frameTipPivot = "rt";
  173. config.onPrepare = (g) => {
  174. if (!DeviceView1.ins) {
  175. g.customPreparePass = false;
  176. return;
  177. }
  178. g.customPreparePass = true;
  179. RectTransform btn = DeviceView1.ins.transform.Find("ItemInfo/BowOptions/MagCalibrate") as RectTransform;
  180. g.hollowOutMask.SetTarget(btn);
  181. // g.hollowOutMask.isTargetRectCanThrough = false;
  182. g.SetIconPointerHitOpacity(0.8f);
  183. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  184. g.config.pointerRotZ = 180;
  185. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f));
  186. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, 0))
  187. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 60f, g.iconPointer);
  188. };
  189. config.onStart = (g) => {
  190. g.GetMaskClickedEvent().RemoveAllListeners();
  191. Action onclickTarget = () => {
  192. g.gameObject.SetActive(false);
  193. DeviceCalibrateView.ins.action_OnDestroy += () => {
  194. if (AimHandler.ins.MagCalibrater.Complete) {
  195. FindObjectOfType<DeviceView1>()?.OnClick_Back();
  196. g.clickedWillPlayAudioBtn = false;
  197. g.OnClick_ToNext();
  198. } else {
  199. g.gameObject.SetActive(true);
  200. }
  201. };
  202. };
  203. DeviceView1.ins.action_OnClickMag += onclickTarget;
  204. g.action_OnDestroy += () => {
  205. if (!DeviceView1.ins) return;
  206. DeviceView1.ins.action_OnClickMag -= onclickTarget;
  207. };
  208. };
  209. configs.Add(config.key, config);
  210. config = new NewUserGuiderConfig();
  211. config.key = "查看设置";
  212. config.frameTipPivot = "rt";
  213. config.onPrepare = (g) => {
  214. RectTransform btn = GameObject.Find("TopBarView/TopBar/IconSetUp").GetComponent<RectTransform>();
  215. g.hollowOutMask.SetTarget(btn);
  216. g.hollowOutMask.isTargetRectCanThrough = false;
  217. g.SetIconPointerHitOpacity(0.6f);
  218. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  219. g.config.pointerRotZ = 180;
  220. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f);
  221. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  222. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  223. };
  224. configs.Add(config.key, config);
  225. config = new NewUserGuiderConfig();
  226. config.key = "查看商城";
  227. config.frameTipPivot = "rt";
  228. config.onPrepare = (g) => {
  229. RectTransform btn = GameObject.Find("TopBarView/TopBar/IconShop").GetComponent<RectTransform>();
  230. g.hollowOutMask.SetTarget(btn);
  231. g.hollowOutMask.isTargetRectCanThrough = false;
  232. g.SetIconPointerHitOpacity(0.6f);
  233. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  234. g.config.pointerRotZ = 180;
  235. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f);
  236. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  237. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer);
  238. };
  239. configs.Add(config.key, config);
  240. config = new NewUserGuiderConfig();
  241. config.key = "切换好友/排行榜";
  242. config.frameTipPivot = "lt";
  243. config.onPrepare = (g) => {
  244. RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnTop").GetComponent<RectTransform>();
  245. g.hollowOutMask.SetTarget(btn);
  246. g.hollowOutMask.isTargetRectCanThrough = false;
  247. g.SetIconPointerHitOpacity(0.6f);
  248. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  249. g.config.pointerRotZ = -30;
  250. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0.9f));
  251. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0));
  252. };
  253. configs.Add(config.key, config);
  254. config = new NewUserGuiderConfig();
  255. config.key = "展开好友/排行榜";
  256. config.frameTipPivot = "lc";
  257. config.onPrepare = (g) => {
  258. RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnBottom").GetComponent<RectTransform>();
  259. g.hollowOutMask.SetTarget(btn);
  260. g.hollowOutMask.isTargetRectCanThrough = false;
  261. g.SetIconPointerHitOpacity(0.8f);
  262. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  263. g.config.pointerRotZ = -30;
  264. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1, 0.9f));
  265. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.5f, 0.5f));
  266. };
  267. configs.Add(config.key, config);
  268. config = new NewUserGuiderConfig();
  269. config.key = "联机游戏";
  270. config.frameTipPivot = "lt";
  271. config.onPrepare = (g) => {
  272. RectTransform btn = GameObject.Find("HomeView/RightPanel/Item (1)").GetComponent<RectTransform>();
  273. g.hollowOutMask.SetTarget(btn);
  274. g.hollowOutMask.isTargetRectCanThrough = false;
  275. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f));
  276. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f));
  277. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero);
  278. };
  279. configs.Add(config.key, config);
  280. config = new NewUserGuiderConfig();
  281. config.key = "开始游戏";
  282. config.frameTipPivot = "lt";
  283. config.onPrepare = (g) => {
  284. RectTransform btn = GameObject.Find("HomeView/RightPanel/Item").GetComponent<RectTransform>();
  285. g.hollowOutMask.SetTarget(btn);
  286. // g.hollowOutMask.isTargetRectCanThrough = false;
  287. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f));
  288. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f));
  289. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero);
  290. };
  291. config.onStart = (g) => {
  292. g.GetMaskClickedEvent().RemoveAllListeners();
  293. Action onClickTarget = () => {
  294. g.clickedWillPlayAudioBtn = false;
  295. g.OnClick_ToNext();
  296. };
  297. HomeView.ins.action_OnClickStartGame += onClickTarget;
  298. g.action_OnDestroy += () => HomeView.ins.action_OnClickStartGame -= onClickTarget;
  299. };
  300. configs.Add(config.key, config);
  301. config = new NewUserGuiderConfig();
  302. config.key = "开始-限时游戏";
  303. config.frameTipPivot = "lt";
  304. config.onPrepare = (g) => {
  305. if (!GameStartView.ins) {
  306. g.customPreparePass = false;
  307. return;
  308. }
  309. g.customPreparePass = true;
  310. RectTransform btn = GameStartView.ins.transform.Find("EntryList/Item (1)") as RectTransform;
  311. g.hollowOutMask.SetTarget(btn);
  312. // g.hollowOutMask.isTargetRectCanThrough = false;
  313. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  314. g.config.pointerRotZ = 180;
  315. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.2f, 0.3f));
  316. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.4f, 0.15f));
  317. };
  318. config.onStart = (g) => {
  319. g.GetMaskClickedEvent().RemoveAllListeners();
  320. };
  321. configs.Add(config.key, config);
  322. config = new NewUserGuiderConfig();
  323. config.key = "限时游戏-选择距离";
  324. config.frameTipPivot = "lc";
  325. config.onPrepare = (g) => {
  326. if (g.hollowOutMask.enabled) g.hollowOutMask.enabled = false;
  327. if (!TimeLimitGameDistanceSelectView.ins) {
  328. g.customPreparePass = false;
  329. return;
  330. }
  331. g.customPreparePass = true;
  332. g.hollowOutMask.enabled = true;
  333. RectTransform btn = TimeLimitGameDistanceSelectView.ins.transform.Find("Layout/Item") as RectTransform;
  334. g.hollowOutMask.SetTarget(btn);
  335. // g.hollowOutMask.isTargetRectCanThrough = false;
  336. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  337. g.config.pointerRotZ = -30;
  338. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.85f, 0.5f));
  339. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.15f, 0.4f));
  340. };
  341. config.onStart = (g) => {
  342. g.GetMaskClickedEvent().RemoveAllListeners();
  343. Action onClickTarget = () => {
  344. g.clickedWillPlayAudioBtn = false;
  345. g.OnClick_ToNext();
  346. };
  347. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance += onClickTarget;
  348. g.action_OnDestroy += () => {
  349. if (!TimeLimitGameDistanceSelectView.ins) return;
  350. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance -= onClickTarget;
  351. };
  352. };
  353. configs.Add(config.key, config);
  354. config = new NewUserGuiderConfig();
  355. config.key = "视角归位-触发";
  356. config.frameTipPivot = "rb";
  357. config.frameTipPos = Vector2.zero;
  358. config.onPrepare = (g) => {
  359. RectTransform btn4 = GameAssistUI.ins.transform.Find("Button4") as RectTransform;
  360. g.hollowOutMask.SetTarget(btn4);
  361. RectTransform btn4_img = btn4.Find("Image") as RectTransform;
  362. g.config.hitPos = btn4_img.position;
  363. g.config.pointerRotZ = 120;
  364. g.config.pointerPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-60, 60), btn4);
  365. g.config.frameTipPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-120, 120), btn4);
  366. GameMode gameMode = GameMgr.ins.gameMode;
  367. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  368. gameMode.PauseTimeCounting(g);
  369. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  370. }
  371. };
  372. config.onStart = (g) => {
  373. g.GetMaskClickedEvent().RemoveAllListeners();
  374. Action onClickTarget = () => {
  375. g.gameObject.SetActive(false);
  376. AutoResetView.ins.action_OnDestroy += () => {
  377. DoTweenUtil.CallDelay(1, () => {
  378. if (!g) return;
  379. g.clickedWillPlayAudioBtn = false;
  380. g.OnClick_ToNext();
  381. });
  382. };
  383. };
  384. GameAssistUI.ins.action_OnClickBtnIdentity += onClickTarget;
  385. g.action_OnDestroy += () => GameAssistUI.ins.action_OnClickBtnIdentity -= onClickTarget;
  386. };
  387. configs.Add(config.key, config);
  388. // config = new NewUserGuiderConfig();
  389. // config.key = "视角归位-瞄准";
  390. // config.frameTipPivot = "lc";
  391. // config.onPrepare = (g) => {
  392. // float rectSideLen = RectTransformUtils.ScreenV3ToCanvasV3(Vector3.right * Screen.height * 100 / 720f, g.GetComponent<RectTransform>()).x;
  393. // Vector2 rectSize = new Vector2(rectSideLen, rectSideLen);
  394. // RectTransform iconRect = g.transform.Find("IconRect") as RectTransform;
  395. // iconRect.sizeDelta = rectSize;
  396. // iconRect.gameObject.SetActive(true);
  397. // g.hollowOutMask.isTargetRectCanThrough = false;
  398. // g.hollowOutMask.SetTarget(iconRect);
  399. // g.config.hitPosType = 1;
  400. // g.config.hitPos = Vector2.zero;
  401. // g.config.pointerPosType = 1;
  402. // g.config.pointerRotZ = 120;
  403. // g.config.pointerPos = new Vector2(-rectSideLen / 2 * 1.2f, rectSideLen / 2 * 1.1f);
  404. // RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
  405. // iconHumanShoot.anchoredPosition = g.config.pointerPos;
  406. // iconHumanShoot.gameObject.SetActive(true);
  407. // g.config.frameTipPosType = 1;
  408. // g.config.frameTipPos = new Vector2(rectSideLen / 2 * 1.3f, 0);
  409. // GameMode gameMode = GameMgr.ins.gameMode;
  410. // if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  411. // gameMode.PauseTimeCounting(g);
  412. // g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  413. // }
  414. // };
  415. // configs.Add(config.key, config);
  416. config = new NewUserGuiderConfig();
  417. config.key = "教程结束";
  418. config.hitActive = false;
  419. config.pointerActive = false;
  420. config.frameTipPivot = "ct";
  421. config.frameTipPosType = 1;
  422. config.frameTipPos = Vector2.zero;
  423. config.onStart = (g) => {
  424. g.GetMaskClickedEvent().AddListener(() => {
  425. OnEnd();
  426. });
  427. GameMode gameMode = GameMgr.ins.gameMode;
  428. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  429. gameMode.PauseTimeCounting(g);
  430. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  431. }
  432. };
  433. configs.Add(config.key, config);
  434. }
  435. #if UNITY_EDITOR
  436. bool warn_test = false;
  437. void Update() {
  438. if (!warn_test) {
  439. warn_test = true;
  440. Debug.LogWarning("F3-重置设备校准引导,规则引导");
  441. Debug.LogWarning("F4-重置新手引导记录");
  442. Debug.LogWarning("F5-新手引导强行下一步");
  443. }
  444. if (Input.GetKeyDown(KeyCode.F3)) {
  445. Debug.Log("重置设备校准引导,规则引导");
  446. AimHandler.ins.MagCalibrater = new o0._9Axis.MagnetometerAutoCalibrater();
  447. UserSettings.ins.deviceCalibrateGuideFinish = false;
  448. UserSettings.ins.gameRuleGuideFinish = new HashSet<int>();
  449. }
  450. if (Input.GetKeyDown(KeyCode.F4)) {
  451. Debug.Log("重置新手引导记录");
  452. SaveUserGuideFinished(false);
  453. }
  454. if (Input.GetKeyDown(KeyCode.F5)) {
  455. Debug.Log("新手引导强行下一步");
  456. FindObjectOfType<NewUserGuider>()?.OnClick_ToNext();
  457. }
  458. }
  459. #endif
  460. private Dictionary<string, NewUserGuiderConfig> configs = new Dictionary<string, NewUserGuiderConfig>();
  461. private bool configsInited = false;
  462. [SerializeField] public string curConfigKey = "模块开机";
  463. private List<string> configKeyList = new List<string>(new string[]{
  464. "模块开机",
  465. "连接设备",
  466. "弓箭详情",
  467. "设备-陀螺仪校准",
  468. "设备-地磁计校准",
  469. "查看设置",
  470. "查看商城",
  471. "切换好友/排行榜",
  472. "展开好友/排行榜",
  473. "联机游戏",
  474. "开始游戏",
  475. "开始-限时游戏",
  476. "限时游戏-选择距离",
  477. "视角归位-触发",
  478. // "视角归位-瞄准",
  479. "教程结束",
  480. });
  481. [ContextMenu("执行当前配置")]
  482. void ExecuteCurConfig() {
  483. InitConfigs();
  484. NewUserGuiderConfig config = configs[curConfigKey];
  485. NewUserGuider guider = Instantiate(prefab_NewUserGuider).GetComponent<NewUserGuider>();
  486. guider.config = config;
  487. }
  488. public void OnClickedDestroyed(string configKey) {
  489. int nextIndex = configKeyList.IndexOf(configKey) + 1;
  490. if (nextIndex >= configKeyList.Count) return;
  491. curConfigKey = configKeyList[nextIndex];
  492. ExecuteCurConfig();
  493. }
  494. }
  495. public class NewUserGuiderConfig
  496. {
  497. public string key;
  498. //0:position,1:anchoredPosition
  499. public int hitPosType = 0;
  500. public Vector2 hitPos;
  501. public bool hitActive = true;
  502. //icon pointer rotation z
  503. public float pointerRotZ;
  504. public int pointerPosType = 0;
  505. public Vector2 pointerPos;
  506. public bool pointerActive = true;
  507. //frameTip-Pivot l:left,r:right,t:top,b:bottom,ct:center
  508. public string frameTipPivot = "lt";
  509. public int frameTipPosType = 0;
  510. public Vector2 frameTipPos;
  511. //frameTip text
  512. public string frameTipText = null;
  513. public string frameTipTextKey = null;
  514. public Action<NewUserGuider> onPrepare;
  515. public Action<NewUserGuider> onStart;
  516. }