| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.UI;
 
- using DG.Tweening;
 
- using UnityEngine.SceneManagement;
 
- /* 游戏帮助界面(右侧方的辅助功能) */
 
- public class GameAssistUI : MonoBehaviour
 
- {
 
-     [SerializeField] Material outlight;
 
-     [SerializeField] Text text1;
 
-     [SerializeField] Text text2;
 
-     Button btnScaleAim;
 
-     Button btnScaleShoot;
 
-     public Action action_OnClickBtnIdentity;
 
-     public static GameAssistUI ins;
 
-     void Awake() {
 
-         ins = this;
 
-     }
 
-     public void onBtnBack() {
 
-         AudioMgr.ins.PlayBtn();
 
-         //如果是从地磁计跳进来的,直接返回到主页
 
-         if (GlobalData.pkMatchType == PKMatchType.None && GameMgr.gameType == 1 && GameMgr.bNavBack)
 
-         {
 
-             GameMgr.bNavBack = false;
 
-             HomeView.bOpenOtherView = true;
 
-             HomeView.openName = "DeviceView";
 
-             SceneManager.LoadScene("Home", LoadSceneMode.Single);
 
-         }
 
-         else {
 
-             GameMgr.ins.userGameAnalyse.showResultView(() => {
 
-                 SceneManager.LoadScene("Home", LoadSceneMode.Single);
 
-             });
 
-         }
 
-        
 
-     }
 
-     void Start()
 
-     {
 
-         this.transform.Find("Button0").GetComponent<Button>().onClick.AddListener(onBtnBack);
 
-         Button guideBtn = this.transform.Find("Button1").GetComponent<Button>();
 
-         btnScaleAim = this.transform.Find("Button2").GetComponent<Button>();
 
-         guideBtn.gameObject.SetActive(!CommonConfig.StandaloneModeOrPlatformB);
 
-         btnScaleAim.gameObject.SetActive(!CommonConfig.StandaloneModeOrPlatformB);
 
-         btnScaleShoot = this.transform.Find("Button3").GetComponent<Button>();
 
-         //枪类型下隐藏
 
-         if (GlobalData.MyDeviceMode == DeviceMode.Gun || CommonConfig.StandaloneModeOrPlatformB)
 
-         {
 
-             btnScaleShoot.gameObject.SetActive(false);
 
-         }
 
-         if (!CommonConfig.StandaloneModeOrPlatformB) 
 
-         { 
 
-             guideBtn.onClick.AddListener(delegate () {
 
-                 AudioMgr.ins.PlayBtn();
 
-                 GameRuleView.Create();
 
-             });
 
-             btnScaleAim.onClick.AddListener(delegate () {
 
-                 AudioMgr.ins.PlayBtn();
 
-                 if (btnScaleAim.GetComponentInChildren<Image>().material == outlight)
 
-                 {
 
-                     closeScaleAim();
 
-                 }
 
-                 else
 
-                 {
 
-                     bool success = openScaleAim();
 
-                     if (!success) ShowOpenScaleAimFailTip();
 
-                 }
 
-             });
 
-             btnScaleShoot.onClick.AddListener(delegate () {
 
-                 AudioMgr.ins.PlayBtn();
 
-                 if (btnScaleShoot.GetComponentInChildren<Image>().material == outlight)
 
-                 {
 
-                     closeScaleShoot();
 
-                 }
 
-                 else
 
-                 {
 
-                     bool success = openScaleShoot();
 
-                     if (!success) ShowOpenScaleShootFailTip();
 
-                 }
 
-             });
 
-         }
 
-       
 
-         Button btnIdentity = this.transform.Find("Button4").GetComponent<Button>();
 
-         if (!CommonConfig.StandaloneModeOrPlatformB)
 
-         {
 
-             //手枪不显示视角归位,连接接红外也不显示视角归位
 
-             if (GlobalData.MyDeviceMode == DeviceMode.Gun || BluetoothAim.ins && BluetoothAim.ins.isMainConnectToInfraredDevice())
 
-             {
 
-                 btnIdentity.gameObject.SetActive(false);
 
-                 //显示控制准心按钮
 
-                 Button crossHairBtn = transform.Find("Button5").GetComponent<Button>();
 
-                 crossHairBtn.gameObject.SetActive(true);
 
-                 //设置准心是否显示
 
-                 if (InfraredDemo._ins) CrossHair.ins.SetOnlyShow(InfraredDemo._ins.getCrosshairValue() == 1);
 
-                 bool onInitOpen = CrossHair.ins.GetOpen() && CrossHair.ins.GetOnlyShow();
 
-                 Image crossHairImage = crossHairBtn.GetComponentInChildren<Image>();
 
-                 crossHairImage.material = onInitOpen ? outlight : null;
 
-                 crossHairBtn.onClick.AddListener(delegate () {
 
-                     AudioMgr.ins.PlayBtn();
 
-                     bool onlyShow = !CrossHair.ins.GetOnlyShow();
 
-                     CrossHair.ins.SetOnlyShow(onlyShow);
 
-                     //保存准心状态
 
-                     if (InfraredDemo._ins) InfraredDemo._ins.setCrosshairValue(onlyShow);
 
-                     if (onlyShow)
 
-                     {
 
-                         crossHairImage.material = outlight;
 
-                     }
 
-                     else
 
-                     {
 
-                         crossHairImage.material = null;
 
-                     }
 
-                 });
 
-                 //校准
 
-                 Button offsetBtn = transform.Find("Button6").GetComponent<Button>();
 
-                 offsetBtn.gameObject.SetActive(true);
 
-                 offsetBtn.onClick.AddListener(delegate () {
 
-                     AudioMgr.ins.PlayBtn();
 
-                     AutoResetView.DoIdentity();
 
-                 });
 
-             }
 
-             else
 
-             {
 
-                 btnIdentity.gameObject.SetActive(true);
 
-                 btnIdentity.onClick.AddListener(delegate () {
 
-                     if (btnIdentity.GetComponent<LongPressMonitor>().isLongPress) return;
 
-                     AudioMgr.ins.PlayBtn();
 
-                     AutoResetView.DoIdentity();
 
-                     action_OnClickBtnIdentity?.Invoke();
 
-                 });
 
-                 btnIdentity.gameObject.AddComponent<LongPressMonitor>().onLongPress += () => {
 
-                     AudioMgr.ins.PlayBtn();
 
-                     if (SB_EventSystem.ins) SB_EventSystem.ins.AwakenSimulateMouse();
 
-                 };
 
-             }
 
-         }
 
-        
 
-         // ------ 查看靶子 ------
 
-         Transform targetView = this.transform.Find("TargetView");
 
-         Button btnViewTarget = this.transform.Find("Button10").GetComponent<Button>();
 
-         btnViewTarget.onClick.AddListener(delegate(){
 
-             AudioMgr.ins.PlayBtn();
 
-             TargetView.ins.ReverseActive();
 
-         });
 
-         if (GameMgr.gameType == 2 || GameMgr.gameType == 9) {
 
-             targetView.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 30);
 
-             btnViewTarget.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 195);
 
-         }
 
