RiftMayhem/Assets/Scripts/Player/AbilityKeyBinder.cs

38 lines
996 B
C#

using Kryz.CharacterStats.Examples;
using Photon.Pun;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AbilityKeyBinder : MonoBehaviour
{
[SerializeField] private BaseAbility ability;
[SerializeField] private GameKey key;
[SerializeField] private CastingStateController castingStateController;
private PhotonView user;
private Taggable userTag;
private Mana mana;
private void Awake()
{
user = GetComponentInParent<PhotonView>();
userTag = GetComponentInParent<Taggable>();
mana = GetComponentInParent<Mana>();
}
private void Start()
{
if (!user.IsMine) this.enabled = false;
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyDown(key.keyCode))
{
if (mana.EnoughMana(ability.manaCost))
castingStateController.RequestAbilityCast(ability, () => ability.Execute(user, userTag));
}
}
}