Ejemplo n.º 1
0
    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);
            }
        }
    }
Ejemplo n.º 2
0
 public virtual void PerformSpell(ICharacter target)
 {
     SpellBehavior.Cast(this, target);
 }