Example #1
0
 public void SetTrace(GridNode target, int g, int h)
 {
     Target = target;
     this.G = g;
     H = h;
 }
Example #2
0
 public void LoadNodes(GridNode[,] storedNodes)
 {
     nodes = storedNodes;
 }
Example #3
0
 private Rectangle CenterOnNode(GridNode node, Rectangle centerer)
 {
     Vector2 position = GetPositionFromNode(node);
     return new Rectangle((int)(position.X - centerer.Width / 2), (int)(position.Y - centerer.Height / 2), centerer.Width, centerer.Height);
 }
Example #4
0
 public Vector2 GetPositionFromNode(GridNode currentNode)
 {
     return new Vector2(currentNode.LocationInGrid.X * nodeSpacing, currentNode.LocationInGrid.Y * nodeSpacing);
 }
Example #5
0
        private void BuildGridFromSnapshot()
        {
            if ( pendingNodeSpacing != 0 && pendingWorldSpace != Rectangle.Empty && pendingObstacles != null)
            {
                nodeSpacing = pendingNodeSpacing;

                //initialize array size
                nodes = new GridNode[pendingWorldSpace.Width / nodeSpacing, pendingWorldSpace.Height / nodeSpacing];

                currentObstacles = pendingObstacles;

                ////loop and weigh
                for (int x = 0; x < nodes.GetLength(0); ++x)
                {
                    for (int y = 0; y < nodes.GetLength(1); ++y)
                    {
                        GridNode currentNode = nodes[x, y] = new GridNode();
                        currentNode.LocationInGrid = new Point(x, y);
                    }
                }

                pendingObstacles = null;
                pendingWorldSpace = Rectangle.Empty;
                pendingNodeSpacing = 0;
            }
        }