SmartBowController.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. CameraToLook.ins.onParseRotation += OnRotationUpdate;
  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. }
  27. public void OnRotationUpdate(Quaternion rotation)
  28. {
  29. if (SB_EventSystem.ins.simulateMouseIsAwaked) return;
  30. GameMananger.GetInstance().OnRotationUpdate(rotation);
  31. }
  32. float _lastShootTime = 0;
  33. public void OnShooting(float speed)
  34. {
  35. if (Time.time == 0) return;
  36. if (Time.realtimeSinceStartup - _lastShootTime < 1) return;
  37. _lastShootTime = Time.realtimeSinceStartup;
  38. GameMananger.GetInstance().OnModuleShooting(speed);
  39. }
  40. public bool IsBluetoothModuleInited()
  41. {
  42. return BluetoothAim.ins && BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
  43. }
  44. }
  45. }