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


C# GridGraph.GenerateMatrix方法代码示例

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


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

示例1: 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) {
						//Rescan 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:Alx666,项目名称:ProjectPhoenix,代码行数:49,代码来源:GridGeneratorEditor.cs

示例2: 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

示例3: SnapSizeToNodes

		public void SnapSizeToNodes (int newWidth, int newDepth, GridGraph graph) {
			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 ();
			AutoScan ();

			GUI.changed = true;
		}
开发者ID:JtheSpaceC,项目名称:Breaking-The-Rules,代码行数:9,代码来源:GridGeneratorEditor.cs

示例4: DrawPositionField

		void DrawPositionField (GridGraph graph) {
			Vector3 pivotPoint;
			Vector3 diff;

			GUILayout.BeginHorizontal ();

			switch (pivot) {
				case GridPivot.Center:
					graph.center = RoundVector3 ( graph.center );
					graph.center = EditorGUILayout.Vector3Field ("Center",graph.center);
					break;
				case GridPivot.TopLeft:
					pivotPoint = graph.matrix.MultiplyPoint3x4 (new Vector3 (0,0,graph.depth));
					pivotPoint = RoundVector3 ( pivotPoint );
					diff = pivotPoint-graph.center;
					pivotPoint = EditorGUILayout.Vector3Field ("Top-Left",pivotPoint);
					graph.center = pivotPoint-diff;
					break;
				case GridPivot.TopRight:
					pivotPoint = graph.matrix.MultiplyPoint3x4 (new Vector3 (graph.width,0,graph.depth));
					pivotPoint = RoundVector3 ( pivotPoint );
					diff = pivotPoint-graph.center;
					pivotPoint = EditorGUILayout.Vector3Field ("Top-Right",pivotPoint);
					graph.center = pivotPoint-diff;
					break;
				case GridPivot.BottomLeft:
					pivotPoint = graph.matrix.MultiplyPoint3x4 (new Vector3 (0,0,0));
					pivotPoint = RoundVector3 ( pivotPoint );
					diff = pivotPoint-graph.center;
					pivotPoint = EditorGUILayout.Vector3Field ("Bottom-Left",pivotPoint);
					graph.center = pivotPoint-diff;
					break;
				case GridPivot.BottomRight:
					pivotPoint = graph.matrix.MultiplyPoint3x4 (new Vector3 (graph.width,0,0));
					pivotPoint = RoundVector3 ( pivotPoint );
					diff = pivotPoint-graph.center;
					pivotPoint = EditorGUILayout.Vector3Field ("Bottom-Right",pivotPoint);
					graph.center = pivotPoint-diff;
					break;
			}

			graph.GenerateMatrix ();

			pivot = PivotPointSelector (pivot);

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

示例5: updateGraph

 private void updateGraph(GridGraph g, Vector3 center)
 {
     g.center = center;
     Matrix4x4 m = g.matrix;
     g.GenerateMatrix();
     g.RelocateNodes (m, g.matrix);
     //Debug.Log("Graph updated!");
     return;
 }
开发者ID:jlonardi,项目名称:igp-DnM,代码行数:9,代码来源:GraphManager.cs


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