• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PathNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中PathNode的典型用法代码示例。如果您正苦于以下问题:C# PathNode类的具体用法?C# PathNode怎么用?C# PathNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PathNode类属于命名空间,在下文中一共展示了PathNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetNeighbours

	private static List<PathNode> GetNeighbours(PathNode pathNode, 
		Point goal, int[,] field)
	{
		var result = new List<PathNode>();

		// Соседними точками являются соседние по стороне клетки.
		Point[] neighbourPoints = new Point[4];
		neighbourPoints[0] = new Point(pathNode.Position.x + 1, pathNode.Position.y);
		neighbourPoints[1] = new Point(pathNode.Position.x - 1, pathNode.Position.y);
		neighbourPoints[2] = new Point(pathNode.Position.x, pathNode.Position.y + 1);
		neighbourPoints[3] = new Point(pathNode.Position.x, pathNode.Position.y - 1);

		foreach (var point in neighbourPoints)
		{
			// Проверяем, что не вышли за границы карты.
			if (point.x < 0 || point.x >= field.GetLength(0))
				continue;
			if (point.y < 0 || point.y >= field.GetLength(1))
				continue;
			// Проверяем, что по клетке можно ходить.
			if ((field[point.x, point.y] != 1) && (field[point.x, point.y] != 3))
				continue;
			// Заполняем данные для точки маршрута.
			var neighbourNode = new PathNode()
			{
				Position = point,
				CameFrom = pathNode,
				PathLengthFromStart = pathNode.PathLengthFromStart +
					GetDistanceBetweenNeighbours(),
				HeuristicEstimatePathLength = GetHeuristicPathLength(point, goal)
			};
			result.Add(neighbourNode);
		}
		return result;
	}
开发者ID:fabiusBile,项目名称:ProjectDarkDawn,代码行数:35,代码来源:AStarPathfinder.cs


示例2: Movement

 /// <summary>Создаёт новый экземпляр класса <see cref="Movement"/>.</summary>
 /// <param name="board">Вся доска.</param>
 /// <param name="state">Прямоугольник отрисовки.</param>
 /// <param name="current">Текущая ячейка.</param>
 /// <param name="speed">Скорость перемещения.</param>
 /// <param name="sprite">Анимация объекта.</param>
 /// <param name="animation">Параметры анимации объекта.</param>
 public Movement(Rectangle state, Cell current, int speed, AnimateSprite sprite, PlayerAnimation animation, bool IsMagic)
 {
     IsEnd = true;
       _CurrentState = state;
       _Current = current;
       _Speed = speed;
       _Tile = sprite;
       _Animation = animation;
       _Field = Helper.Field;
       _Field = new PathNode[Helper.Board.GetLength(0), Helper.Board.GetLength(1)];
       bool pass;
       for (int i = 0; i < Helper.Board.GetLength(0); i++)
     for (int j = 0; j < Helper.Board.GetLength(1); j++)
     {
       if (IsMagic)
     pass = false;
       else
     pass = (Helper.Board[i, j].Type != CellType.Passable);
       _Field[i, j] = new PathNode()
       {
     IsWall = pass ,
     X = Helper.Board[i, j].Rect.X,
     Y = Helper.Board[i, j].Rect.Y,
     i = i,
     j = j,
       };
     }
 }
开发者ID:yourowndeath,项目名称:Sourcery,代码行数:35,代码来源:Movement.cs


示例3: Find

 /// <summary>
 /// Finds the shortest path, if any, between 2 nodes given the start node and the target node ID.
 /// </summary>
 /// <param name="start"></param>
 /// <param name="targetid"></param>
 /// <returns></returns>
 public static Path Find(PathNode start, uint targetid)
 {
     if (targetid != LastTarget)
         foreach (PathNode node in IDNodeMap.Values)
             node.Visited = false;
     return start.Find(targetid, start);
 }
