AIEditor.PathDisplay.ShowPath C# (CSharp) Метод

ShowPath() публичный Метод

public ShowPath ( List path ) : void
path List
Результат void
        public void ShowPath(List<PositionedNode> path)
        {
            if (path.Count == 0)
            {
                return;
            }

            Text text;

            for (int i = 0; i < path.Count - 1; i++)
            {
                Line line = new Line();
                line.Visible = true;
                line.RelativePoint1.X = 0;
                line.RelativePoint1.Y = 0;

                line.Position = path[i].Position;

                line.RelativePoint2.X = path[i + 1].X - line.Position.X;
                line.RelativePoint2.Y = path[i + 1].Y - line.Position.Y;
                line.Color = Color.Yellow;

                mPath.Add(line);

                text = TextManager.AddText(path[i].CostToGetHere.ToString());
                text.Position = path[i].Position;
                text.X += .5f;
                text.Y += .5f;
                mCosts.Add(text);
            }

            text = TextManager.AddText(path[path.Count - 1].CostToGetHere.ToString());
            text.Position = path[path.Count - 1].Position;
            text.X += .5f;
            text.Y += .5f;
            mCosts.Add(text);
        }

Usage Example

Пример #1
0
        public void SelectNode(PositionedNode nodeToSelect)
        {
            #region Finding path between two nodes
            if (GuiData.ToolsWindow.IsFindPathToNodeButtonPressed && mCurrentNodes.Count != 0 && nodeToSelect != null)
            {
                // The button should come back up
                GuiData.ToolsWindow.IsFindPathToNodeButtonPressed = false;

                List <PositionedNode> positionedNodes =
                    EditorData.NodeNetwork.GetPath(mCurrentNodes[0], nodeToSelect);

                mPathDisplay.ShowPath(positionedNodes);

                if (positionedNodes.Count == 0)
                {
                    GuiManager.ShowMessageBox("The two nodes are not connected by links.", "Not Connected");
                }
            }
            #endregion

            #region else, simply selecting node
            else
            {
                mCurrentNodes.Clear();


                if (nodeToSelect != null)
                {
                    mCurrentNodes.Add(nodeToSelect);
                }
            }
            #endregion
        }