當前位置: 首頁>>代碼示例>>C#>>正文


C# AstarPath類代碼示例

本文整理匯總了C#中AstarPath的典型用法代碼示例。如果您正苦於以下問題:C# AstarPath類的具體用法?C# AstarPath怎麽用?C# AstarPath使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


AstarPath類屬於命名空間,在下文中一共展示了AstarPath類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PathThreadInfo

 public PathThreadInfo(int index, AstarPath astar, PathHandler runData)
 {
     this.threadIndex = index;
     this.astar = astar;
     this.runData = runData;
     this.lockObject = new object();
 }
開發者ID:GameDiffs,項目名稱:TheForest,代碼行數:7,代碼來源:PathThreadInfo.cs

示例2: PathThreadInfo

 public PathThreadInfo(int index, AstarPath astar, NodeRunData runData)
 {
     this.threadIndex = index;
     this.astar = astar;
     this.runData = runData;
     _lock = new object();
 }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:7,代碼來源:astarclasses.cs

示例3: OnComplete

	//This function will be called when the pathfinding is complete, it will be called when the pathfinding returned an error too.
	public void OnComplete (AstarPath.Path p) {
		
		//If the script was already calculating a path when a new path started calculating, then it would have canceled the first path, that will generate an OnComplete message from the first path, this makes sure we only get OnComplete messages from the path we started calculating latest.
		if (path != p) {
			return;
		}
		
		//What should we do if the path returned an error (there is no available path to the target).
		if (path.error) {
			switch (onError) {
				case OnError.None:
					return;
				case OnError.ErrorMessage:
					SendMessage("PathError",new Vector3[0],SendMessageOptions.DontRequireReceiver);
					break;
				case OnError.EmptyArray:
					SendMessage("PathComplete",new Vector3[0],SendMessageOptions.DontRequireReceiver);
					break;
			} 
			return;
		}
		
		if (path.path == null) {
			Debug.LogError ("The 'Path' array is not assigned - System Error - Please send a bug report - Include the following info:\nError = "+p.error+"\nStart = "+startpos+"\nEnd = "+endpos+"\nFound End = "+p.foundEnd+"\nError = "+p.error);
		}
		
		if(path.path.Length > 1) {
			//Convert the Node array to a Vector3 array, subract one from the array if Remove First is true and add one to the array if Use Real End is set to Add
			Vector3[] a = new Vector3[path.path.Length - (removeFirst ? 1 : 0) + (endPoint == RealEnd.AddExact ? 1 : 0)];
			
			for (int i=0;i<path.path.Length;i++) {
				//Ignore the first node if Remove First is set to True
				if (removeFirst && i==0) {
					continue;
				}
				
				a[i - (removeFirst ? 1 : 0)] = path.path[i].vectorPos;
			}
			
			if (startPoint == RealStart.Exact) {
				a[0] = startpos;
			}
			
			//Assign the endpoint
			if (endPoint == RealEnd.AddExact || endPoint == RealEnd.Exact) {
				a[a.Length-1] = endpos;
			}
			
			//Store the path in a variable so it can be drawn in the scene view for debugging
			pathPoints = a;
			
			//Send the Vector3 array to a movement script attached to this gameObject
			SendMessage("PathComplete",a,SendMessageOptions.DontRequireReceiver);
		} else {
			Vector3[] a2 = new Vector3[1] {(endPoint == RealEnd.AddExact || endPoint == RealEnd.Exact ? endpos : startpos)};
			pathPoints = a2;
			SendMessage("PathComplete",a2,SendMessageOptions.DontRequireReceiver);
		}
		
	}
開發者ID:salomonT,項目名稱:gamedevelhorse,代碼行數:61,代碼來源:Seeker.cs

示例4: CreateGraph

    void CreateGraph(AstarPath astar)
    {
        if (!points)
        {
            Debug.LogWarning("missing points root for autopointgraph " + name);
        }

        var graphs = new List<NavGraph>(astar.graphs);
        if (graphs.Contains(graph))
        {
            return;
        }

        graph = new PointGraph();
        graph.active = astar;
        graph.name = "AutoPointGraph (" + name + ")";
        graph.root = points;
        graph.raycast = true;
        graph.maxDistance = 0;
        graph.recursive = true;
        graph.mask = -1;
        
        graphs.Add(graph);
        astar.graphs = graphs.ToArray();
    }
