public void PlaySpell(SpellCard spellCard, Character target) { Debugger.LogPlayer(this, "starting to cast spell " + spellCard.Name + " to " + target); // Firing OnSpellPreCast events SpellPreCastEvent spellPreCastEvent = EventManager.Instance.OnSpellPreCast(this, spellCard, target); if (target != spellPreCastEvent.Target) { Debugger.LogPlayer(this, " switching spell " + spellCard.Name + " target to " + target); // Re-setting the target because it has changed on the PreCast events target = spellPreCastEvent.Target; } // Checking if the Spell has not been cancelled if (spellPreCastEvent.Status != PreStatus.Cancelled) { Debugger.LogPlayer(this, "casting spell " + spellCard.Name + " to " + target); // Casting the Spell to the target spellCard.Cast(target); } else { Debugger.LogPlayer(this, "cancelled casting spell " + spellCard.Name); } // Firing OnSpellCasted events EventManager.Instance.OnSpellCasted(this, spellCard); // Adding the Spell to the Played Spells list UsedSpells.Add(spellCard); // Updating the Player glows UpdateSprites(); }