public AnimalStandard( string whatAmI, AnimalState initialState, IAnimalBehavior aggressiveBehavior, IAnimalBehavior fearfulBehavior, IAnimalBehavior idleBehavior) : base(whatAmI, initialState) { SetBehavior(AnimalState.aggressive, aggressiveBehavior); SetBehavior(AnimalState.fearful, fearfulBehavior); SetBehavior(AnimalState.idle, idleBehavior); }
public AnimalBehavior(AnimalBase animal, Action behavior, Func <bool> criterion, IAnimalBehavior next) { Behavior = behavior; Criterion = criterion; Next = next; }
public Animal(string description, IAnimalBehavior behavior) { Behavior = behavior ?? throw new ArgumentException("Null for initial behavior not allowed..."); Description = description; }
/// <summary> /// Setting a behavior will always overwrite any existing /// behavior for the given state. /// </summary> public void SetBehavior(AnimalState state, IAnimalBehavior behavior) { Behaviors[state] = behavior; }