| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419 | 
							- using System;
 
- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.UI;
 
- namespace WildAttack
 
- {
 
-     public class MainPanel : MonoBehaviour
 
-     {
 
-         #region Members
 
-         [SerializeField] Button _btnConnect;
 
-         [SerializeField] Text textMacAddress;
 
-         [SerializeField] Text textBattery;
 
-         [SerializeField] Button _btnCalibrateGyr;
 
-         [SerializeField] Button _btnCalibrateMag;
 
-         [SerializeField] Button _btnResetAim;
 
-         [SerializeField] Button _btnCalibrationOffset;
 
-         [SerializeField] Button _btnStartRotationSensor;
 
-         [SerializeField] Button _btnStopRotationSensor;
 
-         [SerializeField] Button _btnStartShootingSensor;
 
-         [SerializeField] Button _btnStopShootingSensor;
 
-         [SerializeField] Button _btnChangeShootType;
 
-         [SerializeField] InputField _inputFieldGameID;
 
-         [SerializeField] InputField _inputFieldChannelID;
 
-         [SerializeField] InputField _inputFieldUsername;
 
-         [SerializeField] InputField _inputFieldPassword;
 
-         [SerializeField] Button _btnLogin;
 
-         [SerializeField] Button _btnLogout;
 
-         [SerializeField] Button _btnGetUserInfo;
 
-         [SerializeField] Image _imgAvatar;
 
-         [SerializeField] Text _textNickname;
 
-         [SerializeField] Text _textGender;
 
-         [SerializeField] Text btnConnectText;
 
-         [SerializeField] GameObject _processObj;
 
-         [SerializeField] Text _textProcessTitle;
 
-         [SerializeField] Text _textProcess;
 
-         [SerializeField] Text _textEnemy;
 
-         [SerializeField] Text _textHighScore;
 
-         [SerializeField] Text _textHpBarTitle;
 
-         [SerializeField] Button _btnQuit;
 
-         //用户信息
 
-         [SerializeField] Image _imgUserAvatar;
 
-         [SerializeField] Text _textUserNickname;
 
-         [SerializeField] Text _textUserRecordScore;
 
-         public Action onQuitCallback;
 
-         #endregion
 
-         #region Lifecycle
 
-         // Start is called before the first frame update
 
-         void Start()
 
-         {
 
-             btnConnectText.text = "<color=blue>未连接</color>(点击连接)";
 
-             _textHighScore.text = StringModule.GetInstance().GetData("highScore") + ":";
 
-             textBattery.color = new Color(1, 1, 1, 0);
 
-             textMacAddress.color = new Color(1, 1, 1, 0);
 
-             _textProcessTitle.text = StringModule.GetInstance().GetData("wave") + ":";
 
-             Transform wall = GameObject.Find("Wall").transform;
 
-             var wallScreenPos = Camera.main.WorldToScreenPoint(wall.position);
 
-             RegistEvent();
 
-             _btnResetAim.GetComponentInChildren<Text>().text = StringModule.GetInstance().GetData("resetAim");
 
-             RenderUserInfo();
 
-         }
 
-         public void RenderUserInfo()
 
-         {
 
-             RoleMgr.SetAvatarToImage(
 
-                 _imgUserAvatar,
 
-                 LoginMgr.myUserInfo.avatarID, LoginMgr.myUserInfo.avatarUrl
 
-             );
 
-             _textUserNickname.text = LoginMgr.myUserInfo.nickname + "  ";
 
-             float recordScore = 0;
 
-             if (LoginMgr.myUserInfo.timeLimitGameScores.ContainsKey("WildAttack"))
 
-             {
 
-                 recordScore = LoginMgr.myUserInfo.timeLimitGameScores["WildAttack"];
 
-             }
 
-             _textUserRecordScore.text = recordScore.ToString();
 
-         }
 
-         // Update is called once per frame
 
-         void Update()
 
-         {
 
-             UpdateProcess();
 
-             ////更新显示陀螺仪校准文本
 
-             //UpdateCalibrateGyrText();
 
-             ////更新显示地磁计校准文本
 
-             //UpdateCalibrateMagText();
 
-         }
 
-         #endregion
 
-         #region ButtonClickEvent
 
-         void RegistEvent()
 
-         {
 
-             // SDK
 
-             //SmartBowHelper.GetInstance().OnBluetoothModuleInited += OnBluetoothModuleInited;
 
-             //SmartBowHelper.GetInstance().OnBluetoothStatusChanged += OnBluetoothStatusChanged;
 
-             // SDK相关btn
 
-             //_btnConnect.onClick.AddListener(OnClick_Connect);
 
-             //_btnCalibrateGyr.onClick.AddListener(OnClick_CalibrateGyr);
 
-             //_btnCalibrateMag.onClick.AddListener(OnClick_CalibrateMag);
 
-             if (CommonConfig.StandaloneModeOrPlatformB)
 
-             {
 
-                 _btnResetAim.gameObject.SetActive(false);
 
-             }
 
-             else {
 
-                 if (BluetoothAim.ins && BluetoothAim.ins.isMainConnectToInfraredDevice())
 
-                 {
 
-                     _btnResetAim.gameObject.SetActive(false);
 
-                     //校准
 
-                     _btnCalibrationOffset.gameObject.SetActive(true);
 
-                     _btnCalibrationOffset.onClick.AddListener(delegate () {
 
-                         AudioMgr.ins.PlayBtn();
 
-                         OnClick_ResetAim();
 
-                     });
 
-                 }
 
-                 else
 
-                 {
 
-                     _btnResetAim.onClick.AddListener(() => {
 
-                         if (_btnResetAim.GetComponent<LongPressMonitor>().isLongPress) return;
 
-                         OnClick_ResetAim();
 
-                     });
 
-                     _btnResetAim.gameObject.AddComponent<LongPressMonitor>().onLongPress += () =>
 
-                     {
 
-                         AudioMgr.ins?.PlayBtn();
 
-                         if (SB_EventSystem.ins) SB_EventSystem.ins.AwakenSimulateMouse();
 
-                     };
 
-                 }
 
-             }
 
-   
 
-             //_btnStopRotationSensor.onClick.AddListener(OnClick_StopRotationSensor);
 
-             //_btnStopShootingSensor.onClick.AddListener(OnClick_StopShootingSensor);
 
-             //_btnLogin.onClick.AddListener(OnClick_Login);
 
-             //_btnLogout.onClick.AddListener(OnClick_Logout);
 
-             //_btnGetUserInfo.onClick.AddListener(OnClick_GetUserInfo);
 
-             _btnQuit.onClick.AddListener(OnClick_Quit);
 
-         }
 
-         /// <summary>
 
-         /// 退出游戏
 
-         /// </summary>
 
-         private void OnClick_Quit()
 
-         {
 
-             //#if UNITY_EDITOR
 
-             //            UnityEditor.EditorApplication.isPlaying = false;
 
-             //#else
 
-             //        Application.Quit();
 
-             //#endif
 
-             AudioMgr.ins.PlayBtn();
 
-             //UnityEngine.SceneManagement.SceneManager.LoadScene("Home", UnityEngine.SceneManagement.LoadSceneMode.Single);
 
-             onQuitCallback?.Invoke();
 
-         }
 
-         //public void OnClick_Connect()
 
-         //{
 
-         //    if (SmartBowHelper.GetInstance().GetBluetoothStatus() == BluetoothStatusEnum.Connecting) return;
 
-         //    if (SmartBowHelper.GetInstance().GetBluetoothStatus() == BluetoothStatusEnum.None)
 
-         //    {
 
-         //        SmartBowHelper.GetInstance().Connect();
 
-         //        return;
 
-         //    }
 
-         //    if (SmartBowHelper.GetInstance().GetBluetoothStatus() == BluetoothStatusEnum.Connected)
 
-         //    {
 
-         //        if (SmartBowHelper.GetInstance().IsBluetoothModuleInited())
 
-         //        {
 
-         //            SmartBowHelper.GetInstance().Disconnect();
 
-         //            return;
 
-         //        }
 
-         //        else
 
-         //        {
 
-         //            return;
 
-         //        }
 
-         //    }
 
-         //}
 
-         //public void OnClick_CalibrateGyr()
 
-         //{
 
-         //    if (SmartBowHelper.GetInstance().GetBluetoothStatus() != BluetoothStatusEnum.Connected
 
-         //        || !SmartBowHelper.GetInstance().IsBluetoothModuleInited()) return;
 
-         //    if (SmartBowHelper.GetInstance().IsGyrCalibrating())
 
-         //    {
 
-         //        SmartBowHelper.GetInstance().StopGyrCalibration();
 
-         //    }
 
-         //    else
 
-         //    {
 
-         //        SmartBowHelper.GetInstance().StartGyrCalibration();
 
-         //    }
 
-         //}
 
-         ///// <summary>
 
-         ///// 地磁计校准
 
-         ///// </summary>
 
-         //float _clickCalibrateMagTime = -100;
 
-         //public void OnClick_CalibrateMag()
 
-         //{
 
-         //    _clickCalibrateMagTime = Time.realtimeSinceStartup;
 
-         //    SmartBowHelper.GetInstance().StartMagCalibration();
 
-         //}
 
-         ////private bool isResetAim = false;
 
-         public void OnClick_ResetAim()
 
-         {
 
-             // todo: 不连接时 归位正中间
 
-             //       UI改回1280 归位按钮放大
 
-             AudioMgr.ins.PlayBtn();
 
-             AutoResetView.DoIdentity();
 
-             //TipText.Show("OnClick_ResetAim");
 
-             //isResetAim = true;
 
-         }
 
-         //public void OnClick_StopRotationSensor()
 
-         //{
 
-         //    bool success = SmartBowHelper.GetInstance().StopRotationSensor();
 
-         //    if (!success) TipText.Show("停止九轴传感失败\n原因\n模块未连接或未初始化完成");
 
-         //    else TipText.Show("停止九轴传感\n指令发送成功");
 
-         //    // 移除监听
 
-         //    SmartBowHelper.GetInstance().OnRotationUpdate -= GameMananger.GetInstance().OnRotationUpdate;
 
-         //}
 
-         //public void OnClick_StopShootingSensor()
 
-         //{
 
-         //    bool success = SmartBowHelper.GetInstance().StopShootingSensor();
 
-         //    if (!success) TipText.Show("停止射箭传感失败\n原因\n模块未连接或未初始化完成");
 
-         //    else TipText.Show("停止射箭传感\n指令发送成功");
 
-         //    // 移除onshooting监听
 
-         //    SmartBowHelper.GetInstance().OnShooting -= GameMananger.GetInstance().OnShooting;
 
-         //}
 
-         /// <summary>
 
-         /// 切换射击模式
 
-         /// </summary>
 
-         //private void OnClick_ChangeShootType()
 
-         //{
 
-         //    ShootTypeEnum type = GameMananger.GetInstance().GetShootType();
 
-         //    if (type == ShootTypeEnum.FixedScreen)
 
-         //    {
 
-         //        GameMananger.GetInstance().SetShootType(ShootTypeEnum.FixedCrossHair);
 
-         //    }
 
-         //    else if (type == ShootTypeEnum.FixedCrossHair)
 
-         //    {
 
-         //        GameMananger.GetInstance().SetShootType(ShootTypeEnum.moreScreen);
 
-         //    }
 
-         //    else if (type == ShootTypeEnum.moreScreen)
 
-         //    {
 
-         //        GameMananger.GetInstance().SetShootType(ShootTypeEnum.FixedScreen);
 
-         //    }
 
-         //    TipText.Show(GameMananger.GetInstance().GetShootType().ToString());
 
-         //}
 
-         //public void OnClick_Login()
 
-         //{
 
-         //    if (string.IsNullOrWhiteSpace(_inputFieldUsername.text) || string.IsNullOrWhiteSpace(_inputFieldPassword.text))
 
-         //    {
 
-         //        TipText.Show("请输入账号密码");
 
-         //        return;
 
-         //    }
 
-         //    SmartBowHelper.GetInstance().Login(
 
-         //        _inputFieldGameID.text,
 
-         //        _inputFieldChannelID.text,
 
-         //        _inputFieldUsername.text,
 
-         //        _inputFieldPassword.text,
 
-         //        (res) =>
 
-         //        {
 
-         //            if (res.success)
 
-         //            {
 
-         //                Debug.Log("登录成功");
 
-         //                UpdateLoginUI(1);
 
-         //            }
 
-         //            TipText.Show(res.message);
 
-         //        });
 
-         //}
 
-         //public void OnClick_Logout()
 
-         //{
 
-         //    SmartBowHelper.GetInstance().Logout((success) =>
 
-         //    {
 
-         //        if (success)
 
-         //        {
 
-         //            TipText.Show($"登出成功");
 
-         //            UpdateLoginUI(0);
 
-         //        }
 
-         //        else TipText.Show($"登出失败");
 
-         //    });
 
-         //}
 
-         ///// <summary>
 
-         ///// 获取用户信息按钮点击事件
 
-         ///// </summary>
 
-         //public void OnClick_GetUserInfo()
 
-         //{
 
-         //    SmartBowHelper.GetInstance().GetUserInfo((res) =>
 
-         //    {
 
-         //        if (res.success)
 
-         //        {
 
-         //            Debug.Log("获取用户信息成功");
 
-         //            UserInfo userInfo = res.userInfo;
 
-         //        //渲染UI
 
-         //        StartCoroutine(SmartBowNetwork.LoadSprite(userInfo.avatarUrl, (sprite) =>
 
-         //            {
 
-         //                _imgAvatar.sprite = sprite;
 
-         //                _imgAvatar.enabled = true;
 
-         //            }));
 
-         //            _textNickname.text = userInfo.nickname;
 
-         //            _textNickname.enabled = true;
 
-         //            _textGender.text = userInfo.gender == 1 ? "男" : "女";
 
-         //            _textGender.enabled = true;
 
-         //        // todo: 更新用户头像,保存最高分 GameOverPanel也用得到
 
-         //        GameMananger.GetInstance().SetHighScore(0);
 
-         //        }
 
-         //        TipText.Show(res.message);
 
-         //    });
 
-         //}
 
-         //#endregion
 
-         //#region Functions
 
-         ///// <summary>
 
-         ///// 登录相关文字更新
 
-         ///// </summary>
 
-         ///// <param name="step"></param>
 
-         //void UpdateLoginUI(int step)
 
-         //{
 
-         //    _inputFieldGameID.gameObject.SetActive(step == 0);
 
-         //    _inputFieldChannelID.gameObject.SetActive(step == 0);
 
-         //    _inputFieldUsername.gameObject.SetActive(step == 0);
 
-         //    _inputFieldPassword.gameObject.SetActive(step == 0);
 
-         //    _btnLogin.gameObject.SetActive(step == 0);
 
-         //    _btnLogout.gameObject.SetActive(step == 1);
 
-         //    _btnGetUserInfo.gameObject.SetActive(step == 1);
 
-         //    _imgAvatar.gameObject.SetActive(step == 1);
 
-         //    _textNickname.gameObject.SetActive(step == 1);
 
-         //    _textGender.gameObject.SetActive(step == 1);
 
-         //    _imgAvatar.enabled = false;
 
-         //    _imgAvatar.sprite = null;
 
-         //    _textNickname.enabled = false;
 
-         //    _textGender.enabled = false;
 
-         //}
 
-         ///// <summary>
 
-         ///// 陀螺仪文字更新
 
-         ///// </summary>
 
-         //void UpdateCalibrateGyrText()
 
-         //{
 
-         //    Text text = _btnCalibrateGyr.GetComponentInChildren<Text>();
 
-         //    int progress = (int)(SmartBowHelper.GetInstance().GetGyrProgress() * 100);
 
-         //    string act = SmartBowHelper.GetInstance().IsGyrCalibrating() ? "停止" : "开始";
 
-         //    text.text = $"点击{act}陀螺仪校准({progress}%)";
 
-         //}
 
-         ///// <summary>
 
-         ///// 地磁计文字更新
 
-         ///// </summary>
 
-         //void UpdateCalibrateMagText()
 
-         //{
 
-         //    Text text = _btnCalibrateMag.GetComponentInChildren<Text>();
 
-         //    if (SmartBowHelper.GetInstance().IsMagCompleted())
 
-         //    {
 
-         //        text.text = $"<color=green>校准完成</color>(点击重置)";
 
-         //    }
 
-         //    else
 
-         //    {
 
-         //        string tip = Time.realtimeSinceStartup - _clickCalibrateMagTime < 2 ? "<color=#FF670D>已重置</color>" : "点击重置";
 
-         //        text.text = $"<color=blue>自动校准中</color>({tip})";
 
-         //    }
 
-         //}
 
-         /// <summary>
 
-         /// 进度文字更新
 
-         /// </summary>
 
-         public void UpdateProcess()
 
-         {
 
-             if (ProcessManager.GetInstance().CurrLevel <= 0) return;
 
-             _textProcess.text = $"{(ProcessManager.GetInstance().CurrLevel > ProcessModule.GetInstance().processDataDic.Count ? ProcessModule.GetInstance().processDataDic.Count : ProcessManager.GetInstance().CurrLevel)}/{ProcessModule.GetInstance().processDataDic.Count}";
 
-         }
 
-         public void SetProcessInfoActive(bool active)
 
-         {
 
-             _processObj.gameObject.SetActive(active);
 
-             _textEnemy.gameObject.SetActive(active);
 
-         }
 
-         //private void OnBluetoothModuleInited()
 
-         //{
 
-         //    textBattery.color = new Color(1, 1, 1, 1);
 
-         //    textMacAddress.color = new Color(1, 1, 1, 1);
 
-         //    // 初始化完成
 
-         //    // 真 连接成功 文本表现 见OnBluetoothStatusChanged注释
 
-         //    if (SmartBowHelper.GetInstance().IsBluetoothModuleInited()) btnConnectText.text = "<color=green>已连接</color>(点击断开)";
 
-         //    else btnConnectText.text = "<color=green>已连接</color><color=blue>(正在初始化)</color>";
 
-         //    // 开始get电量和macAdd (在update处理
 
-         //}
 
-         ///// <summary>
 
-         ///// 蓝牙状态变化
 
-         ///// </summary>
 
-         ///// <param name="oldStatus"></param>
 
-         ///// <param name="newStatus"></param>
 
-         //void OnBluetoothStatusChanged(BluetoothStatusEnum oldStatus, BluetoothStatusEnum newStatus)
 
-         //{
 
-         //    if (newStatus == BluetoothStatusEnum.None) btnConnectText.text = "<color=blue>未连接</color>(点击连接)";
 
-         //    if (newStatus == BluetoothStatusEnum.Connecting) btnConnectText.text = "<color=#FF670D>连接中</color>";
 
-         //    if (newStatus == BluetoothStatusEnum.Connected) btnConnectText.text = "<color=green>已连接</color><color=blue>(正在初始化)</color>";
 
-         //}
 
-         #endregion
 
-     }
 
- }
 
 
  |