NewUserGuiderManager.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592
  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. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  288. };
  289. configs.Add(config.key, config);
  290. config = new NewUserGuiderConfig();
  291. config.key = "开始游戏";
  292. config.frameTipPivot = "lt";
  293. config.onPrepare = (g) => {
  294. RectTransform btn = GameObject.Find("HomeView/RightPanel/Item").GetComponent<RectTransform>();
  295. g.hollowOutMask.SetTarget(btn);
  296. // g.hollowOutMask.isTargetRectCanThrough = false;
  297. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f));
  298. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f));
  299. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero)
  300. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  301. };
  302. config.onStart = (g) => {
  303. g.GetMaskClickedEvent().RemoveAllListeners();
  304. Action onClickTarget = () => {
  305. g.clickedWillPlayAudioBtn = false;
  306. g.OnClick_ToNext();
  307. };
  308. HomeView.ins.action_OnClickStartGame += onClickTarget;
  309. g.action_OnDestroy += () => HomeView.ins.action_OnClickStartGame -= onClickTarget;
  310. };
  311. configs.Add(config.key, config);
  312. config = new NewUserGuiderConfig();
  313. config.key = "开始-限时游戏";
  314. config.frameTipPivot = "lt";
  315. config.onPrepare = (g) => {
  316. if (!GameStartView.ins) {
  317. g.customPreparePass = false;
  318. return;
  319. }
  320. g.customPreparePass = true;
  321. RectTransform btn = GameStartView.ins.transform.Find("EntryList/Item (1)") as RectTransform;
  322. g.hollowOutMask.SetTarget(btn);
  323. // g.hollowOutMask.isTargetRectCanThrough = false;
  324. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  325. g.config.pointerRotZ = 180;
  326. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.2f, 0.3f));
  327. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.4f, 0.15f))
  328. + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer);
  329. };
  330. config.onStart = (g) => {
  331. g.GetMaskClickedEvent().RemoveAllListeners();
  332. };
  333. configs.Add(config.key, config);
  334. config = new NewUserGuiderConfig();
  335. config.key = "限时游戏-选择距离";
  336. config.frameTipPivot = "lc";
  337. config.onPrepare = (g) => {
  338. if (g.hollowOutMask.enabled) g.hollowOutMask.enabled = false;
  339. if (!TimeLimitGameDistanceSelectView.ins) {
  340. g.customPreparePass = false;
  341. return;
  342. }
  343. g.customPreparePass = true;
  344. g.hollowOutMask.enabled = true;
  345. RectTransform btn = TimeLimitGameDistanceSelectView.ins.transform.Find("Layout/Item") as RectTransform;
  346. g.hollowOutMask.SetTarget(btn);
  347. // g.hollowOutMask.isTargetRectCanThrough = false;
  348. g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f);
  349. g.config.pointerRotZ = -30;
  350. g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.85f, 0.5f));
  351. g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.15f, 0.4f));
  352. };
  353. config.onStart = (g) => {
  354. g.GetMaskClickedEvent().RemoveAllListeners();
  355. Action onClickTarget = () => {
  356. g.clickedWillPlayAudioBtn = false;
  357. g.OnClick_ToNext();
  358. };
  359. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance += onClickTarget;
  360. g.action_OnDestroy += () => {
  361. if (!TimeLimitGameDistanceSelectView.ins) return;
  362. TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance -= onClickTarget;
  363. };
  364. };
  365. configs.Add(config.key, config);
  366. config = new NewUserGuiderConfig();
  367. config.key = "视角归位-触发";
  368. config.frameTipPivot = "rb";
  369. config.frameTipPos = Vector2.zero;
  370. config.onPrepare = (g) => {
  371. RectTransform btn4 = GameAssistUI.ins.transform.Find("Button4") as RectTransform;
  372. g.hollowOutMask.SetTarget(btn4);
  373. RectTransform btn4_img = btn4.Find("Image") as RectTransform;
  374. g.config.hitPos = btn4_img.position;
  375. g.config.pointerRotZ = 120;
  376. g.config.pointerPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-60, 60), btn4);
  377. g.config.frameTipPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-120, 120), btn4);
  378. RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
  379. iconHumanShoot.pivot = Vector2.one * 0.5f;
  380. iconHumanShoot.anchoredPosition = new Vector2(-350, -85);
  381. iconHumanShoot.gameObject.SetActive(true);
  382. GameMode gameMode = GameMgr.ins.gameMode;
  383. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  384. gameMode.PauseTimeCounting(g);
  385. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  386. }
  387. };
  388. config.onStart = (g) => {
  389. g.GetMaskClickedEvent().RemoveAllListeners();
  390. Action onClickTarget = () => {
  391. g.gameObject.SetActive(false);
  392. AutoResetView.ins.action_OnDestroy += () => {
  393. DoTweenUtil.CallDelay(1, () => {
  394. if (!g) return;
  395. g.clickedWillPlayAudioBtn = false;
  396. g.OnClick_ToNext();
  397. });
  398. };
  399. };
  400. GameAssistUI.ins.action_OnClickBtnIdentity += onClickTarget;
  401. g.action_OnDestroy += () => GameAssistUI.ins.action_OnClickBtnIdentity -= onClickTarget;
  402. };
  403. configs.Add(config.key, config);
  404. // config = new NewUserGuiderConfig();
  405. // config.key = "视角归位-瞄准";
  406. // config.frameTipPivot = "lc";
  407. // config.onPrepare = (g) => {
  408. // float rectSideLen = RectTransformUtils.ScreenV3ToCanvasV3(Vector3.right * Screen.height * 100 / 720f, g.GetComponent<RectTransform>()).x;
  409. // Vector2 rectSize = new Vector2(rectSideLen, rectSideLen);
  410. // RectTransform iconRect = g.transform.Find("IconRect") as RectTransform;
  411. // iconRect.sizeDelta = rectSize;
  412. // iconRect.gameObject.SetActive(true);
  413. // g.hollowOutMask.isTargetRectCanThrough = false;
  414. // g.hollowOutMask.SetTarget(iconRect);
  415. // g.config.hitPosType = 1;
  416. // g.config.hitPos = Vector2.zero;
  417. // g.config.pointerPosType = 1;
  418. // g.config.pointerRotZ = 120;
  419. // g.config.pointerPos = new Vector2(-rectSideLen / 2 * 1.2f, rectSideLen / 2 * 1.1f);
  420. // RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
  421. // iconHumanShoot.anchoredPosition = g.config.pointerPos;
  422. // iconHumanShoot.gameObject.SetActive(true);
  423. // g.config.frameTipPosType = 1;
  424. // g.config.frameTipPos = new Vector2(rectSideLen / 2 * 1.3f, 0);
  425. // GameMode gameMode = GameMgr.ins.gameMode;
  426. // if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  427. // gameMode.PauseTimeCounting(g);
  428. // g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  429. // }
  430. // };
  431. // configs.Add(config.key, config);
  432. config = new NewUserGuiderConfig();
  433. config.key = "教程结束";
  434. config.hitActive = false;
  435. config.pointerActive = false;
  436. config.frameTipPivot = "ct";
  437. config.frameTipPosType = 1;
  438. config.frameTipPos = Vector2.zero;
  439. config.onStart = (g) => {
  440. g.GetMaskClickedEvent().AddListener(() => {
  441. OnEnd();
  442. });
  443. GameMode gameMode = GameMgr.ins.gameMode;
  444. if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
  445. gameMode.PauseTimeCounting(g);
  446. g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
  447. }
  448. };
  449. configs.Add(config.key, config);
  450. }
  451. #if UNITY_EDITOR
  452. bool warn_test = false;
  453. void Update() {
  454. if (!warn_test) {
  455. warn_test = true;
  456. Debug.LogWarning("F3-重置设备校准引导,规则引导");
  457. Debug.LogWarning("F4-重置新手引导记录");
  458. Debug.LogWarning("F5-新手引导强行下一步");
  459. }
  460. if (Input.GetKeyDown(KeyCode.F3)) {
  461. Debug.Log("重置设备校准引导,规则引导");
  462. AimHandler.ins.MagCalibrater = new o0._9Axis.MagnetometerAutoCalibrater();
  463. UserSettings.ins.deviceCalibrateGuideFinish = false;
  464. UserSettings.ins.gameRuleGuideFinish = new HashSet<int>();
  465. }
  466. if (Input.GetKeyDown(KeyCode.F4)) {
  467. Debug.Log("重置新手引导记录");
  468. SaveUserGuideFinished(false);
  469. }
  470. if (Input.GetKeyDown(KeyCode.F5)) {
  471. Debug.Log("新手引导强行下一步");
  472. FindObjectOfType<NewUserGuider>()?.OnClick_ToNext();
  473. }
  474. }
  475. #endif
  476. private Dictionary<string, NewUserGuiderConfig> configs = new Dictionary<string, NewUserGuiderConfig>();
  477. private bool configsInited = false;
  478. [SerializeField] public string curConfigKey = "模块开机";
  479. private List<string> configKeyList = new List<string>(new string[]{
  480. "模块开机",
  481. "连接设备",
  482. "弓箭详情",
  483. "设备-陀螺仪校准",
  484. "设备-地磁计校准",
  485. "查看设置",
  486. "查看商城",
  487. "切换好友/排行榜",
  488. "展开好友/排行榜",
  489. "联机游戏",
  490. "开始游戏",
  491. "开始-限时游戏",
  492. "限时游戏-选择距离",
  493. "视角归位-触发",
  494. // "视角归位-瞄准",
  495. "教程结束",
  496. });
  497. [ContextMenu("执行当前配置")]
  498. void ExecuteCurConfig() {
  499. InitConfigs();
  500. NewUserGuiderConfig config = configs[curConfigKey];
  501. NewUserGuider guider = Instantiate(prefab_NewUserGuider).GetComponent<NewUserGuider>();
  502. guider.config = config;
  503. }
  504. public void OnClickedDestroyed(string configKey) {
  505. int nextIndex = configKeyList.IndexOf(configKey) + 1;
  506. if (nextIndex >= configKeyList.Count) return;
  507. curConfigKey = configKeyList[nextIndex];
  508. ExecuteCurConfig();
  509. }
  510. }
  511. public class NewUserGuiderConfig
  512. {
  513. public string key;
  514. //0:position,1:anchoredPosition
  515. public int hitPosType = 0;
  516. public Vector2 hitPos;
  517. public bool hitActive = true;
  518. //icon pointer rotation z
  519. public float pointerRotZ;
  520. public int pointerPosType = 0;
  521. public Vector2 pointerPos;
  522. public bool pointerActive = true;
  523. //frameTip-Pivot l:left,r:right,t:top,b:bottom,ct:center
  524. public string frameTipPivot = "lt";
  525. public int frameTipPosType = 0;
  526. public Vector2 frameTipPos;
  527. //frameTip text
  528. public string frameTipText = null;
  529. public string frameTipTextKey = null;
  530. public Action<NewUserGuider> onPrepare;
  531. public Action<NewUserGuider> onStart;
  532. }