当前位置: 首页>>代码示例>>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;未经允许,请勿转载。