Example #1
0
        public bool PlaceNode(Node node)
        {
            var added = _grid.AddNode(node);

            Size = _grid.Size;
            IslandSet.Add(node);
            return(added);
        }
Example #2
0
        /// <summary>
        /// Adds the specified Arc to the game board.
        /// </summary>
        public bool Push(Arc arc, Field field)
        {
            if (!field.ValidPlacement(arc))
            {
                return(false);
            }

            // Push the arc onto the field
            arc.Push(field);
            Arcs.Add(arc);

            // Notify the island set of connected nodes
            IslandSet.Connect(field);

            return(true);
        }
Example #3
0
        /// <summary>
        /// Removes the specified Arc from the game board.
        /// </summary>
        public bool Pull(Arc arc)
        {
            if (arc.IsPulled)
            {
                return(false);
            }

            // Pull the arc from the field
            var field = arc.Field;

            arc.Pull();
            Arcs.Remove(arc);

            // Notify the island set of disconnected nodes
            IslandSet.Disconnect(field);

            return(true);
        }
Example #4
0
 /// <summary>
 /// Checks if the two nodes are connected via arcs
 /// </summary>
 public bool IsConnected(Node start, Node end)
 {
     return(IslandSet.IsConnected(start, end));
 }