// returns true - if trigger is allowed to fire its delegate // returns false - if trigger is not selected as one of the allowed triggers public virtual bool FilterTriggers(PlayerTurnStateTriggers trig, PlayerBoard plr) { bool isAllowed = false; if (onStateTrigger == PlayerTurnStateTriggers.AllTrigger) { isAllowed = true; } if (trig == PlayerTurnStateTriggers.AcquireUndo) { isAllowed = true; } if (trig == onStateTrigger) { isAllowed = true; } foreach (PlayerTurnStateTriggers testTrig in fireOnTriggerList) { if (testTrig == trig) { isAllowed = true; } } return(isAllowed); }
// this calls the actual delegates for the triggers public virtual void ActualFireTrigger(PlayerTurnStateTriggers trig, PlayerBoard plr) { switch (trig) { default: case PlayerTurnStateTriggers.OnSpecificRoll: // my die has rolled. Send the trigger of what that roll was so that the TileAbility may react to it. int dieRoll = this.myDie.GetValue(); OnSpecificDie(dieRoll); break; case PlayerTurnStateTriggers.NoTrigger: break; case PlayerTurnStateTriggers.StartOfRoll: OnStartRoll(plr); break; case PlayerTurnStateTriggers.StartOfTurn: OnStartTurn(plr); break; case PlayerTurnStateTriggers.EndOfTurn: OnEndOfTurn(plr); break; case PlayerTurnStateTriggers.AllLocked: OnAllLocked(plr); break; case PlayerTurnStateTriggers.Acquire: OnAcquire(plr); break; case PlayerTurnStateTriggers.AcquireUndo: OnAcquireUndo(plr); break; case PlayerTurnStateTriggers.Select: OnSelect(plr); break; case PlayerTurnStateTriggers.ChooseDie: OnChooseDie(plr); break; case PlayerTurnStateTriggers.LockedAny: OnLockedAny(plr); break; } }
// received a type of trigger from somewhere. If this TileAbility is listening for it, then fire it off using the appropriate delegate // AllTrigger - listens to all triggers and fires off delegates (if any) on all of them. // AcquireUndo - is a system level trigger and must always fire. public virtual void FireTrigger(PlayerTurnStateTriggers trig, PlayerBoard plr) { /* // old logic * if (onStateTrigger != PlayerTurnStateTriggers.AllTrigger) // if we trigger on all triggers, ignore this bail. * { * if (trig != PlayerTurnStateTriggers.AcquireUndo) // undo does not bail but always goes through * { * if (onStateTrigger != trig) return; // bail if it's not the right trigger. * } * } */ bool allowTriggerToFire = FilterTriggers(trig, plr); if (allowTriggerToFire) { ActualFireTrigger(trig, plr); } }
// received a type of trigger from somewhere. If this TileAbility is listening for it, then fire it off using the appropriate delegate // AllTrigger - listens to all triggers and fires off delegates (if any) on all of them. // AcquireUndo - is a system level trigger and must always fire. public virtual void FireTrigger(PlayerTurnStateTriggers trig, PlayerBoard plr) { /* // old logic if (onStateTrigger != PlayerTurnStateTriggers.AllTrigger) // if we trigger on all triggers, ignore this bail. { if (trig != PlayerTurnStateTriggers.AcquireUndo) // undo does not bail but always goes through { if (onStateTrigger != trig) return; // bail if it's not the right trigger. } } */ bool allowTriggerToFire = FilterTriggers(trig, plr); if (allowTriggerToFire) ActualFireTrigger(trig, plr); }
// returns true - if trigger is allowed to fire its delegate // returns false - if trigger is not selected as one of the allowed triggers public virtual bool FilterTriggers(PlayerTurnStateTriggers trig, PlayerBoard plr) { bool isAllowed = false; if (onStateTrigger==PlayerTurnStateTriggers.AllTrigger) isAllowed = true; if (trig == PlayerTurnStateTriggers.AcquireUndo) isAllowed = true; if (trig == onStateTrigger) isAllowed = true; foreach(PlayerTurnStateTriggers testTrig in fireOnTriggerList) { if (testTrig == trig) isAllowed = true; } return isAllowed; }