开发者ID:MSTCAlex,项目名称:HandasaMap,代码行数:13,代码来源:PathNode.cs


示例4: ClearPathfinding

 public void ClearPathfinding()
 {
     for( int i = 0; i < 4; ++i )
     {
         PathNodes[i] = new PathNode();
     }
 }
开发者ID:neilogd,项目名称:LD28,代码行数:7,代码来源:BoardPiece.cs


示例5: CharacterMoveReport

 public CharacterMoveReport(Character c, Vector3 s, Vector3 d, PathNode eop)
 {
     character = c;
     src = s;
     dest = d;
     endOfPath = eop;
 }
开发者ID:JoeOsborn,项目名称:SRPGCK,代码行数:7,代码来源:CharacterMoveReport.cs


示例6: SetupWPNode

	//安裝Tag是WP的物件
	void SetupWPNode(){
		GameObject [] point = GameObject.FindGameObjectsWithTag ("WP");
		int pLenth = point.Length;
		m_NodeList = new PathNode[pLenth];
		string tNodeName = "";
		string [] s;
		int iWP;
		
		for (int i = 0; i < pLenth; i++) {
			PathNode pNode = new PathNode ();
			pNode.iNeibors = 0;
			pNode.NeiborsNode = null;
			pNode.fH = 0.0f;
			pNode.fG = 0.0f;
			pNode.fF = 0.0f;
			pNode.tParent = null;
			pNode.tPoint = point [i].transform.position;
			
			tNodeName = point [i].name;
			s = tNodeName.Split ('_');
			
			iWP = int.Parse (s [1]);
			pNode.iID = iWP;
			m_NodeList [iWP] = pNode;
		}
	}
开发者ID:Pathoscross,项目名称:UMEP07_03,代码行数:27,代码来源:PathNode.cs


示例7: fillHFromNodes

 public void fillHFromNodes(PathNode targetNode)
 {
     foreach (var node in nodes)
     {
         node.FillH(targetNode);
     }
 }
开发者ID:flaviold,项目名称:PG2D,代码行数:7,代码来源:PathFinderManager.cs


示例8: PathNode

 public PathNode(PathNode newNode)
 {
     this.prev = newNode.prev;
     this.pos = newNode.pos;
     this.totalDist = newNode.totalDist;
     this.distToTarget = newNode.distToTarget;
 }
开发者ID:EECS290Project4Group5,项目名称:HvZ_FPS,代码行数:7,代码来源:PathNode.cs


示例9: ResetGame

	private void ResetGame() {
		DestroyAllNodes ();
		
		pathNodeBoundsRect = new Rect ();
		targetPathLength = 0;
		isGameOver = false;
		timeUntilGameEnds = 45f;
		scoreText.enabled = false;
		gameOverText.enabled = false;
		
		// Make the first TWO nodes.
		sourceNode = Instantiate (pathNodePrefab).GetComponent<PathNode> ();
		sourceNode.Initialize (this, Vector2.zero, null, 10, 0, 0, true, true);
		PathNode secondNode = Instantiate (pathNodePrefab).GetComponent<PathNode> ();
		secondNode.Initialize (this, new Vector2(0,-0.5f), null, 4, 50, 0, true, true);
		sourceNode.nextNodes.Add (secondNode);
		secondNode.previousNode = sourceNode;

		// Reset travelers!
		DestroyAllTravelers ();
//		travelers = new List<Traveler> ();
//		int NUM_TRAVELERS = 8;
//		for (int i=0; i<NUM_TRAVELERS; i++) {
//			AddTraveler();
//			Traveler newTraveler = Instantiate (travelerPrefab).GetComponent<Traveler>();
//			float charge = i<NUM_TRAVELERS*0.5f ? -1 : 1;
//			newTraveler.Initialize (this, worldGenerator.sourceNode, charge);
//			travelers.Add (newTraveler);
//		}
	}
