ModleK102Blend.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using SC.XR.Unity.Module_InputSystem.InputDeviceGC.KS;
  5. using SC.XR.Unity.Module_InputSystem;
  6. public class ModleK102Blend : ModelK102 {
  7. public float keyAXBlend = 0;
  8. public float keyBYBlend = 0;
  9. public float keyFunctionBlend = 0;
  10. public float keyHallInsideBlend = 0;
  11. public float keyHallForwardBlend = 0;
  12. public float JoystickXBlend = 0;
  13. public float JoystickYBlend = 0;
  14. public Animator ControllerKeyAnimator;
  15. public override void OnSCAwake() {
  16. base.OnSCAwake();
  17. if (ControllerKeyAnimator == null) {
  18. ControllerKeyAnimator = GetComponent<Animator>();
  19. }
  20. }
  21. public override void UpdateHallVisual() {
  22. if (inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.HallFoward <= (HallForwardReleaseValue - HallForwardPressValue) / 2) {
  23. keyHallForwardBlend = 1;
  24. } else {
  25. keyHallForwardBlend = 0;
  26. }
  27. SetAnimatorValue("keyHallForwardBlend", keyHallForwardBlend);
  28. if (inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.HallInside <= (HallInsideReleaseValue - HallInsidePressValue) / 2) {
  29. keyHallInsideBlend = 1;
  30. } else {
  31. keyHallInsideBlend = 0;
  32. }
  33. SetAnimatorValue("keyHallInsideBlend", keyHallInsideBlend);
  34. }
  35. public override void UpdateJoystickTransform() {
  36. if (inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.JoystickX != joystickTempValue.x || inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.JoystickY != joystickTempValue.y) {
  37. JoystickXBlend = inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.JoystickX - joystickInitalValue.x;
  38. JoystickYBlend = inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.JoystickY - joystickInitalValue.y;
  39. SetAnimatorValue("JoystickXBlend", JoystickXBlend);
  40. SetAnimatorValue("JoystickYBlend", JoystickYBlend);
  41. joystickTempValue.x = inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.JoystickX;
  42. joystickTempValue.y = inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.JoystickY;
  43. }
  44. }
  45. public override void SetHandleKeysColor() {
  46. foreach (var item in inputDeviceKSPartUI.inputDeviceKSPart.inputDataKS.inputKeys.inputKeyPressDic) {
  47. if (item.Key == InputKeyCode.Trigger) {
  48. //triggerKey.material = releaseMaterial;
  49. //if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  50. // triggerKey.material = pressMaterial;
  51. //}
  52. } else if ((item.Key == InputKeyCode.RFunction || item.Key == InputKeyCode.LFunction)) {
  53. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  54. keyFunctionBlend = 1;
  55. } else if (item.Value == InputKeyState.UP) {
  56. keyFunctionBlend = 0;
  57. }
  58. SetAnimatorValue("keyFunctionBlend", keyFunctionBlend);
  59. } else if (item.Key == InputKeyCode.X || item.Key == InputKeyCode.A) {
  60. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  61. keyAXBlend = 1;
  62. } else if (item.Value == InputKeyState.UP) {
  63. keyAXBlend = 0;
  64. }
  65. SetAnimatorValue("keyAXBlend", keyAXBlend);
  66. } else if (item.Key == InputKeyCode.Y || item.Key == InputKeyCode.B) {
  67. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  68. keyBYBlend = 1;
  69. } else if (item.Value == InputKeyState.UP) {
  70. keyBYBlend = 0;
  71. }
  72. SetAnimatorValue("keyBYBlend", keyBYBlend);
  73. } else if (item.Key == InputKeyCode.LjoystickKey || item.Key == InputKeyCode.RjoystickKey) {
  74. if (item.Value == InputKeyState.DOWN || item.Value == InputKeyState.LONG) {
  75. } else if (item.Value == InputKeyState.UP) {
  76. }
  77. }
  78. }
  79. }
  80. void SetAnimatorValue(string name,float value) {
  81. if (ControllerKeyAnimator) {
  82. ControllerKeyAnimator.SetFloat(name, value);
  83. }
  84. }
  85. }