예제 #1
0
        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);
              }
        }
예제 #2
0
 public override bool IsAccessibleTo(Actor actor)
 {
     return false;
 }
예제 #3
0
 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;
 }
예제 #5
0
 public Behaviour Invoke(Actor actor, WorldView state)
 {
     var result = behaviour(state);
       result.Item1.Act(actor, state);
       return result.Item2;
 }