开发者ID:BATzerk,项目名称:Unity-GGJ2016,代码行数:30,代码来源:GameController.cs


示例10: ReversePath

        public static PathNode ReversePath(PathNode path)
        {
            // Get the current first element.
            // This will end up being our new last element.
            PathNode root = path;

            // The last element shouldn't have a backpointer
            // so this will start as null.
            PathNode next = null;

            // While we have elements to reverse...
            while (root != null)
            {
                // Get the next element.
                PathNode tmp = root.backPointer;

                // Set the current element's backpointer to our previous element.
                root.backPointer = next;

                // Set the next previous element to the current element.
                next = root;

                // Set the current element to our new element.
                root = tmp;
            }

            // Return the reversed list.
            return next;
        }
开发者ID:Tragedian-HLife,项目名称:HLife,代码行数:29,代码来源:Pathfinding.cs


示例11: SetVals

 public void SetVals(PathNode prev, Vector3 pos, float dist, float dist2)
 {
     this.prev = prev;
     this.pos = pos;
     this.totalDist = dist;
     this.distToTarget = dist2;
 }
开发者ID:EECS290Project4Group5,项目名称:HvZ_FPS,代码行数:7,代码来源:PathNode.cs


示例12: Insert

        public virtual BinaryHeapNode Insert(PathNode data)
        {
            Nodes.Add(new BinaryHeapNode(data));
            FilterUp(Count - 1);

            return null;
        }
开发者ID:xdray,项目名称:CubeWorld,代码行数:7,代码来源:BinaryHeap.cs


示例13: GetPath

    public List<PathNode> GetPath(PathNode start, PathNode end)
    {
        WaypointManager wg = GameObject.Find ("WaypointManager").GetComponent<WaypointManager>();
        var sources = wg.pathNodes;

        if(start == null || end == null)
        {
            if (sources != null && sources.Count >= 2)
            {
                start 	= sources[PathNode.startNode]/*.GetComponent<PathNode>()*/;//.GetInnerObject();
                end 	= sources[PathNode.endNode]/*.GetComponent<PathNode>()*/;//.GetInnerObject();
            }

            if (start == null || end == null)
            {
                Debug.LogWarning("Need 'start' and or 'end' defined!");
                enabled = false;
                return null;
            }
        }

        startIndex = Closest(sources, start.position);

        endIndex = Closest(sources, end.position);

        return AStarHelper.Calculate(sources[startIndex]/*.GetComponent<PathNode>()*/, sources[endIndex]/*.GetComponent<PathNode>()*/);
    }
开发者ID:MyOwnClone,项目名称:Unity-AI-framework,代码行数:27,代码来源:PathfindingManager.cs


示例14: Add

		/** Adds a node to the heap */
		public void Add(PathNode node) {
			
			if (node == null) throw new System.ArgumentNullException ("Sending null node to BinaryHeap");

			if (numberOfItems == binaryHeap.Length) {
				int newSize = System.Math.Max(binaryHeap.Length+4,(int)System.Math.Round(binaryHeap.Length*growthFactor));
				if (newSize > 1<<18) {
					throw new System.Exception ("Binary Heap Size really large (2^18). A heap size this large is probably the cause of pathfinding running in an infinite loop. " +
						"\nRemove this check (in BinaryHeap.cs) if you are sure that it is not caused by a bug");
				}

				PathNode[] tmp = new PathNode[newSize];

				for (int i=0;i<binaryHeap.Length;i++) {
					tmp[i] = binaryHeap[i];
				}
				binaryHeap = tmp;
				
				//Debug.Log ("Forced to discard nodes because of binary heap size limit, please consider increasing the size ("+numberOfItems +" "+binaryHeap.Length+")");
				//numberOfItems--;
			}

			PathNode obj = node;
			binaryHeap[numberOfItems] = obj;

			//node.heapIndex = numberOfItems;//Heap index

			int bubbleIndex = numberOfItems;
			uint nodeF = node.F;
			//Debug.Log ( "Adding node with " + nodeF + " to index " + numberOfItems);
			
			while (bubbleIndex != 0 ) {
				int parentIndex = (bubbleIndex-1) / D;

				//Debug.Log ("Testing " + nodeF + " < " + binaryHeap[parentIndex].F);

				if (nodeF < binaryHeap[parentIndex].F) {

				   	
					//binaryHeap[bubbleIndex].f <= binaryHeap[parentIndex].f) { /* \todo Wouldn't it be more efficient with '<' instead of '<=' ? * /
					//Node tmpValue = binaryHeap[parentIndex];
					
					//tmpValue.heapIndex = bubbleIndex;//HeapIndex
					
					binaryHeap[bubbleIndex] = binaryHeap[parentIndex];
					binaryHeap[parentIndex] = obj;
					
					//binaryHeap[bubbleIndex].heapIndex = bubbleIndex; //Heap index
					//binaryHeap[parentIndex].heapIndex = parentIndex; //Heap index
					
					bubbleIndex = parentIndex;
				} else {
					break;
				}
			}

			numberOfItems++;

			//Validate();
		}
