44 lines
1.0 KiB
C#
44 lines
1.0 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
public class AbilityInput : MonoBehaviour
|
|
{
|
|
[Header("User + Slots")]
|
|
public AbilityUser user;
|
|
public AbilitySlot[] slots = new AbilitySlot[4];
|
|
public Animator[] HandsAnimator;
|
|
private void Start()
|
|
{
|
|
foreach (var slot in slots)
|
|
{
|
|
if (slot.abilityUiItem)
|
|
{
|
|
slot.abilityUiItem.Init(slot.ability);
|
|
}
|
|
}
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
foreach (var s in slots) s?.Tick(Time.deltaTime);
|
|
|
|
// Quick default bindings: 1..4
|
|
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);
|
|
}
|
|
void AnimateHands()
|
|
{
|
|
foreach (var item in HandsAnimator)
|
|
{
|
|
item.SetTrigger("Throw");
|
|
}
|
|
}
|
|
public void Use(int index)
|
|
{
|
|
if (index < 0 || index >= slots.Length) return;
|
|
//AnimateHands();
|
|
slots[index]?.TryUse(user);
|
|
}
|
|
} |