SmartBowHandler.cs 977 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using SmartBowSDK;
  5. public class SmartBowHandler
  6. {
  7. SmartBowHelper smartBowHelper;
  8. Bow bow;
  9. public SmartBowHandler(SmartBowHelper smartBowHelper, Bow bow)
  10. {
  11. smartBowHelper.OnBluetoothModuleInited += OnBluetoothModuleInited;
  12. smartBowHelper.OnRotationUpdate += OnRotationUpdate;
  13. smartBowHelper.OnShooting += OnShooting;
  14. smartBowHelper.OnFunctionKeyPress += OnFunctionKeyPress;
  15. this.smartBowHelper = smartBowHelper;
  16. this.bow = bow;
  17. }
  18. void OnBluetoothModuleInited()
  19. {
  20. smartBowHelper.StartRotationSensor();
  21. smartBowHelper.StartShootingSensor();
  22. }
  23. void OnRotationUpdate(Quaternion rotation)
  24. {
  25. bow.transform.localRotation = rotation;
  26. }
  27. void OnShooting(float speed)
  28. {
  29. bow.Shoot();
  30. }
  31. void OnFunctionKeyPress()
  32. {
  33. smartBowHelper.ResetAim();
  34. }
  35. }