本文整理匯總了C#中System.Objects.ResetGrid方法的典型用法代碼示例。如果您正苦於以下問題:C# Objects.ResetGrid方法的具體用法?C# Objects.ResetGrid怎麽用?C# Objects.ResetGrid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Objects
的用法示例。
在下文中一共展示了Objects.ResetGrid方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: GetTilesToLocation
/// <summary>
/// Gets a collection of pathfinder nodes to a given location. Returns 0 elements if unsuccessful.
/// </summary>
/// <param name="c">The client to perform the operation on.</param>
/// <param name="loc">The location to reach.</param>
/// <param name="tiles">A list of tiles to use for pathfinding.</param>
/// <param name="pathFinder">The pathfinder to use.</param>
/// <param name="considerPlayerWalkable">Whether to consider the player as walkable.</param>
/// <param name="considerCreatureOnLocationWalkable">Whether to consider any creatures on the target location as walkable.</param>
/// <returns></returns>
public IEnumerable<Objects.PathFinder.Node> GetTilesToLocation(Objects.Client c,
Location loc, Map.TileCollection tiles, Objects.PathFinder pathFinder,
bool considerPlayerWalkable = false, bool considerCreatureOnLocationWalkable = false)
{
if (pathFinder == null) return Enumerable.Empty<Objects.PathFinder.Node>();
//return pathFinder.
if (!this.IsOnScreen(c.Player.Location)) return Enumerable.Empty<Objects.PathFinder.Node>();
uint playerId = c.Player.ID;
Map.Tile playerTile = tiles.GetTile(count: playerId);
Map.Tile fromTile = tiles.GetTile(this);
Map.Tile targetTile = tiles.GetTile(loc);
if (playerTile == null || fromTile == null || targetTile == null) return Enumerable.Empty<Objects.PathFinder.Node>();
// check if target tile is walkable
if (!targetTile.IsWalkable() && (!considerPlayerWalkable || targetTile != playerTile)) return Enumerable.Empty<Objects.PathFinder.Node>();
if (fromTile == targetTile) return Enumerable.AsEnumerable(new Objects.PathFinder.Node[] { new Objects.PathFinder.Node() });
lock (pathFinder)
{
pathFinder.ResetGrid();
foreach (Map.Tile tile in tiles.GetTiles())
{
if (tile == null) continue;
if ((considerPlayerWalkable && tile == playerTile) || tile.IsWalkable()) pathFinder.Grid[tile.MemoryLocation.X, tile.MemoryLocation.Y] = 1;
else pathFinder.Grid[tile.MemoryLocation.X, tile.MemoryLocation.Y] = (byte)Enums.MiniMapSpeedValues.Unwalkable;
}
pathFinder.Grid[fromTile.MemoryLocation.X, fromTile.MemoryLocation.Y] = 1;
return pathFinder.FindPath(fromTile.MemoryLocation, targetTile.MemoryLocation);
}
}