-         LoadMyRecord();
 
-         applyPlayerRecordsWhenGameTryAgain();
 
-     }
 
-     void OnDestroy() {
 
-         if (ins == null) ins = null;
 
-         SaveMyRecord();
 
-     }
 
-     void Update() {
 
-         bool autoSwitch = true;
 
-         int myPlayerIndex = GetMyPlayerIndex();
 
-         int curPlayerIndex = GetCurPlayerIndex();
 
-         // if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
 
-         //     if (myPlayerIndex == curPlayerIndex) {
 
-         //         autoSwitch = true;
 
-         //     } else {
 
-         //         autoSwitch = false;
 
-         //         //渲染别人的瞄准镜
 
-         //         DisplayScaleAim(playerScaleAimValue_OnlinePK > 0, playerScaleAimValue_OnlinePK);             
 
-         //     }
 
-         // }
 
-         if (autoSwitch) {
 
-             if (scaleAimOn != playerScaleAimRecords[curPlayerIndex]) {
 
-                 if (playerScaleAimRecords[curPlayerIndex]) {
 
-                     openScaleAim();
 
-                 } else {
 
-                     closeScaleAim();
 
-                 }
 
-             }
 
-             if (scaleShootOn != playerScaleShootRecords[curPlayerIndex]) {
 
-                 if (playerScaleShootRecords[curPlayerIndex]) {
 
-                     openScaleShoot();
 
-                 } else {
 
-                     closeScaleShoot();
 
-                 }
 
-             }
 
-             DisplayScaleAim(scaleAimOn, aimScaleValue);
 
-         }
 
-     }
 
