public override void Act(Actor actor, WorldView world) { if (destination != null) { dx = world.Location.X < destination.X ? 1 : world.Location.X > destination.X ? -1 : 0; dy = world.Location.Y < destination.Y ? 1 : world.Location.Y > destination.Y ? -1 : 0; } Location newLocation = world.Location.Offset(dx, dy); if (world.IsAccessibleTo(newLocation, actor)) { world.MoveTo(newLocation); } }
public override bool IsAccessibleTo(Actor actor) { return false; }
public abstract void Act(Actor actor, WorldView state);
public ActorWithLocationAndBehaviour(Actor actor, Location location, Behaviour behaviour) { this.actor = actor; this.location = location; this.behaviour = behaviour; }
public Behaviour Invoke(Actor actor, WorldView state) { var result = behaviour(state); result.Item1.Act(actor, state); return result.Item2; }