| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- using JCUnityLib;
- public class NewUserGuiderManager : MonoBehaviour
- {
- [SerializeField] GameObject prefab_NewUserGuider;
- [SerializeField] GameObject prefab_InfraredGuider;
- 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 (CommonConfig.StandaloneMode)
- {
- configKeyList.Remove("切换好友/排行榜");
- configKeyList.Remove("展开好友/排行榜");
- configKeyList.Remove("联机游戏");
- }
- }
- 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;
- case "视角归位-触发":
- configKeyList.Remove("教程结束");
- ExecuteCurConfig();
- break;
- case "开始-红外调整":
- if (PlayerPrefs.GetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 0) == 1) {
- PlayerPrefs.SetInt("entry-guider-infrared-" + LoginMgr.myUserInfo.id, 2);
- onInitInfraredGuider();
- }
-
- break;
- }
- }
- }
- public void OnSkip()
- {
- curConfigKey = null;
- isNewModule = false;
- LoginMgr.myUserInfo.SaveGuideFinish(0);
- }
- public void OnEnd()
- {
- curConfigKey = null;
- isNewModule = false;
- LoginMgr.myUserInfo.SaveGuideFinish(0);
- }
- public void ReviewNewUserGuide()
- {
- int viewCount = PersistenHandler.ins.menuBackCtr.views.Count;
- for (int i = 0; i < viewCount; i++) {
- PersistenHandler.ins.menuBackCtr.OnOnceBack();
- }
- foreach (var item in FindObjectsOfType<NewUserGuider>()) Destroy(item);
- curConfigKey = "投屏建议";
- ExecuteCurConfig();
- LoginMgr.myUserInfo.SaveGuideFinish(0);
- }
-
- void InitConfigs()
- {
- if (configsInited) return;
- configsInited = true;
- NewUserGuiderConfig 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().RemoveAllListeners();
- g.ActiveBtnSkip(false);
- RectTransform btnOK = g.transform.Find("BtnOK") as RectTransform;
- btnOK.anchoredPosition = new Vector2(0, -250);
- if (TextAutoLanguage2.GetLanguage() == LanguageEnum.English) {
- btnOK.anchoredPosition = new Vector2(0, -300);
- g.FixFrameTipWidth(1200);
- g.frameTip.anchoredPosition += Vector2.up * 20;
- }
- btnOK.GetComponent<Button>().onClick.AddListener(() => g.OnClick_ToNext());
- btnOK.gameObject.SetActive(true);
- };
- configs.Add(config.key, config);
- 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/RenderBow/BtnConnectBLE").GetComponent<RectTransform>();
- 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<bool> 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/RenderBow/BtnShowDetail").GetComponent<RectTransform>();
- 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 += () => {
- HomeView.ins.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 (!DeviceViewInfrared.ins) {
- g.customPreparePass = false;
- return;
- }
- g.customPreparePass = true;
- RectTransform btn = DeviceViewInfrared.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();
- };
- DeviceViewInfrared.ins.action_OnClickGyr += onclickTarget;
- g.action_OnDestroy += () => DeviceViewInfrared.ins.action_OnClickGyr -= onclickTarget;
- //渲染模型
- RectTransform md = g.transform.Find("ImageRenderModule") as RectTransform;
- md.Find("Plane").gameObject.SetActive(true);
- md.Find("Module2").gameObject.SetActive(true);
- md.gameObject.SetActive(true);
- md.anchoredPosition += Vector2.up * 30;
- };
- 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<Canvas>().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<bool> 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<Canvas>().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 = "rb";
- config.onPrepare = (g) => {
- if (!DeviceViewInfrared.ins) {
- g.customPreparePass = false;
- return;
- }
- g.customPreparePass = true;
- RectTransform btn = DeviceViewInfrared.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 = 210;
- g.config.pointerPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0.3f, -1));
- g.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(-0.1f, 0))
- + RectTransformUtils.CanvasV3ToScreenV3(Vector3.down * 220f, g.iconPointer);
- g.FixFrameTipWidth(930);
- };
- config.onStart = (g) => {
- g.GetMaskClickedEvent().RemoveAllListeners();
- Action onclickTarget = () => {
- g.clickedWillPlayAudioBtn = false;
- g.OnClick_ToNext();
- };
- DeviceViewInfrared.ins.action_OnClickMag += onclickTarget;
- g.action_OnDestroy += () => DeviceViewInfrared.ins.action_OnClickMag -= onclickTarget;
- //渲染模型
- RectTransform md = g.transform.Find("ImageRenderModule") as RectTransform;
- md.Find("Module").gameObject.SetActive(true);
- md.gameObject.SetActive(true);
- if (TextAutoLanguage2.GetLanguage() == LanguageEnum.English) md.anchoredPosition += Vector2.up * 220;
- else md.anchoredPosition += Vector2.up * 50;
- RenderModuleCamera.Load();
- RenderModuleCamera.ins.SetMode(1);
- g.action_OnDestroy += () => RenderModuleCamera.Unload();
- };
- 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<Canvas>().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<bool> 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 = "rb";
- // config.frameTipText = "";
- config.onPrepare = (g) => {
- g.SetCanvasSortOrder(DeviceCalibrateView.ins.GetComponent<Canvas>().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.config.frameTipPos = RectTransformUtils.GetPositionByPivot(btn, new Vector2(0, 1))
- + RectTransformUtils.CanvasV3ToScreenV3(Vector3.left * 100 + Vector3.up * 50f, g.iconPointer);
- g.FixFrameTipWidth(700);
- g.SetMaskOpacity(0.7f);
- };
- config.onStart = (g) => {
- g.GetMaskClickedEvent().RemoveAllListeners();
- Action operateFinished = () => {
- FindObjectOfType<DeviceViewInfrared>()?.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<RectTransform>();
- 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<RectTransform>();
- 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/IconGuider").GetComponent<RectTransform>();
- 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<RectTransform>();
- 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<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 = -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<RectTransform>();
- 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<RectTransform>();
- 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.Find("Layout") 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);
- //2023-3-29-new
- config = new NewUserGuiderConfig();
- config.key = "视角归位-触发";
- config.hitPosType = 1;
- //new Vector2(-150,-21)
- config.hitPos = isNewModule ? new Vector2(-150, -21) : new Vector2(-138.9f, -212);
- config.pointerRotZ = 120;
- config.pointerPosType = 1;
- config.pointerPos = isNewModule? new Vector2(-205, 0) : new Vector2(-205, -154);
- config.frameTipPivot = "lc";
- config.frameTipPosType = 1;
- config.frameTipPos = new Vector2(0, 0);
- config.onPrepare = (g) => {
- RectTransform iconHumanShoot = g.transform.Find("IconHumanShoot") as RectTransform;
- iconHumanShoot.pivot = Vector2.one * 0.5f;
- iconHumanShoot.anchoredPosition = new Vector2(-434, -85);
- iconHumanShoot.gameObject.SetActive(true);
- string moduleName = isNewModule ? "IconModule_artemis" : "IconModule";
- RectTransform iconModule = g.transform.Find(moduleName) as RectTransform;
- iconModule.anchoredPosition = new Vector2(-146, -39);
- iconModule.gameObject.SetActive(true);
- g.SetIconPointerHitOpacity(0.1f);
- GameMode gameMode = GameMgr.ins.gameMode;
- if (gameMode.GetType().Equals(typeof(TimeLimitGameMode))) {
- gameMode.PauseTimeCounting(g);
- g.action_OnDestroy += () => gameMode.ResumeTimeCounting(g);
- }
-
- Action onClickTarget = () => {
- if (!g.gameObject.activeSelf) return;
- g.gameObject.SetActive(false);
- AutoResetView.ins.action_OnDestroy += () => {
- if (!g) return;
- g.clickedWillPlayAudioBtn = false;
- g.OnClick_ToNext();
- };
- };
- AutoResetView.onInstantiate += onClickTarget;
- g.action_OnDestroy += () => AutoResetView.onInstantiate -= onClickTarget;
- };
- config.onStart = (g) => {
- g.GetMaskClickedEvent().RemoveAllListeners();
- };
- 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<RectTransform>()).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.hitActive = false;
- config.pointerActive = false;
- //config.frameTipText = "";
- config.frameTipPivot = "ct";
- config.frameTipPosType = 1;
- config.frameTipPos = new Vector2(-400, 0);
- 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");
- RectTransform crossHairLight = g.transform.Find("CrossHair-Light") as RectTransform;
- crossHairLight.gameObject.SetActive(true);
- Action a_hitTarget = () => {
- g.clickedWillPlayAudioBtn = false;
- g.OnClick_ToNext();
- };
- if (gameMode.GetType().Equals(typeof(TimeLimitGameMode)) && !GameMgr.bShowDistance)
- {
- //如果是地磁计进入后的射箭
- TimeLimitGameMode timeLimitGameMode = (TimeLimitGameMode)gameMode;
- timeLimitGameMode.onHitTargetEvent += a_hitTarget;
- g.action_OnDestroy += () => timeLimitGameMode.onHitTargetEvent -= a_hitTarget;
- }
- 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 = JCUnityLib.RectTransformUtils.ScreenV3ToCanvasV3(Vector3.one * sizeLen, iconRect);
- g.hollowOutMask.RefreshViewImmediate();
- if (!(gameMode.GetType().Equals(typeof(TimeLimitGameMode)) && !GameMgr.bShowDistance))
- {
- countDown -= Time.deltaTime;
- if (countDown <= 0)
- {
- g.clickedWillPlayAudioBtn = false;
- g.OnClick_ToNext();
- }
- }
- };
- Action a_updateCrossHair = () => {
- crossHairLight.position = CrossHair.ins.transform.position;
- };
- CrossHair.ins.action_UpdatePostionWhenFixedCamera += a_updateCrossHair;
- g.action_OnDestroy += () => {
- if (CrossHair.ins) CrossHair.ins.action_UpdatePostionWhenFixedCamera -= a_updateCrossHair;
- };
- };
- 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.ResetMag();
- UserSettings.ins.deviceCalibrateGuideFinish = false;
- UserSettings.ins.gameRuleGuideFinish = new HashSet<int>();
- }
- if (Input.GetKeyDown(KeyCode.F4)) {
- Debug.Log("重置新手引导记录");
- LoginMgr.myUserInfo.SaveGuideFinish(0);
- }
- if (Input.GetKeyDown(KeyCode.F5)) {
- Debug.Log("新手引导强行下一步");
- FindObjectOfType<NewUserGuider>()?.OnClick_ToNext();
- }
- }
- #endif
- private Dictionary<string, NewUserGuiderConfig> configs = new Dictionary<string, NewUserGuiderConfig>();
- private bool configsInited = false;
- [SerializeField] public string curConfigKey = "投屏建议";
- public bool isNewModule = false;
- private List<string> configKeyList = new List<string>(new string[]{
- "投屏建议",
- "模块开机",
- "连接设备",
- "弓箭详情",
- "设备-陀螺仪校准",
- "陀螺仪校准-开始",
- "陀螺仪校准-完成",
- "设备-地磁计校准",
- "地磁计校准-开始",
- "地磁计校准-完成",
- "查看设置",
- "查看商城",
- "查看新手指导",
- "切换好友/排行榜",
- "展开好友/排行榜",
- "联机游戏",
- "开始游戏",
- "开始-限时游戏",
- "限时游戏-选择距离",
- "视角归位-触发",
- // "视角归位-瞄准",
- "准心高亮",
- "教程结束"
- });
- [ContextMenu("执行当前配置")]
- void ExecuteCurConfig() {
- InitConfigs();
- NewUserGuiderConfig config = configs[curConfigKey];
- NewUserGuider guider = Instantiate(prefab_NewUserGuider).GetComponent<NewUserGuider>();
- guider.config = config;
- }
- public void OnClickedDestroyed(string configKey) {
- int nextIndex = configKeyList.IndexOf(configKey) + 1;
- if (nextIndex >= configKeyList.Count) return;
- curConfigKey = configKeyList[nextIndex];
- ExecuteCurConfig();
- }
- //红外测试部分
- void onInitInfraredGuider() {
- Instantiate(prefab_InfraredGuider);
- }
- }
- 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<NewUserGuider> onPrepare;
- public Action<NewUserGuider> onStart;
- public bool delayExecute = true;
- }
|