本文整理汇总了C#中Path类的典型用法代码示例。如果您正苦于以下问题:C# Path类的具体用法?C# Path怎么用?C# Path使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于命名空间,在下文中一共展示了Path类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: given_different_methods_of_saying_here_in_this_folder
public void given_different_methods_of_saying_here_in_this_folder()
{
an_absolute_path = Environment.CurrentDirectory.ToPath().Combine("chjailing");
a_relative_path = new Path(".").Combine("chjailing");
a_relative_path_with_drive = new Path("C:./").Combine("chjailing");
a_relative_path_with_drive2 = new Path("C:.").Combine("chjailing");
}
示例2: FromParents
/// <summary>
/// Generate a path from a set of single-source parent pointers.
/// </summary>
/// <param name="from">The start of the path.</param>
/// <param name="to">The end of the path.</param>
/// <param name="parents">The set of single-source parent pointers.</param>
/// <param name="graph">The graph to find the path in.</param>
/// <returns>The path between <paramref name="from"/> and <paramref name="to"/>, if one exists; <code>null</code> otherwise.</returns>
public static Path FromParents(uint from, uint to, Dictionary<uint, uint> parents, Graph graph)
{
if (!parents.ContainsKey(to))
return null;
Path path = new Path();
path.Vertices.Add(graph.Vertices[to]);
uint current = to, parent;
while (parents.TryGetValue(current, out parent))
{
Vertex v = graph.Vertices[parent];
Edge e = v.Neighbours[current];
path.Edges.Add(e);
path.Vertices.Add(v);
path.Weight += e.Weight;
path.Capacity = Math.Min(path.Capacity, e.Capacity);
current = parent;
}
path.Edges.Reverse();
path.Vertices.Reverse();
return path;
}
示例3: DetectPlayer
/// <summary>
///
/// </summary>
/// <returns></returns>
private bool DetectPlayer()
{
// Check if the player is within detection range, and if so, attempt
// detection.
if (m_playerDistance < MaxDetectionDistance)
{
// Calculate the chance of detection based on the range to
// the player.
float playerDetectionChance = LinearTransform(m_playerDistance, 0,
MaxDetectionDistance, MaxDetectionChance, 0);
if (Random.value < playerDetectionChance)
{
if (m_seeker.IsDone())
{
// If we have detected the player, attempt to get a path.
Path path = m_seeker.StartPath(transform.position,
Player.transform.position);
if (!path.error)
{
// Reset pathfinding variables.
m_lastPathfindingUpdate = 0f;
m_currentPath = path;
m_currentWaypoint = 0;
// Change the change to skeleton state and update animation
// variables.
m_mode = SkeletonMode.Hunting;
m_animator.SetFloat("Speed", 1);
return true;
}
}
}
}
return false;
}
示例4: SavePath
public static void SavePath(Path path3D, string filePath)
{
using (StreamWriter sw = new StreamWriter(filePath, false))
{
sw.Write(path3D);
}
}
示例5: LoadPath
public static Path LoadPath(string filePath)
{
if (String.IsNullOrWhiteSpace(filePath))
{
throw new ArgumentException("File name cannot be null or empty.");
}
if (!File.Exists(filePath))
{
throw new ArgumentException("The specified file doesn't exist in the local file system.");
}
Path path = new Path();
using (StreamReader fileReader = new StreamReader(filePath))
{
string line;
while ((line = fileReader.ReadLine()) != null)
{
string[] coordinates = line.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries);
int x;
int y;
int z;
if (coordinates.Length == 3 &&
Int32.TryParse(coordinates[0], out x) &&
Int32.TryParse(coordinates[1], out y) &&
Int32.TryParse(coordinates[2], out z))
{
Point3D point = new Point3D(x, y, z);
path.AddPoint(point);
}
}
}
return path;
}
示例6: PathReadyEventPayload
public PathReadyEventPayload(
GameObject gameObject,
Path path)
{
this.gameObject = gameObject;
this.path = path;
}
示例7: ManualPath
/// <summary>
/// Initializes a new instance of the <see cref="ManualPath"/> class.
/// </summary>
/// <param name="replanCallback">The replan callback.</param>
/// <param name="path">The path.</param>
public ManualPath(Replan replanCallback, Path path)
{
Ensure.ArgumentNotNull(path, "path");
this.onReplan = replanCallback;
this.path = path;
}
示例8: ProgressiveVectorField
/// <summary>
/// Initializes a new instance of the <see cref="ProgressiveVectorField"/> class.
/// </summary>
/// <param name="group">The group.</param>
/// <param name="path">The path.</param>
/// <param name="options">The options.</param>
public ProgressiveVectorField(TransientGroup<IUnitFacade> group, Path path, VectorFieldOptions options)
{
Ensure.ArgumentNotNull(group, "group");
this.group = group;
_currentPath = path;
var modelUnit = group.modelUnit;
_unitProperties = modelUnit;
var pathOptions = modelUnit.pathFinderOptions;
// cache options locally
_allowCornerCutting = pathOptions.allowCornerCutting;
_allowDiagonals = !pathOptions.preventDiagonalMoves;
_announceAllNodes = modelUnit.pathNavigationOptions.announceAllNodes;
_obstacleStrengthFactor = options.obstacleStrengthFactor;
_builtInContainment = options.builtInContainment;
_updateInterval = options.updateInterval;
_paddingIncrease = options.paddingIncrease;
_maxExtraPadding = options.maxExtraPadding;
_boundsPadding = options.boundsPadding;
_boundsRecalculateThreshold = options.boundsRecalculateThreshold;
_expectedGroupGrowthFactor = 1f + options.expectedGroupGrowthFactor;
// pre-allocate lists memory
_openSet = new SimpleQueue<Cell>(31);
_tempWalkableNeighbours = new DynamicArray<Cell>(8);
_extraTempWalkableNeighbours = new DynamicArray<Cell>(8);
_groupBounds = new RectangleXZ(group.centerOfGravity, _boundsPadding, _boundsPadding);
}
示例9: LinkTo
public IDirectory LinkTo(Path path)
{
Contract.Requires(path != null);
Contract.Ensures(Contract.Result<IDirectory>() != null);
throw new NotImplementedException();
}
示例10: OnPath
private void OnPath(Path p)
{
if (p.Success)
{
path = p;
}
}
示例11: OnPathComplete
public void OnPathComplete( Path p )
{
if ( !p.error ) {
path = p;
currentWayPoint = 0;
}
}
示例12: GetPath
private void GetPath(Path obj)
{
Connects = new ObservableCollection<Connector>();
Points = new ObservableCollection<Point>(
obj.Points.Select(x => new Point()
{
X = ((x.From.X < 0) ? Math.Abs(Math.Abs(x.From.X) - 4096) : Math.Abs(x.From.X) + 4096),
Y = ((x.From.Z > 0) ? Math.Abs(Math.Abs(x.From.Z) - 5632) : Math.Abs(x.From.Z) + 5632)
})
);
for(int i = 0; i < Points.Count - 1; i++)
Connects.Add(new Connector()
{
StartPoint = Points[i],
EndPoint = Points[i+1]
});
Connects.Add(new Connector()
{
StartPoint = Points[Points.Count - 1],
EndPoint = Points[0]
});
Collection = new CompositeCollection()
{
new CollectionContainer() { Collection = Points },
new CollectionContainer() { Collection = Connects }
};
}
示例13: Load
public static Path Load(string pathName)
{
Path path = new Path();
string fullPath = GenerateFullPath(pathName);
try
{
using (var reader = new StreamReader(fullPath))
{
string[] points = reader.ReadToEnd()
.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
foreach (var point in points)
{
double[] coordinates = point.Trim('[').Trim(']')
.Split(new[] { ' ', ';', 'X', 'Y', 'Z', ':' }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => double.Parse(x))
.ToArray();
path.AddPoint(new Point3D(coordinates[0], coordinates[1], coordinates[2]));
}
}
}
catch (FileNotFoundException)
{
Console.WriteLine("The path \"{0}\" couldn't be found", pathName);
return null;
}
return path;
}
示例14: ReadPathFromFile
/// <summary>
/// Reads a path of 3D points from the Location/fileName that cane be set through the properties PathName and FileName
/// </summary>
/// <returns>Collection of Point3D</returns>
static public Path ReadPathFromFile()
{
Path resultPath = new Path();
StreamReader reader = new StreamReader(Location + FileName);
string fileContents;
string[] splitters = { "--", "\n", "[", "]", ",", ":","Point","->","\r\n"," "};
//reads the contents of file
using (reader)
{
fileContents = reader.ReadToEnd();
}
//points is an array of strings containing ine [0] - the Path name and in all next 4-s - Point3d
string[] points = fileContents.Split(splitters, StringSplitOptions.RemoveEmptyEntries);
//first is the name of the whole path
resultPath.Name = points[0];
//for every 4 elements in the points array get the nex Point X,Y,Z and Name and put them in a new instance of point
for (int i = 1; i < points.Length; i += 4)
{
Point3D nextPoint = new Point3D(int.Parse(points[i + 1]), int.Parse(points[i + 2]), int.Parse(points[i + 3]), points[i]);
resultPath.PathAddPoint = nextPoint;
}
return resultPath;
}
示例15: LoadPath
internal static Path LoadPath()
{
Path loadPath = new Path();
try
{
using (StreamReader reader = new StreamReader(@"../../savedPaths.txt"))
{
while (reader.Peek() >= 0)
{
String line = reader.ReadLine();
String[] splittedLine = line.Split(new char[] { '(', ',', ')' }, StringSplitOptions.RemoveEmptyEntries);
loadPath.AddPoint(new Point3D(int.Parse(splittedLine[0]), int.Parse(splittedLine[1]), int.Parse(splittedLine[2])));
}
}
}
catch (FileNotFoundException)
{
Console.WriteLine("File not found, try adding a new file");
}
catch (IOException io)
{
Console.WriteLine(io.Message);
}
catch (OutOfMemoryException ome)
{
Console.WriteLine(ome.Message);
}
finally { }
return loadPath;
}