-     // bool IsOnLinePkAndNotMyTime() {
 
-     //     if (GlobalData.pkMatchType != PKMatchType.OnlinePK) return false;
 
-     //     int myPlayerIndex = GetMyPlayerIndex();
 
-     //     int curPlayerIndex = GetCurPlayerIndex();
 
-     //     return myPlayerIndex != curPlayerIndex;
 
-     // }
 
-     [System.NonSerialized] public int playerScaleAimValue_OnlinePK = 0;
 
-     bool[] playerScaleAimRecords = {false, false};
 
-     bool[] playerScaleShootRecords = {false, false};
 
-     int GetMyPlayerIndex() {
 
-         if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
 
-             // return GlobalData.playerIndexInRoom;
 
-             return 0;
 
-         }
 
-         return 0;
 
-     }
 
-     int GetCurPlayerIndex() {
 
-         if (GlobalData.pkMatchType == PKMatchType.OnlinePK) {
 
-             // GameMode gm = GameMgr.ins.gameMode;
 
-             // if (GameMgr.gameType == 9) return ((PKGameMode_OnlinePK) gm).gameLogic.currentPlayerIndex;
 
-             return 0;
 
-         } else if (GlobalData.pkMatchType == PKMatchType.LocalPK) {
 
-             GameMode gm = GameMgr.ins.gameMode;
 
-             if (GameMgr.gameType == 2) return ((PKGameMode) gm).currentPlayerIndex;
 
-             if (GameMgr.gameType == 6) return ((RabbitHuntGameMode_LocalPK) gm).currentPlayerIndex;
 
-             if (GameMgr.gameType == 7) return ((YejiHuntGameMode_LocalPK) gm).currentPlayerIndex;
 
-             if (GameMgr.gameType == 8) return ((WolfHuntGameMode_LocalPK) gm).currentPlayerIndex;
 
-         }
 
-         return 0;
 
-     }
 
-     void SaveMyRecord() {
 
-         int gameType = 0; //多种模式共用记录
 
-         int myPlayerIndex = GetMyPlayerIndex();
 
-         bool isScaleAimOpen = playerScaleAimRecords[myPlayerIndex];
 
-         bool isScaleShootOpen = playerScaleShootRecords[myPlayerIndex];
 
-         PlayerPrefs.SetInt("ScaleAim," + gameType + "," + LoginMgr.myUserInfo.id, isScaleAimOpen ? 1 : 0);
 
-         PlayerPrefs.SetInt("ScaleShoot," + gameType + "," + LoginMgr.myUserInfo.id, isScaleShootOpen ? 1 : 0);
 
-     }
 
-     void LoadMyRecord() {
 
-         int gameType = 0; //多种模式共用记录
 
-         if (CommonConfig.SpecialVersion1) {
 
-             if (PlayerPrefs.GetInt("sv1_ScaleAimShoot," + LoginMgr.myUserInfo.id, 0) == 0) {
 
-                 PlayerPrefs.SetInt("sv1_ScaleAimShoot," + LoginMgr.myUserInfo.id, 1);
 
-                 PlayerPrefs.SetInt("ScaleAim," + gameType + "," + LoginMgr.myUserInfo.id, 0);
 
-                 PlayerPrefs.SetInt("ScaleShoot," + gameType + "," + LoginMgr.myUserInfo.id, 1);
 
-             }
 
-         }
 
-         bool isScaleAimOpen = PlayerPrefs.GetInt("ScaleAim," + gameType + "," + LoginMgr.myUserInfo.id, 0) == 1 ? true : false;
 
-         bool isScaleShootOpen = PlayerPrefs.GetInt("ScaleShoot," + gameType + "," + LoginMgr.myUserInfo.id, 0) == 1 ? true : false;
 
-         if (isScaleAimOpen && GetPropScaleAimValue() == 0) {
 
-             isScaleAimOpen = false;
 
-         }
 
-         if (isScaleShootOpen && getScaleShootProp() == null) {
 
-             isScaleShootOpen = false;
 
-         }
 
-         int myPlayerIndex = GetMyPlayerIndex();
 
-         playerScaleAimRecords[myPlayerIndex] = isScaleAimOpen;
 
-         playerScaleShootRecords[myPlayerIndex] = isScaleShootOpen;
 
-         if (isLocalPK()) {
 
-             playerScaleAimRecords[(myPlayerIndex + 1) % 2] = isScaleAimOpen;
 
-             playerScaleShootRecords[(myPlayerIndex + 1) % 2] = isScaleShootOpen;
 
-         }
 
-     }
 
