SmartBowController.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. namespace WildAttack
  6. {
  7. public class SmartBowController : MonoBehaviour
  8. {
  9. public static SmartBowController Instance;
  10. void Start()
  11. {
  12. Instance = this;
  13. SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
  14. InfraredDemo.infraredCameraHelper.OnPositionUpdate += OnScreenPointUpdate;
  15. StartCoroutine(SetOutBoundChecker());
  16. }
  17. IEnumerator SetOutBoundChecker()
  18. {
  19. yield return null;
  20. CrossHairOutBoundChecker1 outBoundChecker = Instantiate(Resources.Load<GameObject>("Prefabs/CrossHairOutBoundChecker1")).GetComponent<CrossHairOutBoundChecker1>();
  21. outBoundChecker.FetchOutBoundIndex = () => GameMananger.GetInstance().outBoundIndex;
  22. }
  23. void OnDestroy()
  24. {
  25. if (Instance == this) Instance = null;
  26. InfraredDemo.infraredCameraHelper.OnPositionUpdate -= OnScreenPointUpdate;
  27. }
  28. public void OnRotationUpdate(Quaternion rotation)
  29. {
  30. if (SB_EventSystem.ins.simulateMouseIsAwaked) return;
  31. GameMananger.GetInstance()?.OnRotationUpdate(rotation);
  32. }
  33. public void OnScreenPointUpdate(Vector2 point, Vector2 cameraLocation)
  34. {
  35. if (SB_EventSystem.ins.simulateMouseIsAwaked) return;
  36. GameMananger.GetInstance()?.OnScreenPointUpdate(point);
  37. }
  38. float _lastShootTime = 0;
  39. public void OnShooting(float speed)
  40. {
  41. if (Time.time == 0) return;
  42. if (Time.realtimeSinceStartup - _lastShootTime < 1) return;
  43. _lastShootTime = Time.realtimeSinceStartup;
  44. GameMananger.GetInstance().OnModuleShooting(speed);
  45. }
  46. public bool IsBluetoothModuleInited()
  47. {
  48. return BluetoothAim.ins && BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
  49. }
  50. }
  51. }