기본 공격 구현
This commit is contained in:
@@ -101,6 +101,16 @@ public @GameInput()
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": true,
|
||||
""priority"": 0
|
||||
},
|
||||
{
|
||||
""name"": ""Attack"",
|
||||
""type"": ""Button"",
|
||||
""id"": ""bf2fbb7b-fd81-4ec4-824d-26ff5ce88e66"",
|
||||
""expectedControlType"": """",
|
||||
""processors"": """",
|
||||
""interactions"": """",
|
||||
""initialStateCheck"": false,
|
||||
""priority"": 0
|
||||
}
|
||||
],
|
||||
""bindings"": [
|
||||
@@ -158,6 +168,17 @@ public @GameInput()
|
||||
""action"": ""Move"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": true
|
||||
},
|
||||
{
|
||||
""name"": """",
|
||||
""id"": ""7f4c479d-7d04-4598-9df4-cec2ca3408bf"",
|
||||
""path"": ""<Keyboard>/space"",
|
||||
""interactions"": """",
|
||||
""processors"": """",
|
||||
""groups"": """",
|
||||
""action"": ""Attack"",
|
||||
""isComposite"": false,
|
||||
""isPartOfComposite"": false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -167,6 +188,7 @@ public @GameInput()
|
||||
// Character
|
||||
m_Character = asset.FindActionMap("Character", throwIfNotFound: true);
|
||||
m_Character_Move = m_Character.FindAction("Move", throwIfNotFound: true);
|
||||
m_Character_Attack = m_Character.FindAction("Attack", throwIfNotFound: true);
|
||||
}
|
||||
|
||||
~@GameInput()
|
||||
@@ -248,6 +270,7 @@ public int FindBinding(InputBinding bindingMask, out InputAction action)
|
||||
private readonly InputActionMap m_Character;
|
||||
private List<ICharacterActions> m_CharacterActionsCallbackInterfaces = new List<ICharacterActions>();
|
||||
private readonly InputAction m_Character_Move;
|
||||
private readonly InputAction m_Character_Attack;
|
||||
/// <summary>
|
||||
/// Provides access to input actions defined in input action map "Character".
|
||||
/// </summary>
|
||||
@@ -264,6 +287,10 @@ public struct CharacterActions
|
||||
/// </summary>
|
||||
public InputAction @Move => m_Wrapper.m_Character_Move;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action "Character/Attack".
|
||||
/// </summary>
|
||||
public InputAction @Attack => m_Wrapper.m_Character_Attack;
|
||||
/// <summary>
|
||||
/// Provides access to the underlying input action map instance.
|
||||
/// </summary>
|
||||
public InputActionMap Get() { return m_Wrapper.m_Character; }
|
||||
@@ -292,6 +319,9 @@ public void AddCallbacks(ICharacterActions instance)
|
||||
@Move.started += instance.OnMove;
|
||||
@Move.performed += instance.OnMove;
|
||||
@Move.canceled += instance.OnMove;
|
||||
@Attack.started += instance.OnAttack;
|
||||
@Attack.performed += instance.OnAttack;
|
||||
@Attack.canceled += instance.OnAttack;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -306,6 +336,9 @@ private void UnregisterCallbacks(ICharacterActions instance)
|
||||
@Move.started -= instance.OnMove;
|
||||
@Move.performed -= instance.OnMove;
|
||||
@Move.canceled -= instance.OnMove;
|
||||
@Attack.started -= instance.OnAttack;
|
||||
@Attack.performed -= instance.OnAttack;
|
||||
@Attack.canceled -= instance.OnAttack;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -353,5 +386,12 @@ public interface ICharacterActions
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnMove(InputAction.CallbackContext context);
|
||||
/// <summary>
|
||||
/// Method invoked when associated input action "Attack" is either <see cref="UnityEngine.InputSystem.InputAction.started" />, <see cref="UnityEngine.InputSystem.InputAction.performed" /> or <see cref="UnityEngine.InputSystem.InputAction.canceled" />.
|
||||
/// </summary>
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.started" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.performed" />
|
||||
/// <seealso cref="UnityEngine.InputSystem.InputAction.canceled" />
|
||||
void OnAttack(InputAction.CallbackContext context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user