当前位置: 首页>>代码示例>>C#>>正文


C# PathNode类代码示例

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


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


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