44 lines
1.0 KiB
C#
Raw Normal View History

using System;
2025-08-11 20:37:42 +05:00
using UnityEngine;
public class AbilityInput : MonoBehaviour
{
[Header("User + Slots")]
public AbilityUser user;
public AbilitySlot[] slots = new AbilitySlot[4];
2025-09-29 15:38:48 +05:00
public Animator[] HandsAnimator;
private void Start()
{
foreach (var slot in slots)
{
if (slot.abilityUiItem)
{
slot.abilityUiItem.Init(slot.ability);
}
}
}
2025-08-11 20:37:42 +05:00
void Update()
{
foreach (var s in slots) s?.Tick(Time.deltaTime);
// Quick default bindings: 1..4
2025-08-12 12:39:09 +05:00
if (Input.GetKeyDown(KeyCode.Q)) Use(0);
if (Input.GetKeyDown(KeyCode.E)) Use(1);
if (Input.GetKeyDown(KeyCode.R)) Use(2);
if (Input.GetKeyDown(KeyCode.T)) Use(3);
2025-08-11 20:37:42 +05:00
}
2025-09-29 15:38:48 +05:00
void AnimateHands()
{
foreach (var item in HandsAnimator)
{
item.SetTrigger("Throw");
}
}
2025-08-11 20:37:42 +05:00
public void Use(int index)
{
if (index < 0 || index >= slots.Length) return;
2025-09-29 15:38:48 +05:00
AnimateHands();
2025-08-11 20:37:42 +05:00
slots[index]?.TryUse(user);
}
}