开发者ID:JackHR,项目名称:WaveIncoming,代码行数:61,代码来源:BinaryHeap.cs


示例15: LoadPathPointDesc

	public static void LoadPathPointDesc (PathNode [] m_NodeList){

		TextAsset ta=(TextAsset)Resources.Load ("WayPoint");
		string [] sText=ta.text.Split("\n"[0]);
		int tLenth=sText.Length;
		string sID;
		string [] sText2;
		int iNeibor=0;

		for (int i=0; i<tLenth; i++) {
			sID = sText [i];
			sID = sID.Trim ();

			sText2 = sID.Split (" " [0]);
			if (sText2.Length < 1) {
				continue;
			}

			iNeibor = sText2.Length - 1;
			sID = sText2 [0];
			int iID = int.Parse (sID);

			m_NodeList [iID].iNeibors = iNeibor;
			m_NodeList [iID].NeiborsNode = new PathNode[iNeibor];

			for (int j=0; j<iNeibor; j++) {
				sID = sText2 [j + 1];
				int iNei = int.Parse (sID);
				m_NodeList [i].NeiborsNode [j] = m_NodeList [iNei];
			}
		}

	}
开发者ID:Pathoscross,项目名称:UMEP07_03,代码行数:33,代码来源:LoadPathPoint.cs


示例16: Search

    private bool Search(PathNode currentNode)
    {
        currentNode.state = NodeState.Closed;
        List<PathNode> nextNodes = GetSiblingNodes(currentNode);

        // Sort by F-value so that the shortest possible routes are considered first
        nextNodes.Sort((node1, node2) => node1.F.CompareTo(node2.F));
        foreach (var nextNode in nextNodes)
        {
            // Check whether the end node has been reached
            if (nextNode.location == targetNode.location)
            {
                return true;
            }
            else
            {
                // If not, check the next set of nodes
                if (Search(nextNode)) // Note: Recurses back into Search(Node)
                    return true;
            }
        }

        // The method returns false if this path leads to be a dead end
        return false;
    }
开发者ID:flaviold,项目名称:PG2D,代码行数:25,代码来源:PathFinderManager.cs