開發者ID:spriest487,項目名稱:spacetrader-unity,代碼行數:25,代碼來源:AutoPointGraph.cs

示例5: GraphNode

		/** Constructor for a graph node. */
		protected GraphNode (AstarPath astar) {
			if (!System.Object.ReferenceEquals(astar, null)) {
				this.nodeIndex = astar.GetNewNodeIndex();
				astar.InitializeNode(this);
			} else {
				throw new System.Exception("No active AstarPath object to bind to");
			}
		}
開發者ID:CCGLP,項目名稱:Fast,代碼行數:9,代碼來源:GraphNode.cs

示例6: Start

    protected override void Start()
    {
        base.Start();

        if(Pathfinding == null) {
            Pathfinding = (AstarPath)GameObject.FindObjectOfType(typeof(AstarPath));
        }
    }
開發者ID:smarthaert,項目名稱:talimare,代碼行數:8,代碼來源:ResourceNode.cs

示例7: InitializeAstarPath

 private void InitializeAstarPath() {
     _astarPath = AstarPath.active;
     _astarPath.scanOnStartup = false;
     // IMPROVE max distance from a worldspace position to a node from my experimentation
     // assuming points surrounding obstacles are set at 0.05 grids away (0.5 * 0.1) from obstacle center
     // and interior sector points are 0.25 grids away from sector center (0.5 * 0.5)
     _astarPath.maxNearestNodeDistance = 600F;
     // TODO other settings
 }
開發者ID:Maxii,項目名稱:UnityEntry,代碼行數:9,代碼來源:AStarPathManager.cs

示例8: GraphNode

		// End of fallback
		
		/** Constructor for a graph node. */
		public GraphNode (AstarPath astar) {
			//this.nodeIndex = NextNodeIndex++;
			if (astar != null) {
				this.nodeIndex = astar.GetNewNodeIndex();
				astar.InitializeNode (this);
			} else {
				throw new System.Exception ("No active AstarPath object to bind to");
			}
		}
開發者ID:henryj41043,項目名稱:TheUnseen,代碼行數:12,代碼來源:GraphNode.cs

示例9: OnGraphScansCompleted

 private void OnGraphScansCompleted(AstarPath astarPath) {
     //if (GameManager.Instance.GameState == GameState.GeneratingPathGraphs) {
     //GameManager.Instance.__ProgressToRunning();
     // TODO need to tell GameManager that it is OK to progress the game state
     // WARNING: I must not directly cause the game state to change as the other subscribers to 
     // GameStateChanged may not have been called yet. This GraphScansCompletedEvent occurs 
     // while we are still processing OnGameStateChanged
     //}
 }
開發者ID:Maxii,項目名稱:UnityEntry,代碼行數:9,代碼來源:AStarPathManager.cs

示例10: CreateGraphIfItNull

 /// <summary>
 /// Editor only!!!
 /// </summary>
 public static void CreateGraphIfItNull(AstarPath path)
 {
     if (path == null)
     {
         Debug.LogWarning("AstarPath not found");
         return;
     }
     if (path.astarData == null || path.astarData.gridGraph == null)
         AstarPath.MenuScan();
 }
開發者ID:upsky,項目名稱:domru,代碼行數:13,代碼來源:AstarPathUtils.cs

示例11: Start

    int zFront = 0; //forward

    #endregion Fields

    #region Methods

    // Use this for initialization
    void Start()
    {
        dropDownMenuObject = GameObject.Find("Panel").GetComponent<DropDownMenu>();
        missionReader = GameObject.FindGameObjectWithTag("Grid").GetComponent<MissionReader>();
        astarPath = GameObject.FindGameObjectWithTag("Grid").GetComponent<AstarPath>();
        xLeft = -27;
        xRight = 27;
        zFront = -110;
        zBack = -140;
    }
開發者ID:Kitsuneenvy,項目名稱:MajorProject,代碼行數:17,代碼來源:CameraMovement.cs