-     #region 本地双人PK,再来时保存记录
 
-         private static bool[] playerRecords = null; 
 
-         private bool isLocalPK() {
 
-             int[] gameTypes = {2, 6, 7, 8};
 
-             if (System.Array.IndexOf(gameTypes, GameMgr.gameType) > -1) {
 
-                 return true;
 
-             }
 
-             return false;
 
-         }
 
-         public void recordPlayerRecordsWhenGameTryAgain() {
 
-             if (!isLocalPK()) return;
 
-             playerRecords = new bool[] {
 
-                 playerScaleAimRecords[0], playerScaleAimRecords[1],  
 
-                 playerScaleShootRecords[0], playerScaleShootRecords[1]  
 
-             };
 
-         }
 
-         private void applyPlayerRecordsWhenGameTryAgain() {
 
-             if (playerRecords != null) {
 
-                 playerScaleAimRecords[0] = playerRecords[0];
 
-                 playerScaleAimRecords[1] = playerRecords[1];
 
-                 playerScaleShootRecords[0] = playerRecords[2];
 
-                 playerScaleShootRecords[1] = playerRecords[3];
 
-                 playerRecords = null;
 
-             }
 
-         }
 
-     #endregion
 
-     #region 道具开关监听
 
-         private void onOpenScaleAimSuccess() {
 
-             playerScaleAimRecords[GetCurPlayerIndex()] = true;
 
-         }
 
-         private void onCloseScaleAimSuccess() {
 
-             playerScaleAimRecords[GetCurPlayerIndex()] = false;
 
-         }
 
-         private void onOpenScaleShootSuccess() {
 
-             playerScaleShootRecords[GetCurPlayerIndex()] = true;
 
-         }
 
-         private void onCloseScaleShootSuccess() {
 
-             playerScaleShootRecords[GetCurPlayerIndex()] = false;
 
-         }
 
-     #endregion
 
-     
 
-     // ------ 开镜瞄准功能 ------
 
-     [System.NonSerialized] public int aimScaleValue = 1;
 
-     float[] scaleAimFieldOfViews = {30, 20, 12, 6, 3};
 
-     float[] scaleAimScopeScales = {150, 98, 58, 29, 14.5f};
 
-     Sequence seq1 = null;
 
-     [System.NonSerialized] public bool scaleAimOn = false; //该功能是否处于打开状态
 
-     bool openScaleAim()
 
-     {   
 
-         int scaleValue = GetPropScaleAimValue();
 
-         if (scaleValue > 0) 
 
-         {
 
-             btnScaleAim.GetComponentInChildren<Image>().material = outlight;
 
-             aimScaleValue = scaleValue;
 
-             scaleAimOn = true;
 
-             onOpenScaleAimSuccess();
 
-             return true;
 
-         }
 
-         return false;
 
-     }
 
-     bool isScaleAimDisplaying = false;
 
-     int aimScaleDisplayValue = -1;
 