示例17: Main

 static void Main(string[] args)
 {
     string str = FileReader.ReadFile(FILENAME);
     string[] strArray = str.Replace("\n", "|").Split('|');
     int matrixWidth = strArray.Length;
     PathNode[][] matrix = new PathNode[matrixWidth][];
     for (int i = 0; i < strArray.Length; i++)
     {
         matrix[i] = new PathNode[matrixWidth];
         string line = strArray[i];
         string[] numStrs = line.Split(',');
         for (int j = 0; j < numStrs.Length; j++)
         {
             string numStr = numStrs[j];
             matrix[i][j] = new PathNode() { NodeValue = int.Parse(numStr), NodePathSum = 0 };
         }
     }
     matrix[matrixWidth - 1][matrixWidth - 1].NodePathSum = matrix[matrixWidth - 1][matrixWidth - 1].NodeValue;
     int currSub = 1;
     while (currSub < matrixWidth)
     {
         // 从下向上计算左侧
         int colIndex = matrixWidth - currSub - 1;
         int tempRowIndex = 0;
         for (int i = 0; i < currSub; i++)
         {
             tempRowIndex = matrixWidth - i - 1;
             // 下方
             long tempDownSum = long.MaxValue;
             if (i > 0)
             {
                 tempDownSum = matrix[tempRowIndex + 1][colIndex].NodePathSum;
             }
             // 右侧
             long tempRightSum = matrix[tempRowIndex][colIndex + 1].NodePathSum;
             matrix[tempRowIndex][colIndex].NodePathSum = matrix[tempRowIndex][colIndex].NodeValue + Math.Min(tempDownSum, tempRightSum);
         }
         // 从右向左计算顶部
         int rowIndex = matrixWidth - currSub - 1;
         int tempColumnIndex = 0;
         for (int i = 0; i < currSub; i++)
         {
             tempColumnIndex = matrixWidth - i - 1;
             // 下方
             long tempDownSum = matrix[rowIndex + 1][tempColumnIndex].NodePathSum;
             // 右侧
             long tempRightSum = long.MaxValue;
             if (i > 0)
             {
                 tempRightSum = matrix[rowIndex][tempColumnIndex + 1].NodePathSum;
             }
             matrix[rowIndex][tempColumnIndex].NodePathSum = matrix[rowIndex][tempColumnIndex].NodeValue + Math.Min(tempDownSum, tempRightSum);
         }
         // 计算左上角
         matrix[rowIndex][colIndex].NodePathSum = matrix[rowIndex][colIndex].NodeValue + Math.Min(matrix[rowIndex + 1][colIndex].NodePathSum, matrix[rowIndex][colIndex + 1].NodePathSum);
         currSub++;
     }
     Console.WriteLine("Result is {0}", matrix[0][0].NodePathSum);
 }
开发者ID:PayneKang,项目名称:ProjectEulerResolves,代码行数:59,代码来源:Program.cs


示例18: createPathNode

 public void createPathNode(GameObject square, GameObject goalSquare)
 {
     thisSquare = square;
     this.goalSquare = goalSquare;
     neighbors = findNeighbors();
     parent = null;
     // square.GetComponent<Renderer>().material.color = Color.red;
 }
开发者ID:JBillingsley,项目名称:SpyParty,代码行数:8,代码来源:PathNode.cs


示例19: IsClearPath

    public static bool IsClearPath(PathNode node1, PathNode node2)
    {
        float dist = Vector3.Distance(node1.transform.position, node2.transform.position);
        Vector3 direction = node2.transform.position - node1.transform.position;
        direction.Normalize();

        return !Physics.Raycast(node1.transform.position, direction, dist, int.MaxValue);
    }
开发者ID:pimms,项目名称:gfh_gj,代码行数:8,代码来源:PathNodeMapper.cs


示例20: CharacterMovedIncremental

 public virtual void CharacterMovedIncremental(Character c, Vector3 src, Vector3 dest, PathNode endOfPath)
 {
     map.BroadcastMessage(
         "MovedCharacterIncremental",
         new CharacterMoveReport(c, src, dest, endOfPath),
         SendMessageOptions.DontRequireReceiver
     );
 }
开发者ID:JoeOsborn,项目名称:SRPGCK,代码行数:8,代码来源:Scheduler.cs



注:本文中的PathNode类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# PathSegmentCollection类代码示例发布时间:2022-05-24
下一篇:
C# PathInfo类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap