void CastSpell(GameObject spell) { SpellBehavior spellBehavior = spell.GetComponent <SpellBehavior>(); if (!spellBehavior.canBeCast) { return; } if (!RectTransformUtility.RectangleContainsScreenPoint(rectTransform, Input.mousePosition)) { RaycastHit hit = new RaycastHit(); Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit, 1000)) { spellBehavior.Cast(); GameObject prefab = spell.GetComponent <SpellBehavior>().prefab; Instantiate(prefab, hit.point, Quaternion.identity); } } }
public virtual void PerformSpell(ICharacter target) { SpellBehavior.Cast(this, target); }