NewUserGuiderManager.cs 24 KB

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