本文整理汇总了C#中Pathfinding.IntRect.Expand方法的典型用法代码示例。如果您正苦于以下问题:C# IntRect.Expand方法的具体用法?C# IntRect.Expand怎么用?C# IntRect.Expand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pathfinding.IntRect
的用法示例。
在下文中一共展示了IntRect.Expand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateArea
public void UpdateArea (GraphUpdateObject guo) {
Bounds b = guo.bounds;
b.center -= forcedBounds.min;
//Figure out which tiles are affected
IntRect r = new IntRect (Mathf.FloorToInt (b.min.x / (tileSizeX*cellSize)), Mathf.FloorToInt (b.min.z / (tileSizeZ*cellSize)), Mathf.FloorToInt (b.max.x / (tileSizeX*cellSize)), Mathf.FloorToInt (b.max.z / (tileSizeZ*cellSize)));
//Clamp to bounds
r = IntRect.Intersection (r, new IntRect (0,0,tileXCount-1,tileZCount-1));
if (!guo.updatePhysics) {
for ( int z=r.ymin;z<=r.ymax;z++) {
for ( int x=r.xmin;x<=r.xmax;x++) {
NavmeshTile tile = tiles[z*tileXCount + x];
tile.flag = true;
}
}
for ( int z=r.ymin;z<=r.ymax;z++) {
for ( int x=r.xmin;x<=r.xmax;x++) {
NavmeshTile tile = tiles[z*tileXCount + x];
if ( tile.flag ) {
tile.flag = false;
NavMeshGraph.UpdateArea (guo, tile);
}
}
}
return;
}
if (!dynamic) {
throw new System.Exception ("Recast graph must be marked as dynamic to enable graph updates with updatePhysics = true");
}
Voxelize vox = globalVox;
if (vox == null) {
throw new System.InvalidOperationException ("No Voxelizer object. UpdateAreaInit should have been called before this function.");
}
AstarProfiler.StartProfile ("Init");
/** \bug No bounds checking */
//r.DebugDraw (Matrix4x4.TRS (forcedBounds.min, Quaternion.identity, new Vector3 (tileSize*cellSize, 1, tileSize*cellSize)), Color.red);
//Debug.Break ();
AstarProfiler.StartProfile ("RemoveConnections");
for (int x=r.xmin;x<=r.xmax;x++) {
for (int z=r.ymin;z<=r.ymax;z++) {
RemoveConnectionsFromTile (tiles[x + z*tileXCount]);
}
}
AstarProfiler.EndProfile ("RemoveConnections");
AstarProfiler.StartProfile ("Build Tiles");
for (int x=r.xmin;x<=r.xmax;x++) {
for (int z=r.ymin;z<=r.ymax;z++) {
BuildTileMesh (vox, x,z);
}
}
AstarProfiler.EndProfile ("Build Tiles");
AstarProfiler.StartProfile ("ConnectTiles");
uint graphIndex = (uint)AstarPath.active.astarData.GetGraphIndex (this);
for (int x=r.xmin;x<=r.xmax;x++) {
for (int z=r.ymin;z<=r.ymax;z++) {
NavmeshTile tile = tiles[x + z*tileXCount];
GraphNode[] nodes = tile.nodes;
for (int i=0;i<nodes.Length;i++) nodes[i].GraphIndex = graphIndex;
}
}
//Connect the newly create tiles with the old tiles and with each other
r = r.Expand (1);
//Clamp to bounds
//.........这里部分代码省略.........
示例2: UpdateArea
public void UpdateArea(GraphUpdateObject guo)
{
Bounds bounds = guo.bounds;
bounds.center -= this.forcedBounds.min;
IntRect a = new IntRect(Mathf.FloorToInt(bounds.min.x / ((float)this.tileSizeX * this.cellSize)), Mathf.FloorToInt(bounds.min.z / ((float)this.tileSizeZ * this.cellSize)), Mathf.FloorToInt(bounds.max.x / ((float)this.tileSizeX * this.cellSize)), Mathf.FloorToInt(bounds.max.z / ((float)this.tileSizeZ * this.cellSize)));
a = IntRect.Intersection(a, new IntRect(0, 0, this.tileXCount - 1, this.tileZCount - 1));
if (!guo.updatePhysics)
{
for (int i = a.ymin; i <= a.ymax; i++)
{
for (int j = a.xmin; j <= a.xmax; j++)
{
RecastGraph.NavmeshTile navmeshTile = this.tiles[i * this.tileXCount + j];
navmeshTile.flag = true;
}
}
for (int k = a.ymin; k <= a.ymax; k++)
{
for (int l = a.xmin; l <= a.xmax; l++)
{
RecastGraph.NavmeshTile navmeshTile2 = this.tiles[k * this.tileXCount + l];
if (navmeshTile2.flag)
{
navmeshTile2.flag = false;
NavMeshGraph.UpdateArea(guo, navmeshTile2);
}
}
}
return;
}
if (!this.dynamic)
{
throw new Exception("Recast graph must be marked as dynamic to enable graph updates with updatePhysics = true");
}
Voxelize voxelize = this.globalVox;
if (voxelize == null)
{
throw new InvalidOperationException("No Voxelizer object. UpdateAreaInit should have been called before this function.");
}
for (int m = a.xmin; m <= a.xmax; m++)
{
for (int n = a.ymin; n <= a.ymax; n++)
{
this.RemoveConnectionsFromTile(this.tiles[m + n * this.tileXCount]);
}
}
for (int num = a.xmin; num <= a.xmax; num++)
{
for (int num2 = a.ymin; num2 <= a.ymax; num2++)
{
this.BuildTileMesh(voxelize, num, num2);
}
}
uint graphIndex = (uint)AstarPath.active.astarData.GetGraphIndex(this);
for (int num3 = a.xmin; num3 <= a.xmax; num3++)
{
for (int num4 = a.ymin; num4 <= a.ymax; num4++)
{
RecastGraph.NavmeshTile navmeshTile3 = this.tiles[num3 + num4 * this.tileXCount];
GraphNode[] nodes = navmeshTile3.nodes;
for (int num5 = 0; num5 < nodes.Length; num5++)
{
nodes[num5].GraphIndex = graphIndex;
}
}
}
a = a.Expand(1);
a = IntRect.Intersection(a, new IntRect(0, 0, this.tileXCount - 1, this.tileZCount - 1));
for (int num6 = a.xmin; num6 <= a.xmax; num6++)
{
for (int num7 = a.ymin; num7 <= a.ymax; num7++)
{
if (num6 < this.tileXCount - 1 && a.Contains(num6 + 1, num7))
{
this.ConnectTiles(this.tiles[num6 + num7 * this.tileXCount], this.tiles[num6 + 1 + num7 * this.tileXCount]);
}
if (num7 < this.tileZCount - 1 && a.Contains(num6, num7 + 1))
{
this.ConnectTiles(this.tiles[num6 + num7 * this.tileXCount], this.tiles[num6 + (num7 + 1) * this.tileXCount]);
}
}
}
}