Пример #1
0
 public void SetLocation(MapNode node)
 {
     if (node == null)
     {
         throw new ArgumentNullException("node");
     }
     if (node != Location)
     {
         Location?.RemoveActor(this);
         node.AddActor(this);
         Location = node;
         ActorMoved?.Invoke(this, new ActorMovedEventArgs(Location, node, Direction.None));
     }
 }
Пример #2
0
        public virtual bool Move(Direction dir)
        {
            MapNode node = Location.GetNeighbour(dir);

            if (node != null)
            {
                Location.RemoveActor(this);
                node.AddActor(this);
                Location = node;
                ActorMoved?.Invoke(this, new ActorMovedEventArgs(Location, node, dir));
                return(true);
            }
            Program.Error("Cannot move player", "The player location is null");
            return(false);
        }
Пример #3
0
 public void RaiseActorMoved(object sender, EventArgs e)
 {
     ActorMoved?.Invoke(sender, e);
 }