diff --git a/Version 1/Assets/_InputTest/Entity/Scripts/Monobehaviours/CharacterInput.cs b/Version 1/Assets/_InputTest/Entity/Scripts/Monobehaviours/CharacterInput.cs index 30fa4bf..5466000 100644 --- a/Version 1/Assets/_InputTest/Entity/Scripts/Monobehaviours/CharacterInput.cs +++ b/Version 1/Assets/_InputTest/Entity/Scripts/Monobehaviours/CharacterInput.cs @@ -1,5 +1,4 @@ -using System; -using _InputTest.Scripts; +using _InputTest.Scripts; using _InputTest.Scripts.Monobehaviours.Commands; using UnityEngine; using UnityEngine.InputSystem; @@ -13,17 +12,16 @@ public class CharacterInput : MonoBehaviour, IInteractInput, IMoveInput, IRotati public Command analogRotationInput; public Command mouseRotationInput; public Command skillInput; - - + + private PlayerInputActions _inputActions; - - + public Vector3 MoveDirection { get; private set; } public Vector3 RotationDirection { get; set; } public bool IsUsingSkill { get; private set; } public bool IsPressingInteract { get; private set; } - + private void Awake() { _inputActions = new PlayerInputActions(); @@ -32,23 +30,23 @@ private void Awake() private void OnEnable() { _inputActions.Enable(); - + if (movementInput) _inputActions.Player.Movement.performed += OnMoveInput; - + _inputActions.Player.Interact.performed += OnInteractButton; - + if (analogRotationInput) _inputActions.Player.AnalogAim.performed += OnAnalogAimInput; - + if (mouseRotationInput) _inputActions.Player.MouseAim.performed += OnMouseAimInput; - + if (skillInput) _inputActions.Player.Skill.performed += OnSkillButton; } - + private void OnMoveInput(InputAction.CallbackContext context) { var value = context.ReadValue(); @@ -63,8 +61,8 @@ private void OnAnalogAimInput(InputAction.CallbackContext context) RotationDirection = new Vector3(value.x, 0, value.y); if (analogRotationInput != null) analogRotationInput.Execute(); - } - + } + private void OnMouseAimInput(InputAction.CallbackContext context) { var value = context.ReadValue(); @@ -77,11 +75,11 @@ private void OnInteractButton(InputAction.CallbackContext context) { var value = context.ReadValue(); IsPressingInteract = value >= 0.15f; - if(interactInput != null && IsPressingInteract) + if (interactInput != null && IsPressingInteract) interactInput.Execute(); } - - + + private void OnSkillButton(InputAction.CallbackContext context) { var value = context.ReadValue(); @@ -89,13 +87,16 @@ private void OnSkillButton(InputAction.CallbackContext context) if (skillInput != null && IsUsingSkill) skillInput.Execute(); } - - - + + private void OnDisable() { + _inputActions.Player.Movement.performed -= OnMoveInput; _inputActions.Player.Interact.performed -= OnInteractButton; - + _inputActions.Player.AnalogAim.performed -= OnAnalogAimInput; + _inputActions.Player.MouseAim.performed -= OnMouseAimInput; + _inputActions.Player.Skill.performed -= OnSkillButton; + _inputActions.Disable(); } diff --git a/Version 1/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs b/Version 1/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs index b7c7efe..633cfc7 100644 --- a/Version 1/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs +++ b/Version 1/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs @@ -4,7 +4,7 @@ namespace _InputTest.WorldObjects.Chest.Scripts.Monobehaviours { - public class TreasureChest : MonoBehaviour, IOpenenable, IInteractable + public class TreasureChest : MonoBehaviour, IOpenable, IInteractable { [SerializeField] private float force; [SerializeField] private GameObject lootPrefab; diff --git a/Version 1/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs b/Version 1/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs index 78942c8..8b7a3da 100644 --- a/Version 1/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs +++ b/Version 1/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs @@ -1,6 +1,6 @@ namespace _InputTest.WorldObjects.Scripts { - public interface IOpenenable + public interface IOpenable { bool Opened { get; set; } diff --git a/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs b/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs index b7c7efe..633cfc7 100644 --- a/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs +++ b/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Chest/Scripts/Monobehaviours/TreasureChest.cs @@ -4,7 +4,7 @@ namespace _InputTest.WorldObjects.Chest.Scripts.Monobehaviours { - public class TreasureChest : MonoBehaviour, IOpenenable, IInteractable + public class TreasureChest : MonoBehaviour, IOpenable, IInteractable { [SerializeField] private float force; [SerializeField] private GameObject lootPrefab; diff --git a/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs b/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs index 78942c8..8b7a3da 100644 --- a/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs +++ b/Version 2 - Attack System/Assets/_InputTest/WorldObjects/Scripts/IOpenable.cs @@ -1,6 +1,6 @@ namespace _InputTest.WorldObjects.Scripts { - public interface IOpenenable + public interface IOpenable { bool Opened { get; set; }