Beispiel #1
0
 //Finds adjacent active nodes to the node passed in
 public IEnumerable <Node> GetActiveNeighbors(Node current)
 {
     if (Diagonal.Checked)
     {
         return(ListOfNodes.Where(node =>
                                  ((node.X == current.X + 1 ||
                                    node.X == current.X ||
                                    node.X == current.X - 1) &&
                                   (node.Y == current.Y + 1 ||
                                    node.Y == current.Y ||
                                    node.Y == current.Y - 1)) &&
                                  node.State != NodeState.Inactive &&
                                  node.State != NodeState.Wall &&
                                  node != current));
     }
     else
     {
         return(ListOfNodes.Where(node =>
                                  (((node.X == current.X + 1 || node.X == current.X - 1) && node.Y == current.Y) ||
                                   ((node.Y == current.Y + 1 || node.Y == current.Y - 1) && node.X == current.X)) &&
                                  node.State != NodeState.Inactive &&
                                  node.State != NodeState.Wall &&
                                  node != current));
     }
 }
Beispiel #2
0
        public bool ResetGrid()
        {
            //Set points that aren't start or end to be none
            foreach (var node in ListOfNodes
                     .Where(n => n != StartNode && n != EndNode))
            {
                node.State = NodeState.None;
            }

            //Check for start point and end point
            return(StartNode != null && EndNode != null);
        }
Beispiel #3
0
 public IEnumerable <Node> GetAllNeighbors(Node current)
 {
     return(ListOfNodes.Where(node =>
                              ((node.X == current.X + 1 ||
                                node.X == current.X ||
                                node.X == current.X - 1) &&
                               (node.Y == current.Y + 1 ||
                                node.Y == current.Y ||
                                node.Y == current.Y - 1)) &&
                              node.State != NodeState.Wall &&
                              node != current));
 }
Beispiel #4
0
 //Returns all active nodes
 public IEnumerable <Node> GetAllActive()
 {
     return(ListOfNodes.Where(node => node.State == NodeState.Active));
 }