public void Cast(SpellCard spell, Container target) { var Mana = Container.GetComponent <Mana>(); if (Mana == null) { throw new ArgumentException("No mana in container"); } if (spell == null) { throw new ArgumentNullException(nameof(spell)); } if (!SpellCards.Contains(spell)) { throw new ArgumentException("It is'not my spell"); } if (Mana.Value < spell.GetComponent <Cost>().Value) { throw new ArgumentException("Low mana"); } Mana.DeltaMana(-spell.GetComponent <Cost>().Value); spell.GetComponent <Spell>().Use(target); if (OnSpellCast != null) { OnSpellCast.Invoke(new SessionChange()); //TODO } }
protected virtual void Casted(SpellCastArgs.Success success, string spellName) { OnSpellCast?.Invoke(this, new SpellCastArgs() { Cast = success, SpellName = spellName }); }
public void Cast() { if (hasSpell && cc.IsAlive) { canRechargeEnergy = false; selected.Cast(cc); OnSpellCast?.Invoke(); } }
public void CastSpell() { if (ReadyToCast) { Spell spellToCast = SpellBook.Instance.GetSpellFromCombo(elementalHandler.GetCurrentCombo()); if (mana.Use(spellToCast.GetManaCost())) { GameObject spellObject = spellToCast.GetSpellObject(); OnSpellCast?.Invoke(spellToCast); StartCoroutine(Casting(spellObject, spellToCast)); } else { //nomana } } }
private static void OnSpellCastAndImpact(void *pObject, int nSpellId, Vector3 targetPosition, uint oidTarget, byte nMultiClass, uint itemObj, int bSpellCountered, int bCounteringSpell, byte projectilePathType, int bInstantSpell) { CNWSObject gameObject = CNWSObject.FromPointer(pObject); OnSpellCast eventData = null !; VirtualMachine.ExecuteInScriptContext(() => { eventData = ProcessEvent(new OnSpellCast { Caster = gameObject.ToNwObject <NwGameObject>() !, Spell = NwSpell.FromSpellId(nSpellId) !, TargetPosition = targetPosition, TargetObject = oidTarget.ToNwObject <NwGameObject>() !, ClassIndex = nMultiClass, Item = itemObj.ToNwObject <NwItem>() !, SpellCountered = bSpellCountered.ToBool(), CounteringSpell = bCounteringSpell.ToBool(), ProjectilePathType = (ProjectilePathType)projectilePathType, IsInstantSpell = bInstantSpell.ToBool(), MetaMagic = (MetaMagic)NWScript.GetMetaMagicFeat(), }, false); });