private void CancelSpell() { if (CurrentSpell == null || CurrentSpell.Equals(null)) { CurrentSpell = null; SpellElement = SpellElement.None; SpellTier = SpellTier.None; State = SpellCastingState.Select; } else { bool success = CurrentSpell.Deactivate(); if (success) { CurrentSpell = null; SpellElement = SpellElement.None; SpellTier = SpellTier.None; State = SpellCastingState.Select; } } }
public void PublishGesture(ISpellGesture gesture) { bool spellWasDestroyed = CurrentSpell != null && CurrentSpell.Equals(null); //Process cancel gesture. //A spell can be canceled at any time. if (gesture.IsCancel || spellWasDestroyed) { State = SpellCastingState.Cancel; } switch (State) { case SpellCastingState.None: break; case SpellCastingState.Select: SelectSpell(gesture); break; case SpellCastingState.Adjust: AdjustSpell(gesture); break; case SpellCastingState.Cast: CastSpell(gesture); break; case SpellCastingState.Cancel: CancelSpell(); break; default: throw new System.InvalidOperationException("Illegal enum value."); } }
private IEnumerator MonitorChanneledSpell() { yield return(new WaitUntil(() => CurrentSpell == null || CurrentSpell.Equals(null))); CancelSpell(); }