public void SetTrace(GridNode target, int g, int h) { Target = target; this.G = g; H = h; }
public void LoadNodes(GridNode[,] storedNodes) { nodes = storedNodes; }
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); }
public Vector2 GetPositionFromNode(GridNode currentNode) { return new Vector2(currentNode.LocationInGrid.X * nodeSpacing, currentNode.LocationInGrid.Y * nodeSpacing); }
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; } }