NewUserGuiderManager.cs 23 KB

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