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)); } }
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); }
public void RaiseActorMoved(object sender, EventArgs e) { ActorMoved?.Invoke(sender, e); }