| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.UI;
 
- using UnityEngine.SceneManagement;
 
- /*
 
- 按下自动校准键出现倒计时3秒,同时伴有文字提示用户“三秒后即将开始校准,
 
- 请扶稳弓箭。”倒计时3秒后出现一个进度条也是三秒,用户在3秒内自己尽量扶稳弓即可,
 
- 进度条完成后,取一个平均值作为校准值。
 
- */
 
- public class AutoResetView : MonoBehaviour
 
- {
 
-     public static AutoResetView ins;
 
-     public static Action onInstantiate;
 
-     public static void DoIdentity() {
 
-         //if (InfraredDemo.running) return;
 
-         if (SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked) return;
 
-         if (SceneManager.GetActiveScene().name.StartsWith("GameDouble"))
 
-         {
 
-             if (GameObject.Find("AutoResetViewNewLeft")) return;
 
-             GameObject resetView = Instantiate(Resources.Load<GameObject>("AutoResetViewNew"));
 
-             resetView.name = "AutoResetViewNewLeft";
 
-             AutoResetViewNew autoResetViewNewScript = resetView.GetComponent<AutoResetViewNew>();
 
-             autoResetViewNewScript.setPosLeft();
 
-             autoResetViewNewScript.action_OnDestroy += () =>
 
-             {
 
-                 //使用旧模式重置1p
 
-                 AimHandler.ins?.DoIdentity();
 
-             };
 
-         }
 
-         else if (SceneManager.GetActiveScene().name.StartsWith("Game"))
 
-         {
 
-             Instantiate(Resources.Load<GameObject>("Prefabs/Views/AutoResetView"));
 
-         }
 
-         else if (SceneManager.GetActiveScene().name.StartsWith("DuckHunter"))
 
-         {
 
-             Instantiate(Resources.Load<GameObject>("Prefabs/Views/AutoResetView"));
 
-         }
 
-         else if (SceneManager.GetActiveScene().name.StartsWith("WildAttack"))
 
-         {
 
-             Instantiate(Resources.Load<GameObject>("Prefabs/Views/AutoResetView"));
 
-         }
 
-         else if (SceneManager.GetActiveScene().name.StartsWith("FruitMaster"))
 
-         {
 
-             Instantiate(Resources.Load<GameObject>("Prefabs/Views/AutoResetView"));
 
-         }
 
-         else if (SceneManager.GetActiveScene().name.StartsWith("Hyperspace")) {
 
-             //Hyperspace01 Hyperspace02 Hyperspace03
 
-             Instantiate(Resources.Load<GameObject>("Prefabs/Views/AutoResetView"));
 
-         }
 
-         else
 
-         {
 
-             AimHandler.ins.DoIdentity();
 
-         }
 
-     }
 
-     /// <summary>
 
-     /// 引导页面弹出校准
 
-     /// </summary>
 
-     public static void onInfraredGuiderAutoResetView() {
 
-         CreateResetViewPath("Prefabs/Views/AutoResetView");
 
-     }
 
-     /// <summary>
 
-     /// 带背景的校准
 
-     /// </summary>
 
-     public static void onInfraredGuiderAutoResetViewOrBg()
 
-     {
 
-         CreateResetViewPath("Prefabs/Views/AutoResetViewOrBg");
 
-     }
 
-     static void CreateResetViewPath(string path) {
 
-         AutoResetView autoResetView = Instantiate(Resources.Load<GameObject>(path)).GetComponent<AutoResetView>();
 
-         autoResetView.bInfraredGuider = true;
 
-         autoResetView.infraredGuiderTime = GlobalData.MyDeviceMode == DeviceMode.Gun ? CommonConfig.calibrationTimeGun : CommonConfig.calibrationTimeArchery;
 
-     }
 
-     /// <summary>
 
-     /// 是否是引导
 
-     /// </summary>
 
-     public bool bInfraredGuider = false;
 
-     public float infraredGuiderTime = 10;
 
-     void Awake() {
 
-         if (ins) {
 
-             Destroy(gameObject);
 
-             return;
 
-         }
 
-         ins = this;
 
-     }
 
-     void Start() {
 
-         //进入引导游戏场景时候,设置时间
 
-         if (bInfraredGuider)
 
-         {
 
-             prepareTime = infraredGuiderTime;
 
-         }
 
-         else {
 
-             prepareTime = UserSettings.ins.calibrationTime;
 
-         }
 
-         Debug.Log("弓箭重置时间:" + prepareTime);
 
-         if (SceneManager.GetActiveScene().name == "Game") {
 
-             (transform.Find("IconHumanShoot") as RectTransform).anchoredPosition = new Vector2(-193, -85);
 
-         }
 
-         GetGuideTip().textFormatArgs = new object[]{showedPrepareTime = Mathf.CeilToInt(prepareTime)};
 
-         GetGuideTip().ApplyToText();
 
-         ChallengeTargetForResetView.Show();
 
-         onInstantiate?.Invoke();
 
-     }
 
-     public Action action_OnDestroy;
 
-     void OnDestroy() {
 
-         if (ins == this) ins = null;
 
-         action_OnDestroy?.Invoke();
 
-     }
 
-     float prepareTime = 3;
 
-     int showedPrepareTime;
 
-     bool bEnd = false;
 
-     void Update() {
 
-         // 使用 unscaledDeltaTime 代替 deltaTime
 
-         prepareTime -= Time.unscaledDeltaTime;//Time.deltaTime;
 
-         if (prepareTime <= 0) {
 
-             //防止多次调用
 
-             if (bEnd) return;
 
-             bEnd = true;
 
-             
 
-             try {
 
-                 if (SceneManager.GetActiveScene().name.StartsWith("WildAttack"))
 
-                 {
 
-                     WildAttack.GameMananger.GetInstance().ResetAim();
 
-                 }
 
-                 else
 
-                 {
 
-                     if (AimHandler.ins.bRuning9Axis())
 
-                     {
 
-                         AimHandler.ins.DoIdentity();
 
-                     }
 
-                     else
 
-                     {
 
-                         //红外设备校准偏离点
 
-                         InfraredDemo._ins?.OnClick_SetAdjustPointsOffset();
 
-                     }
 
-                 }
 
-             }
 
-             catch (Exception) {}
 
-             //先隐藏子物体
 
-             foreach (Transform child in transform)
 
-             {
 
-                 child.gameObject.SetActive(false);
 
-             }
 
-             Destroy(gameObject,2.0f);
 
-         } else {
 
-             int curTime = Mathf.CeilToInt(prepareTime);
 
-             if (showedPrepareTime != curTime) {
 
-                 showedPrepareTime = curTime;
 
-                 TextAutoLanguage2 gt = GetGuideTip();
 
-                 gt.textFormatArgs[0] = Mathf.CeilToInt(prepareTime);
 
-                 gt.ApplyToText();
 
-             }
 
-         }
 
-     }
 
-     TextAutoLanguage2 _guideTip;
 
-     TextAutoLanguage2 GetGuideTip() {
 
-         if (_guideTip == null) {
 
-             if (AimHandler.ins.bRuning9Axis())
 
-             {
 
-                 Transform text = transform.Find("FrameTip/Text");
 
-                 text.gameObject.SetActive(true);
 
-                 _guideTip = text.GetComponentInChildren<TextAutoLanguage2>();
 
-             }
 
-             else {
 
-                 if (GlobalData.MyDeviceMode == DeviceMode.Gun)
 
-                 {
 
-                     Transform textInfrared = transform.Find("FrameTip/Text-Infrared-Gun");
 
-                     textInfrared.gameObject.SetActive(true);
 
-                     _guideTip = textInfrared.GetComponentInChildren<TextAutoLanguage2>();
 
-                 }
 
-                 else {
 
-                     Transform textInfrared = transform.Find("FrameTip/Text-Infrared");
 
-                     textInfrared.gameObject.SetActive(true);
 
-                     _guideTip = textInfrared.GetComponentInChildren<TextAutoLanguage2>();
 
-                 }
 
-              
 
-             }
 
-              
 
-         }
 
-         return _guideTip;
 
-     }
 
- }
 
 
  |