示例12: DoStuff

        public void DoStuff()
        {
            if (!astarPath.IsNone && astarPath.Value != null)
            { astarp = FsmConverter.GetAstarPath(astarPath); }
            else
            { astarp = AstarPath.active; }

            if(!isScanning.IsNone)
            { isScanning.Value = astarp.isScanning;	}

            if(!showGraphs.IsNone)
            { showGraphs.Value = astarp.showGraphs;	}

            if(!IsUsingMultithreading.IsNone)
            { IsUsingMultithreading.Value = AstarPath.IsUsingMultithreading; }

            if(!IsAnyGraphUpdatesQueued.IsNone)
            { IsAnyGraphUpdatesQueued.Value = astarp.IsAnyGraphUpdatesQueued; }

            if(!lastUniqueAreaIndex.IsNone)
            { lastUniqueAreaIndex.Value = astarp.lastUniqueAreaIndex; }

            if(!ActiveThreadsCount.IsNone)
            { ActiveThreadsCount.Value = AstarPath.ActiveThreadsCount; }

            if(!NumParallelThreads.IsNone)
            { NumParallelThreads.Value = AstarPath.NumParallelThreads;	}

            if(!Version.IsNone)
            { Version.Value = AstarPath.Version.ToString(); }

            if(!graphs.IsNone)
            { graphs.Value = FsmConverter.SetNavGraphs(astarp.graphs); }

            if(!activeAstarPath.IsNone)
            { activeAstarPath.Value = FsmConverter.SetAstarPath(AstarPath.active);	}

            if (!astarData.IsNone)
            { astarData.Value = FsmConverter.SetNavGraphs(astarp.graphs); }
            return;
        }
開發者ID:kiriri,項目名稱:playmaker-astar-actions,代碼行數:41,代碼來源:getAStarPathInfo.cs

示例13: DoStuff

        public void DoStuff()
        {
            if (!astarPath.IsNone && astarPath.Value != null)
            { astarp = FsmConverter.GetAstarPath(astarPath); }
            else
            { astarp = AstarPath.active; }

            if(!isScanning.IsNone)
            { astarp.isScanning = isScanning.Value;	}

            if(!showGraphs.IsNone)
            { astarp.showGraphs = showGraphs.Value; }

            if(!lastUniqueAreaIndex.IsNone)
            { astarp.lastUniqueAreaIndex = lastUniqueAreaIndex.Value; }

            if (!astarData.IsNone)
            { astarp.graphs = FsmConverter.GetNavGraphs(astarData.Value); }

            return;
        }
開發者ID:kiriri,項目名稱:playmaker-astar-actions,代碼行數:21,代碼來源:setAStarPathInfo.cs

示例14: PathProcessor

		public PathProcessor (AstarPath astar, PathReturnQueue returnQueue, int processors, bool multithreaded) {
			this.astar = astar;
			this.returnQueue = returnQueue;

			if (processors < 0) {
				throw new System.ArgumentOutOfRangeException("processors");
			}

			if (!multithreaded && processors != 1) {
				throw new System.Exception("Only a single non-multithreaded processor is allowed");
			}

			// Set up path queue with the specified number of receivers
			queue = new ThreadControlQueue(processors);
			threadInfos = new PathThreadInfo[processors];

			for (int i = 0; i < processors; i++) {
				threadInfos[i] = new PathThreadInfo(i, astar, new PathHandler(i, processors));
			}

			if (multithreaded) {
				threads = new Thread[processors];

				// Start lots of threads
				for (int i = 0; i < processors; i++) {
					var threadIndex = i;
					var thread = new Thread (() => CalculatePathsThreaded(threadInfos[threadIndex]));
					thread.Name = "Pathfinding Thread " + i;
					thread.IsBackground = true;
					threads[i] = thread;
					thread.Start();
				}
			} else {
				// Start coroutine if not using multithreading
				threadCoroutine = CalculatePaths(threadInfos[0]);
			}
		}
開發者ID:legionaryu,項目名稱:Atom-defender,代碼行數:37,代碼來源:PathProcessor.cs

示例15: SerializeSettings

        /** Called to serialize a graphs settings. \note Before calling this, setting #sPrefix to something unique for the graph is a good idea to avoid collisions in variable names */
        public void SerializeSettings(NavGraph graph, AstarPath active)
        {
            ISerializableGraph serializeGraph = graph as ISerializableGraph;

            if (serializeGraph == null) {
                Debug.LogError ("The graph specified is not serializable, the graph is of type "+graph.GetType());
                return;
            }

            serializeGraph.SerializeSettings (this);
        }
開發者ID:rmkeezer,項目名稱:fpsgame,代碼行數:12,代碼來源:AstarSerialize.cs


注:本文中的AstarPath類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。