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


C# Pathfinding.GridGraph类代码示例

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


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

示例1: DrawNeighbours

 protected override void DrawNeighbours(GridGraph graph)
 {
     graph.neighbours = NumNeighbours.Four;
     EditorGUI.BeginDisabledGroup(true);
     EditorGUILayout.EnumPopup (new GUIContent ("Connections","Only 4 connections per node is possible on layered grid graphs"),graph.neighbours);
     EditorGUI.EndDisabledGroup();
 }
开发者ID:jgirald,项目名称:ES2015F,代码行数:7,代码来源:LayerGridGraphEditor.cs

示例2: SetGridGraph

		public static void SetGridGraph (int graphIndex, GridGraph graph) {
			if (_gridGraphs.Length <= graphIndex) {
				var gg = new GridGraph[graphIndex+1];
				for (int i = 0; i < _gridGraphs.Length; i++) gg[i] = _gridGraphs[i];
				_gridGraphs = gg;
			}

			_gridGraphs[graphIndex] = graph;
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:9,代码来源:GridNode.cs

示例3: DrawMaxClimb

		protected override void DrawMaxClimb (GridGraph graph) {
			var layerGridGraph = graph as LayerGridGraph;

			base.DrawMaxClimb(graph);
			layerGridGraph.maxClimb = Mathf.Clamp(layerGridGraph.maxClimb, 0, layerGridGraph.characterHeight);

			if (layerGridGraph.maxClimb == layerGridGraph.characterHeight) {
				EditorGUILayout.HelpBox("Max climb needs to be smaller or equal to character height", MessageType.Info);
			}
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:10,代码来源:LayerGridGraphEditor.cs

示例4: DrawMiddleSection

		protected override void DrawMiddleSection (GridGraph graph) {
			var layerGridGraph = graph as LayerGridGraph;

			DrawNeighbours(graph);

			layerGridGraph.characterHeight = EditorGUILayout.FloatField("Character Height", layerGridGraph.characterHeight);
			DrawMaxClimb(graph);

			DrawMaxSlope(graph);
			DrawErosion(graph);

			layerGridGraph.mergeSpanRange = EditorGUILayout.FloatField("Merge Span Range", layerGridGraph.mergeSpanRange);
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:13,代码来源:LayerGridGraphEditor.cs

示例5: DrawFirstSection

		void DrawFirstSection (GridGraph graph) {
			DrawWidthDepthFields (graph);

			newNodeSize = EditorGUILayout.FloatField (new GUIContent ("Node size","The size of a single node. The size is the side of the node square in world units"),graph.nodeSize);

			newNodeSize = newNodeSize <= 0.01F ? 0.01F : newNodeSize;

			float prevRatio = graph.aspectRatio;
			graph.aspectRatio = EditorGUILayout.FloatField (new GUIContent ("Aspect Ratio","Scaling of the nodes width/depth ratio. Good for isometric games"),graph.aspectRatio);

			DrawIsometricField(graph);

			if (graph.nodeSize != newNodeSize || prevRatio != graph.aspectRatio) {
				if (!locked) {
					graph.nodeSize = newNodeSize;
					Matrix4x4 oldMatrix = graph.matrix;
					graph.GenerateMatrix ();
					if (graph.matrix != oldMatrix) {
						//Rescann the graphs
						//AstarPath.active.AutoScan ();
						GUI.changed = true;
					}
				} else {
					int tmpWidth = graph.width;
					int tmpDepth = graph.depth;

					float delta = newNodeSize / graph.nodeSize;
					graph.nodeSize = newNodeSize;
					graph.unclampedSize = RoundVector3 (new Vector2 (tmpWidth*graph.nodeSize,tmpDepth*graph.nodeSize));
					Vector3 newCenter = graph.matrix.MultiplyPoint3x4 (new Vector3 ((tmpWidth/2F)*delta,0,(tmpDepth/2F)*delta));
					graph.center = RoundVector3 (newCenter);

					graph.GenerateMatrix ();

					//Make sure the width & depths stay the same
					graph.width = tmpWidth;
					graph.depth = tmpDepth;
					AutoScan ();
				}
			}

			DrawPositionField(graph);

			graph.rotation = EditorGUILayout.Vector3Field ("Rotation", graph.rotation);

			if (GUILayout.Button (new GUIContent ("Snap Size","Snap the size to exactly fit nodes"), GUILayout.MaxWidth (100), GUILayout.MaxHeight (16))) {
				SnapSizeToNodes (graph.width,graph.depth,graph);
			}
		}
开发者ID:JtheSpaceC,项目名称:Breaking-The-Rules,代码行数:49,代码来源:GridGeneratorEditor.cs

示例6: SetGridGraph

        public static int SetGridGraph(GridGraph graph)
        {
            if (gridGraphs == null) {
                gridGraphs = new GridGraph[1];
            } else {

                for (int i=0;i<gridGraphs.Length;i++) {
                    if (gridGraphs[i] == graph) {
                        return i;
                    }
                }

                GridGraph[] tmp = new GridGraph[gridGraphs.Length+1];
                for (int i=0;i<gridGraphs.Length;i++) {
                    tmp[i] = gridGraphs[i];
                }
                gridGraphs = tmp;
            }

            gridGraphs[gridGraphs.Length-1] = graph;
            return gridGraphs.Length-1;
        }
开发者ID:shreshtabm,项目名称:Fight-for-Zion-Mobile-Game,代码行数:22,代码来源:GridNode.cs

示例7: RemoveGridGraph

        public static void RemoveGridGraph(GridGraph graph)
        {
            if (gridGraphs == null) {
                return;
            }

            for (int i=0;i<gridGraphs.Length;i++) {
                if (gridGraphs[i] == graph) {
                    if (gridGraphs.Length == 1) {
                        gridGraphs = null;
                        return;
                    }

                    for (int j=i+1;j<gridGraphs.Length;j++) {

                        GridGraph gg = gridGraphs[j];

                        if (gg.nodes != null) {
                            for (int n=0;n<gg.nodes.Length;n++) {
                                if (gg.nodes[n] != null)
                                    ((GridNode)gg.nodes[n]).SetGridIndex (j-1);
                            }
                        }
                    }

                    GridGraph[] tmp = new GridGraph[gridGraphs.Length-1];
                    for (int j=0;j<i;j++) {
                        tmp[j] = gridGraphs[j];
                    }
                    for (int j=i+1;j<gridGraphs.Length;j++) {
                        tmp[j-1] = gridGraphs[j];
                    }
                    return;
                }
            }
        }
开发者ID:shreshtabm,项目名称:Fight-for-Zion-Mobile-Game,代码行数:36,代码来源:GridNode.cs

示例8: SnapSizeToNodes

		public void SnapSizeToNodes (int newWidth, int newDepth, GridGraph graph) {
			//Vector2 preSize = graph.unclampedSize;
			
			/*if (locked) {
				graph.unclampedSize = new Vector2 (newWidth*newNodeSize,newDepth*newNodeSize);
				graph.nodeSize = newNodeSize;
				graph.GenerateMatrix ();
				Vector3 newCenter = graph.matrix.MultiplyPoint3x4 (new Vector3 (newWidth/2F,0,newDepth/2F));
				graph.center = newCenter;
				AstarPath.active.AutoScan ();
			} else {*/
				graph.unclampedSize = new Vector2 (newWidth*graph.nodeSize,newDepth*graph.nodeSize);
				Vector3 newCenter = graph.matrix.MultiplyPoint3x4 (new Vector3 (newWidth/2F,0,newDepth/2F));
				graph.center = newCenter;
				graph.GenerateMatrix ();
				AstarPath.active.AutoScan ();
			//}
			
			GUI.changed = true;
		}
开发者ID:JoseRego,项目名称:summer-rush,代码行数:20,代码来源:GridGeneratorEditor.cs

示例9: SaveReferenceTexture

		public void SaveReferenceTexture (GridGraph graph) {
			//GridGraph graph = target as GridGraph;
			
			if (graph.nodes == null || graph.nodes.Length != graph.width * graph.depth) {
				AstarPath.active.Scan ();
			}
			
			if (graph.nodes.Length != graph.width * graph.depth) {
				Debug.LogError ("Couldn't create reference image since width*depth != nodes.Length");
				return;
			}
			
			if (graph.nodes.Length == 0) {
				Debug.LogError ("Couldn't create reference image since the graph is too small (0*0)");
				return;
			}
			
			Texture2D tex = new Texture2D (graph.width,graph.depth);
			
			float maxY = float.NegativeInfinity;
			for (int i=0;i<graph.nodes.Length;i++) {
				Vector3 p = graph.inverseMatrix.MultiplyPoint ((Vector3)graph.nodes[i].position);
				maxY = p.y > maxY ? p.y : maxY;
			}
			
			Color[] cols = new Color[graph.width*graph.depth];
			
			for (int z=0;z<graph.depth;z++) {
				for (int x=0;x<graph.width;x++) {
					GraphNode node = graph.nodes[z*graph.width+x];
					float v = node.Walkable ? 1F : 0.0F;
					Vector3 p = graph.inverseMatrix.MultiplyPoint ((Vector3)node.position);
					float q = p.y / maxY;
					cols[z*graph.width+x] = new Color (v,q,0);
				}
			}
			tex.SetPixels (cols);
			tex.Apply ();
			
			string path = AssetDatabase.GenerateUniqueAssetPath ("Assets/gridReference.png");
			
			using (System.IO.StreamWriter outstream = new System.IO.StreamWriter (path)) {
				using (System.IO.BinaryWriter outfile = new System.IO.BinaryWriter (outstream.BaseStream)) {
					outfile.Write (tex.EncodeToPNG ());
				}
			}
			AssetDatabase.Refresh ();
			Object obj = AssetDatabase.LoadAssetAtPath (path,typeof (Texture));
			
			EditorGUIUtility.PingObject (obj);
		}
开发者ID:JoseRego,项目名称:summer-rush,代码行数:51,代码来源:GridGeneratorEditor.cs

示例10: DrawJPS

		protected virtual void DrawJPS (GridGraph graph) {
			// Jump point search is a pro only feature
		}
开发者ID:JtheSpaceC,项目名称:Breaking-The-Rules,代码行数:3,代码来源:GridGeneratorEditor.cs

示例11: DrawLastSection

		void DrawLastSection (GridGraph graph) {
			GUILayout.Label (new GUIContent ("Advanced"), EditorStyles.boldLabel);

			DrawPenaltyModifications (graph);
			DrawJPS (graph);
		}
开发者ID:JtheSpaceC,项目名称:Breaking-The-Rules,代码行数:6,代码来源:GridGeneratorEditor.cs

示例12: UpdateShortcuts

 public void UpdateShortcuts()
 {
     navmesh = (NavMeshGraph)FindGraphOfType (typeof(NavMeshGraph));
     gridGraph = (GridGraph)FindGraphOfType (typeof(GridGraph));
     listGraph = (ListGraph)FindGraphOfType (typeof(ListGraph));
 }
开发者ID:arcoelho01,项目名称:astrochimps,代码行数:6,代码来源:AstarData.cs

示例13: DrawJPS

		protected virtual void DrawJPS (GridGraph graph) {
			graph.useJumpPointSearch = EditorGUILayout.Toggle(new GUIContent("Use Jump Point Search", "Jump Point Search can significantly speed up pathfinding. But only works on uniformly weighted graphs"), graph.useJumpPointSearch);
			if (graph.useJumpPointSearch) {
				EditorGUILayout.HelpBox("Jump Point Search assumes that there are no penalties applied to the graph. Tag penalties cannot be used either.", MessageType.Warning);

#if !ASTAR_JPS
				EditorGUILayout.HelpBox("JPS needs to be enabled using a compiler directive before it can be used.\n" +
					"Enabling this will add ASTAR_JPS to the Scriping Define Symbols field in the Unity Player Settings", MessageType.Warning);
				if (GUILayout.Button("Enable Jump Point Search support")) {
					OptimizationHandler.EnableDefine("ASTAR_JPS");
				}
#endif
			} else {
#if ASTAR_JPS
				EditorGUILayout.HelpBox("If you are not using JPS in any scene, you can disable it to save memory", MessageType.Info);
				if (GUILayout.Button("Disable Jump Point Search support")) {
					OptimizationHandler.DisableDefine("ASTAR_JPS");
				}
#endif
			}
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:21,代码来源:GridGeneratorEditor.cs

示例14: DrawCutCorners

		protected virtual void DrawCutCorners (GridGraph graph) {
			graph.cutCorners = EditorGUILayout.Toggle(new GUIContent("Cut Corners", "Enables or disables cutting corners. See docs for image example"), graph.cutCorners);
			if (!graph.cutCorners && graph.useJumpPointSearch) {
				EditorGUILayout.HelpBox("Jump Point Search only works if 'Cut Corners' is enabled.", MessageType.Error);
			}
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:6,代码来源:GridGeneratorEditor.cs

示例15: DrawCutCorners

		protected override void DrawCutCorners (GridGraph graph) {
			// No corner cutting since only 4 neighbours are possible
		}
开发者ID:Alx666,项目名称:ProjectPhoenix,代码行数:3,代码来源:LayerGridGraphEditor.cs


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