using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SceneManagement; using JC.Unity.UI; public class NewUserGuiderManager : MonoBehaviour { [SerializeField] GameObject prefab_NewUserGuider; public static NewUserGuiderManager ins; void Awake() { if (ins) { Destroy(gameObject); return; } ins = this; DontDestroyOnLoad(gameObject); } void OnDestroy() { if (ins == this) ins = null; if (onSceneLoaded_added) SceneManager.sceneLoaded -= onSceneLoaded; } void Start() { SceneManager.sceneLoaded += onSceneLoaded; onSceneLoaded_added = true; if (!IsUserGuideFinished()) { ExecuteCurConfig(); SaveUserGuideFinished(true); } } bool onSceneLoaded_added = false; void onSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { //初始话的场景不会触发 if (scene.name == "Game" && GameMgr.gameType == 1) { switch (curConfigKey) { case "开始-限时游戏": OnClickedDestroyed(curConfigKey); break; case "限时游戏-选择距离": ExecuteCurConfig(); break; } } } public void OnSkip() { curConfigKey = null; SaveUserGuideFinished(true); } public void OnEnd() { curConfigKey = null; SaveUserGuideFinished(true); } public void ReviewNewUserGuide() { int viewCount = PersistenHandler.ins.menuBackCtr.views.Count; for (int i = 0; i < viewCount; i++) { PersistenHandler.ins.menuBackCtr.OnOnceBack(); } curConfigKey = "模块开机"; ExecuteCurConfig(); } void SaveUserGuideFinished(bool finished) { PlayerPrefs.SetInt("NewUserGuiderFinished", finished ? 1 : 0); } bool IsUserGuideFinished() { return PlayerPrefs.GetInt("NewUserGuiderFinished", 0) == 1 ? true : false; } void InitConfigs() { if (configsInited) return; configsInited = true; NewUserGuiderConfig config = new NewUserGuiderConfig(); config.key = "模块开机"; config.hitPosType = 1; config.hitPos = new Vector2(-138.9f, -56.1f); config.pointerRotZ = 120; config.pointerPosType = 1; config.pointerPos = new Vector2(-205, 4); config.frameTipPivot = "lc"; config.frameTipPosType = 1; config.frameTipPos = new Vector2(0, 0); config.onStart = (g) => { RectTransform iconModule = g.transform.Find("IconModule") as RectTransform; iconModule.anchoredPosition = new Vector2(-146, -39); iconModule.gameObject.SetActive(true); g.SetIconPointerHitOpacity(0.2f); }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "连接设备"; config.frameTipPivot = "lb"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("HomeView/HomeViewRenderBow/Btn").GetComponent(); g.hollowOutMask.SetTarget(btn); // g.hollowOutMask.isTargetRectCanThrough = false; g.SetIconPointerHitOpacity(0.5f); g.config.hitPos = btn.position; g.config.pointerPos = btn.position + RectTransformUtils.CanvasV3ToScreenV3(Vector3.up * 80f, btn); g.config.frameTipPos = btn.position + RectTransformUtils.CanvasV3ToScreenV3(Vector3.up * 150f, btn); g.hollowOutMask.autoUpdate = true; }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); g.GetMaskClickedEvent().AddListener(() => { if (BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess) { g.OnClick_ToNext(); } }); Func action_DoConnectInterceptor = () => { bool isConnected = BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess; if (isConnected) { g.OnClick_ToNext(); } return isConnected; }; BluetoothAim.ins.action_DoConnectInterceptor += action_DoConnectInterceptor; g.action_OnDestroy += () => BluetoothAim.ins.action_DoConnectInterceptor -= action_DoConnectInterceptor; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "弓箭详情"; config.frameTipPivot = "lt"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("HomeView/HomeViewRenderBow/BtnShowDetail").GetComponent(); g.hollowOutMask.SetTarget(btn); g.hollowOutMask.isTargetRectCanThrough = false; g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.7f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.5f)); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); g.GetNewUserGuiderButton().onClick += () => { HomeViewRenderBow homeViewRenderBow = FindObjectOfType(); if (homeViewRenderBow) { homeViewRenderBow.OnClick_ShowDeviceView(); g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); } }; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "设备-陀螺仪校准"; config.frameTipPivot = "rt"; config.onPrepare = (g) => { if (!DeviceView1.ins) { g.customPreparePass = false; return; } g.customPreparePass = true; RectTransform btn = DeviceView1.ins.transform.Find("ItemInfo/BowOptions/GyrCalibrate") as RectTransform; g.hollowOutMask.SetTarget(btn); // g.hollowOutMask.isTargetRectCanThrough = false; g.SetIconPointerHitOpacity(0.8f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 180; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, 0)) + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); Action onclickTarget = () => { g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); }; DeviceView1.ins.action_OnClickGyr += onclickTarget; g.action_OnDestroy += () => DeviceView1.ins.action_OnClickGyr -= onclickTarget; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "陀螺仪校准-开始"; config.frameTipPivot = "rt"; config.frameTipText = ""; config.delayExecute = false; config.onPrepare = (g) => { g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent().sortingOrder + 1); RectTransform btn = DeviceCalibrateView.ins.transform.Find("Gyr/Button") as RectTransform; g.hollowOutMask.SetTarget(btn); g.SetIconPointerHitOpacity(0.8f); g.SetMaskOpacity(0.33f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 180; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f)); g.frameTip.gameObject.SetActive(false); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); g.action_Update += () => { bool doing = DeviceCalibrateView.ins.gyrCalibrating; g.iconPointer.gameObject.SetActive(!doing); g.iconPointerHit.gameObject.SetActive(!doing); }; Func interceptor = () => { return DeviceCalibrateView.ins.gyrCalibrating; }; Action operateFinished = () => { g.hollowOutMask.isTargetRectCanThrough = false; g.OnClick_ToNext(); }; DeviceCalibrateView.ins.action_OnClickGyrCalibrateInterceptor += interceptor; DeviceCalibrateView.ins.action_GyrCalibarateOperateAndFinish += operateFinished; g.action_OnDestroy += () => { DeviceCalibrateView.ins.action_OnClickGyrCalibrateInterceptor -= interceptor; DeviceCalibrateView.ins.action_GyrCalibarateOperateAndFinish -= operateFinished; }; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "陀螺仪校准-完成"; config.frameTipPivot = "rt"; config.frameTipText = ""; config.onPrepare = (g) => { g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent().sortingOrder + 1); RectTransform btn = DeviceCalibrateView.ins.transform.Find("BtnFinish") as RectTransform; g.hollowOutMask.SetTarget(btn); g.SetIconPointerHitOpacity(0.8f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 120; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.2f, 1.2f)); g.frameTip.gameObject.SetActive(false); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); Action operateFinished = () => { g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); }; DeviceCalibrateView.ins.action_OnDestroy += operateFinished; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "设备-地磁计校准"; config.frameTipPivot = "rt"; config.onPrepare = (g) => { if (!DeviceView1.ins) { g.customPreparePass = false; return; } g.customPreparePass = true; RectTransform btn = DeviceView1.ins.transform.Find("ItemInfo/BowOptions/MagCalibrate") as RectTransform; g.hollowOutMask.SetTarget(btn); // g.hollowOutMask.isTargetRectCanThrough = false; g.SetIconPointerHitOpacity(0.8f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 180; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, 0)) + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 60f, g.iconPointer); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); Action onclickTarget = () => { g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); }; DeviceView1.ins.action_OnClickMag += onclickTarget; g.action_OnDestroy += () => DeviceView1.ins.action_OnClickMag -= onclickTarget; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "地磁计校准-开始"; config.frameTipPivot = "rt"; config.frameTipText = ""; config.delayExecute = false; config.onPrepare = (g) => { g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent().sortingOrder + 1); RectTransform btn = DeviceCalibrateView.ins.transform.Find("Mag/MagReset") as RectTransform; g.hollowOutMask.SetTarget(btn); g.SetIconPointerHitOpacity(0.8f); g.SetMaskOpacity(0.33f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 180; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0.2f)); g.frameTip.gameObject.SetActive(false); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); g.action_Update += () => { bool doing = DeviceCalibrateView.ins.calibrateMagDoing; g.iconPointer.gameObject.SetActive(!doing); g.iconPointerHit.gameObject.SetActive(!doing); }; Func interceptor = () => { return DeviceCalibrateView.ins.calibrateMagDoing; }; Action operateFinished = () => { g.hollowOutMask.isTargetRectCanThrough = false; g.OnClick_ToNext(); }; DeviceCalibrateView.ins.action_OnClickMagCalibrateInterceptor += interceptor; DeviceCalibrateView.ins.action_MagCalibarateOperateAndFinish += operateFinished; g.action_OnDestroy += () => { DeviceCalibrateView.ins.action_OnClickMagCalibrateInterceptor -= interceptor; DeviceCalibrateView.ins.action_MagCalibarateOperateAndFinish -= operateFinished; }; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "地磁计校准-完成"; config.frameTipPivot = "rt"; config.frameTipText = ""; config.onPrepare = (g) => { g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent().sortingOrder + 1); RectTransform btn = DeviceCalibrateView.ins.transform.Find("BtnFinish") as RectTransform; g.hollowOutMask.SetTarget(btn); g.SetIconPointerHitOpacity(0.8f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 120; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.2f, 1.2f)); g.frameTip.gameObject.SetActive(false); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); Action operateFinished = () => { FindObjectOfType()?.OnClick_Back(); g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); }; DeviceCalibrateView.ins.action_OnDestroy += operateFinished; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "查看设置"; config.frameTipPivot = "rt"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("TopBarView/TopBar/IconSetUp").GetComponent(); g.hollowOutMask.SetTarget(btn); g.hollowOutMask.isTargetRectCanThrough = false; g.SetIconPointerHitOpacity(0.6f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 180; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero) + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer); }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "查看商城"; config.frameTipPivot = "rt"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("TopBarView/TopBar/IconShop").GetComponent(); g.hollowOutMask.SetTarget(btn); g.hollowOutMask.isTargetRectCanThrough = false; g.SetIconPointerHitOpacity(0.6f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 180; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * -0.1f); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero) + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 80f, g.iconPointer); }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "切换好友/排行榜"; config.frameTipPivot = "lt"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnTop").GetComponent(); g.hollowOutMask.SetTarget(btn); g.hollowOutMask.isTargetRectCanThrough = false; g.SetIconPointerHitOpacity(0.6f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = -30; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0.9f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.2f, 0)); }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "展开好友/排行榜"; config.frameTipPivot = "lc"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("HomeView/FriendBar/FrameBtnBottom").GetComponent(); g.hollowOutMask.SetTarget(btn); g.hollowOutMask.isTargetRectCanThrough = false; g.SetIconPointerHitOpacity(0.8f); g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = -30; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1, 0.9f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.5f, 0.5f)); }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "联机游戏"; config.frameTipPivot = "lt"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("HomeView/RightPanel/Item (1)").GetComponent(); g.hollowOutMask.SetTarget(btn); g.hollowOutMask.isTargetRectCanThrough = false; g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f)); g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero) + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer); }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "开始游戏"; config.frameTipPivot = "lt"; config.onPrepare = (g) => { RectTransform btn = GameObject.Find("HomeView/RightPanel/Item").GetComponent(); g.hollowOutMask.SetTarget(btn); // g.hollowOutMask.isTargetRectCanThrough = false; g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.5f, 0.6f)); g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.8f, 0.9f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.zero) + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); Action onClickTarget = () => { g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); }; HomeView.ins.action_OnClickStartGame += onClickTarget; g.action_OnDestroy += () => HomeView.ins.action_OnClickStartGame -= onClickTarget; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "开始-限时游戏"; config.frameTipPivot = "lt"; config.onPrepare = (g) => { if (!GameStartView.ins) { g.customPreparePass = false; return; } g.customPreparePass = true; RectTransform btn = GameStartView.ins.transform.Find("EntryList/Item (1)") as RectTransform; g.hollowOutMask.SetTarget(btn); // g.hollowOutMask.isTargetRectCanThrough = false; g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = 180; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.2f, 0.3f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.4f, 0.15f)) + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 150f, g.iconPointer); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "限时游戏-选择距离"; config.frameTipPivot = "lc"; config.onPrepare = (g) => { if (g.hollowOutMask.enabled) g.hollowOutMask.enabled = false; g.ActiveBtnSkip(false); if (!TimeLimitGameDistanceSelectView.ins) { g.customPreparePass = false; return; } LayoutRebuilder.ForceRebuildLayoutImmediate(TimeLimitGameDistanceSelectView.ins.transform as RectTransform); g.customPreparePass = true; g.hollowOutMask.enabled = true; g.ActiveBtnSkip(true); RectTransform btn = TimeLimitGameDistanceSelectView.ins.transform.Find("Layout/Item") as RectTransform; g.hollowOutMask.SetTarget(btn); // g.hollowOutMask.isTargetRectCanThrough = false; g.config.hitPos = RectTransformUtils.GetPositionByPivot(btn, Vector2.one * 0.5f); g.config.pointerRotZ = -30; g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.85f, 0.5f)); g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(1.15f, 0.4f)); }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); Action onClickTarget = () => { g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); }; TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance += onClickTarget; g.action_OnDestroy += () => { if (!TimeLimitGameDistanceSelectView.ins) return; TimeLimitGameDistanceSelectView.ins.action_OnClickSelectDistance -= onClickTarget; }; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "视角归位-触发"; config.frameTipPivot = "rb"; config.frameTipPos = Vector2.zero; config.onPrepare = (g) => { RectTransform btn4 = GameAssistUI.ins.transform.Find("Button4") as RectTransform; g.hollowOutMask.SetTarget(btn4); RectTransform btn4_img = btn4.Find("Image") as RectTransform; g.config.hitPos = btn4_img.position; g.config.pointerRotZ = 120; g.config.pointerPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-60, 60), btn4); g.config.frameTipPos = btn4_img.position + RectTransformUtils.CanvasV3ToScreenV3(new Vector3(-120, 120), btn4); RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform; iconHumanShoot.pivot = Vector2.one * 0.5f; iconHumanShoot.anchoredPosition = new Vector2(-350, -85); iconHumanShoot.gameObject.SetActive(true); GameMode gameMode = GameMgr.ins.gameMode; if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) { gameMode.PauseTimeCounting(g); g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g); } }; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); Action onClickTarget = () => { g.gameObject.SetActive(false); AutoResetView.ins.action_OnDestroy += () => { if (!g) return; g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); }; }; GameAssistUI.ins.action_OnClickBtnIdentity += onClickTarget; g.action_OnDestroy += () => GameAssistUI.ins.action_OnClickBtnIdentity -= onClickTarget; }; configs.Add(config.key, config); // config = new NewUserGuiderConfig(); // config.key = "视角归位-瞄准"; // config.frameTipPivot = "lc"; // config.onPrepare = (g) => { // float rectSideLen = RectTransformUtils.ScreenV3ToCanvasV3(Vector3.right * Screen.height * 100 / 720f, g.GetComponent()).x; // Vector2 rectSize = new Vector2(rectSideLen, rectSideLen); // RectTransform iconRect = g.transform.Find("IconRect") as RectTransform; // iconRect.sizeDelta = rectSize; // iconRect.gameObject.SetActive(true); // g.hollowOutMask.isTargetRectCanThrough = false; // g.hollowOutMask.SetTarget(iconRect); // g.config.hitPosType = 1; // g.config.hitPos = Vector2.zero; // g.config.pointerPosType = 1; // g.config.pointerRotZ = 120; // g.config.pointerPos = new Vector2(-rectSideLen / 2 * 1.2f, rectSideLen / 2 * 1.1f); // RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform; // iconHumanShoot.anchoredPosition = g.config.pointerPos; // iconHumanShoot.gameObject.SetActive(true); // g.config.frameTipPosType = 1; // g.config.frameTipPos = new Vector2(rectSideLen / 2 * 1.3f, 0); // GameMode gameMode = GameMgr.ins.gameMode; // if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) { // gameMode.PauseTimeCounting(g); // g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g); // } // }; // configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "准心高亮"; config.hitPosType = 1; config.hitPos = Vector2.zero; config.pointerActive = false; config.frameTipText = ""; config.onStart = (g) => { g.GetMaskClickedEvent().RemoveAllListeners(); GameMode gameMode = GameMgr.ins.gameMode; if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) { gameMode.PauseTimeCounting(g); g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g); } RectTransform iconRect = g.transform.Find("IconRect") as RectTransform; iconRect.gameObject.SetActive(true); g.hollowOutMask.isTargetRectCanThrough = false; g.hollowOutMask.SetTarget(iconRect); Transform centerPoint = TargetBody.ins.transform.Find("CenterPoint"); Transform sidePoint = TargetBody.ins.transform.Find("SidePoint"); float countDown = 5; g.action_Update += () => { Vector3 centerPos = RectTransformUtility.WorldToScreenPoint(Camera.main, centerPoint.position); Vector3 sidePos = RectTransformUtility.WorldToScreenPoint(Camera.main, sidePoint.position); float sizeLen = Mathf.Abs(centerPos.x - sidePos.x) * 2; iconRect.position = centerPos; iconRect.sizeDelta = JC.Unity.UI.RectTransformUtils.ScreenV3ToCanvasV3(Vector3.one * sizeLen, iconRect); g.hollowOutMask.RefreshViewImmediate(); countDown -= Time.deltaTime; if (countDown <= 0) { g.clickedWillPlayAudioBtn = false; g.OnClick_ToNext(); } g.iconPointerHit.transform.position = CrossHair.ins.transform.position; }; }; configs.Add(config.key, config); config = new NewUserGuiderConfig(); config.key = "教程结束"; config.hitActive = false; config.pointerActive = false; config.frameTipPivot = "ct"; config.frameTipPosType = 1; config.frameTipPos = Vector2.zero; config.onStart = (g) => { g.GetMaskClickedEvent().AddListener(() => { OnEnd(); }); GameMode gameMode = GameMgr.ins.gameMode; if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) { gameMode.PauseTimeCounting(g); g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g); } }; configs.Add(config.key, config); } #if UNITY_EDITOR bool warn_test = false; void Update() { if (!warn_test) { warn_test = true; Debug.LogWarning("F3-重置设备校准引导,规则引导"); Debug.LogWarning("F4-重置新手引导记录"); Debug.LogWarning("F5-新手引导强行下一步"); } if (Input.GetKeyDown(KeyCode.F3)) { Debug.Log("重置设备校准引导,规则引导"); AimHandler.ins.MagCalibrater = new o0._9Axis.MagnetometerAutoCalibrater(); UserSettings.ins.deviceCalibrateGuideFinish = false; UserSettings.ins.gameRuleGuideFinish = new HashSet(); } if (Input.GetKeyDown(KeyCode.F4)) { Debug.Log("重置新手引导记录"); SaveUserGuideFinished(false); } if (Input.GetKeyDown(KeyCode.F5)) { Debug.Log("新手引导强行下一步"); FindObjectOfType()?.OnClick_ToNext(); } } #endif private Dictionary configs = new Dictionary(); private bool configsInited = false; [SerializeField] public string curConfigKey = "模块开机"; private List configKeyList = new List(new string[]{ "模块开机", "连接设备", "弓箭详情", "设备-陀螺仪校准", "陀螺仪校准-开始", "陀螺仪校准-完成", "设备-地磁计校准", "地磁计校准-开始", "地磁计校准-完成", "查看设置", "查看商城", "切换好友/排行榜", "展开好友/排行榜", "联机游戏", "开始游戏", "开始-限时游戏", "限时游戏-选择距离", "视角归位-触发", // "视角归位-瞄准", "准心高亮", "教程结束", }); [ContextMenu("执行当前配置")] void ExecuteCurConfig() { InitConfigs(); NewUserGuiderConfig config = configs[curConfigKey]; NewUserGuider guider = Instantiate(prefab_NewUserGuider).GetComponent(); guider.config = config; } public void OnClickedDestroyed(string configKey) { int nextIndex = configKeyList.IndexOf(configKey) + 1; if (nextIndex >= configKeyList.Count) return; curConfigKey = configKeyList[nextIndex]; ExecuteCurConfig(); } } public class NewUserGuiderConfig { public string key; //0:position,1:anchoredPosition public int hitPosType = 0; public Vector2 hitPos; public bool hitActive = true; //icon pointer rotation z public float pointerRotZ; public int pointerPosType = 0; public Vector2 pointerPos; public bool pointerActive = true; //frameTip-Pivot l:left,r:right,t:top,b:bottom,ct:center public string frameTipPivot = "lt"; public int frameTipPosType = 0; public Vector2 frameTipPos; //frameTip text public string frameTipText = null; public string frameTipTextKey = null; public Action onPrepare; public Action onStart; public bool delayExecute = true; }