コード例 #1
0
ファイル: GridNode.cs プロジェクト: rickbatka/co-op-engine
 public void SetTrace(GridNode target, int g, int h)
 {
     Target = target;
     this.G = g;
     H = h;
 }
コード例 #2
0
ファイル: PathingGrid.cs プロジェクト: rickbatka/co-op-engine
 public void LoadNodes(GridNode[,] storedNodes)
 {
     nodes = storedNodes;
 }
コード例 #3
0
ファイル: PathingGrid.cs プロジェクト: rickbatka/co-op-engine
 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);
 }
コード例 #4
0
ファイル: PathingGrid.cs プロジェクト: rickbatka/co-op-engine
 public Vector2 GetPositionFromNode(GridNode currentNode)
 {
     return new Vector2(currentNode.LocationInGrid.X * nodeSpacing, currentNode.LocationInGrid.Y * nodeSpacing);
 }
コード例 #5
0
ファイル: PathingGrid.cs プロジェクト: rickbatka/co-op-engine
        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;
            }
        }