-     void DisplayScaleAim(bool open, int scaleValue) { //渲染
 
-         if (isScaleAimDisplaying == open && aimScaleDisplayValue == scaleValue) return;
 
-         isScaleAimDisplaying = open;
 
-         aimScaleDisplayValue = scaleValue;
 
-         BowCamera bowCamera = BowCamera.ins;
 
-         Transform scope = bowCamera.transform.Find("Scope");
 
-         if (open)
 
-         {
 
-             if (GlobalData.MyDeviceMode == DeviceMode.Gun)
 
-                 CrossHair.ins.gameObject.GetComponent<SwitchCrossHair>().ShowOldImage(true);
 
-             CrossHair.ins.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(500, 500);
 
-         }
 
-         else {
 
-             if (GlobalData.MyDeviceMode == DeviceMode.Gun)
 
-             {
 
-                 SwitchCrossHair switchCrossHair = CrossHair.ins.gameObject.GetComponent<SwitchCrossHair>();
 
-                 switchCrossHair.ShowOldImage(false);
 
-                 CrossHair.ins.gameObject.GetComponent<RectTransform>().sizeDelta = switchCrossHair.targetImageSize;
 
-             }
 
-             else {
 
-                 CrossHair.ins.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(260, 260);
 
-             }
 
-         }
 
-    
 
-         if (open) CrossHair.ins.transform.localPosition = Vector3.zero;
 
-         bowCamera.banCameraFieldOfView = open;
 
-         bowCamera.SetScaleAimDisplaying(isScaleAimDisplaying);
 
-         if (open) {
 
-             bowCamera.SetCameraFieldOfView(scaleAimFieldOfViews[scaleValue - 1]);
 
-         }
 
-         Vector3 localPosition = ArmBow.ins.transform.localPosition;
 
-         localPosition.z = open ? -2 : ArmBow.localPosZ;
 
-         ArmBow.ins.transform.localPosition = localPosition;
 
-         
 
-         if (open) {
 
-             float scopeScale = scaleAimScopeScales[scaleValue - 1];
 
-             scope.localScale = new Vector3(scopeScale, scopeScale, scopeScale);
 
-         } else {
 
-             scope.localScale = new Vector3(0, 0, 0);
 
-         }   
 
-     }
 
-     void ShowOpenScaleAimFailTip() {
 
-         if (seq1 != null && !seq1.IsComplete()) {
 
-             seq1.Complete();
 
-         }
 
-         seq1 = DOTween.Sequence();
 
-         seq1.Append(text1.DOFade(1, 0.5f));
 
-         seq1.AppendInterval(2);
 
-         seq1.Append(text1.DOFade(0, 0.5f));
 
-     }
 
-     void closeScaleAim()
 
-     {
 
-         btnScaleAim.GetComponentInChildren<Image>().material = null;
 
-         scaleAimOn = false;
 
-         onCloseScaleAimSuccess();
 
-     }
 
-     int GetPropScaleAimValue()
 
-     {
 
-         List<PropInfo> props = PropMgr.ins.ListForEquipped();
 
-         foreach (var prop in props)
 
-         {
 
-             if (prop.config.type == 1) {
 
-                 PropScaleAim config = prop.config as PropScaleAim;
 
-                 return config.scaleValue;
 
-             }
 
-         }
 
-         return 0;
 
-     }
 
-     // ------ 发射加速功能 ------
 
-     [System.NonSerialized] public int shootScaleValue = 1;
 
-     Sequence seq2 = null;
 
-     bool scaleShootOn = false; //该功能是否处于打开状态
 
-     bool openScaleShoot()
 
-     {   
 
-         PropInfo prop = getScaleShootProp();
 
-         if (prop != null) {
 
-             btnScaleShoot.GetComponentInChildren<Image>().material = outlight;
 
-             PropScaleShoot config = prop.config as PropScaleShoot;
 
-             shootScaleValue = config.scaleValue;
 
-             scaleShootOn = true;
 
-             onOpenScaleShootSuccess();
 
-             return true;
 
-         }
 
-         return false;
 
-     }
 
-     void ShowOpenScaleShootFailTip() {
 
-         if (seq2 != null && !seq2.IsComplete()) {
 
-             seq2.Complete();
 
-         }
 
-         seq2 = DOTween.Sequence();
 
-         seq2.Append(text2.DOFade(1, 0.5f));
 
-         seq2.AppendInterval(2);
 
-         seq2.Append(text2.DOFade(0, 0.5f));
 
-     }
 
-     void closeScaleShoot()
 
-     {
 
-         btnScaleShoot.GetComponentInChildren<Image>().material = null;
 
-         shootScaleValue = 1;
 
-         scaleShootOn = false;
 
-         onCloseScaleShootSuccess();
 
-     }
 
-     PropInfo getScaleShootProp() {
 
-         List<PropInfo> props = PropMgr.ins.ListForEquipped();
 
-         foreach (var prop in props)
 
-         {
 
-             if (prop.config.type == 2) {
 
-                 return prop;
 
-             }
 
-         }
 
-         return null;
 
-     }
 
- }
 
 
  |