using System.Collections; using System.Collections.Generic; using UnityEngine; public class CastSpell : MonoBehaviour { [SerializeField] private FloatVariable knowledgeLevel; [SerializeField] private Transform playerTransform; [Space] [SerializeField] private float globalCooldown; [Space] public List Spells; private float timer = 0f; private bool casted = false; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if(casted) { timer += Time.deltaTime; if(timer >= globalCooldown) { timer = 0f; casted = false; } } } public void OnCastPressed(float id) { if(!casted) { //cast spell int realID = (int)id - 1; if(Spells[realID].CastType == SpellType.CastOnPlayerPosition) { GameObject spellObject = Instantiate(Spells[realID].SpellObject, playerTransform); spellObject.SetActive(true); } else { GameObject spellObject = Instantiate(Spells[realID].SpellObject, playerTransform.position, Quaternion.identity); spellObject.transform.forward = playerTransform.forward; spellObject.SetActive(true); } Debug.Log(Spells[realID].GetFinalDamageValue()); casted = true; } } }