本文整理汇总了C#中Path类的典型用法代码示例。如果您正苦于以下问题:C# Path类的具体用法?C# Path怎么用?C# Path使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Path类属于命名空间,在下文中一共展示了Path类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:bittercoder,项目名称:Windsor,代码行数:7,代码来源:can_chjail_absolute_path_spec.cs
示例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;
}
开发者ID:jlvermeulen,项目名称:algorithms-and-data-structures,代码行数:33,代码来源:Path.cs
示例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;
}
开发者ID:ManChildMan,项目名称:Crypt-of-Yrion,代码行数:39,代码来源:MonsterControllerV2.cs
示例4: SavePath
public static void SavePath(Path path3D, string filePath)
{
using (StreamWriter sw = new StreamWriter(filePath, false))
{
sw.Write(path3D);
}
}
开发者ID:ValMomchilova,项目名称:TelerikAcademyHomeWorks,代码行数:7,代码来源:PathStorage+.cs
示例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;
}
开发者ID:jamaldt,项目名称:telerikacademy,代码行数:35,代码来源:PathStorage.cs
示例6: PathReadyEventPayload
public PathReadyEventPayload(
GameObject gameObject,
Path path)
{
this.gameObject = gameObject;
this.path = path;
}
开发者ID:B-Rich,项目名称:377asn4,代码行数:7,代码来源:PathManager.cs
示例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;
}
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:12,代码来源:ManualPath.cs
示例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);
}
开发者ID:andrewstarnes,项目名称:wwtd2,代码行数:37,代码来源:ProgressiveVectorField.cs
示例9: LinkTo
public IDirectory LinkTo(Path path)
{
Contract.Requires(path != null);
Contract.Ensures(Contract.Result<IDirectory>() != null);
throw new NotImplementedException();
}
开发者ID:hammett,项目名称:Castle.Transactions,代码行数:7,代码来源:IDirectoryContract.cs
示例10: OnPath
private void OnPath(Path p)
{
if (p.Success)
{
path = p;
}
}
开发者ID:Unknown-Studios,项目名称:OneRiver,代码行数:7,代码来源:Test.cs
示例11: OnPathComplete
public void OnPathComplete( Path p )
{
if ( !p.error ) {
path = p;
currentWayPoint = 0;
}
}
开发者ID:Hanteus,项目名称:Awoken,代码行数:7,代码来源:FlyingMonsterAItoOrigin.cs
示例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 }
};
}
开发者ID:pdaniil,项目名称:ProjectAtlas,代码行数:31,代码来源:MapPageViewModel.cs
示例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;
}
开发者ID:monikaBchvarova,项目名称:C-Sharp,代码行数:31,代码来源:PathStorage.cs
示例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;
}
开发者ID:Jarolim,项目名称:AllMyHomeworkForTelerikAcademy,代码行数:31,代码来源:PathStorage.cs
示例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;
}
开发者ID:Nikolay-D,项目名称:TelerikSchoolAcademy,代码行数:30,代码来源:PathStorage.cs
示例16: OnPathComplete
/** Called when a path has completed it's calculation */
public void OnPathComplete (Path p) {
/*if (Time.time-lastPathSearch >= repathRate) {
Repath ();
} else {*/
StartCoroutine (WaitToRepath ());
//}
//If the path didn't succeed, don't proceed
if (p.error) {
return;
}
//Get the calculated path as a Vector3 array
path = p.vectorPath.ToArray();
//Find the segment in the path which is closest to the AI
//If a closer segment hasn't been found in '6' iterations, break because it is unlikely to find any closer ones then
float minDist = Mathf.Infinity;
int notCloserHits = 0;
for (int i=0;i<path.Length-1;i++) {
float dist = AstarMath.DistancePointSegmentStrict (path[i],path[i+1],tr.position);
if (dist < minDist) {
notCloserHits = 0;
minDist = dist;
pathIndex = i+1;
} else if (notCloserHits > 6) {
break;
}
}
}
开发者ID:henryj41043,项目名称:TheUnseen,代码行数:33,代码来源:AIFollow.cs
示例17: LoadPathsFromFile
public static List<Path> LoadPathsFromFile()
{
var paths = new List<Path>();
var pathReader = new StreamReader(LoadFilePath);
using (pathReader)
{
int numberOfPaths = int.Parse(pathReader.ReadLine());
for (int i = 0; i < numberOfPaths; i++)
{
int numberOfPointsinPath = int.Parse(pathReader.ReadLine());
var path = new Path();
string[] currentLine;
for (int k = 0; k < numberOfPointsinPath; k++)
{
currentLine = pathReader.ReadLine().Split(new[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
double x = double.Parse(currentLine[0]);
double y = double.Parse(currentLine[1]);
double z = double.Parse(currentLine[2]);
path.AddPoint(new Point3D(x, y, z));
}
paths.Add(path);
}
}
return paths;
}
开发者ID:tdochev,项目名称:TelerikAcademy,代码行数:27,代码来源:PathStorage.cs
示例18: LoadPath
//In my text files there are more than just one path, because I decided that different paths could be added in txt files with the same names.
public static void LoadPath(string pathName)
{
try
{
var reader = new StreamReader(String.Format("{0}.txt", pathName));
using (reader)
{
string buffer = reader.ReadLine();
do
{
double[] coordinates = buffer
.Split(',')
.Select(double.Parse)
.ToArray();
Path currentPath = new Path();
for (int i = 0; i < coordinates.Length; i += 3)
{
Point3D currentPoint = new Point3D(coordinates[i], coordinates[i + 1], coordinates[i + 2]);
currentPath.Sequence.Add(currentPoint);
}
pathes.Add(currentPath);
buffer = reader.ReadLine();
}
while (buffer != null);
}
}
catch (FileNotFoundException)
{
Console.WriteLine("The file could not be found!");
}
}
开发者ID:AYankova,项目名称:Telerik-Academy-HW,代码行数:32,代码来源:PathStorage.cs
示例19: ExtractFilesFromMsi
/// <summary>
/// Extracts some or all of the files from the specified MSI and returns a <see cref="FileEntryGraph"/> representing the files that were extracted.
/// </summary>
/// <param name="msiFileName">The msi file to extract or null to extract all files.</param>
/// <param name="fileNamesToExtractOrNull">The files to extract from the MSI or null to extract all files.</param>
/// <param name="outputDir">A relative directory to extract output to or an empty string to use the default output directory.</param>
/// <param name="skipReturningFileEntryGraph">True to return the <see cref="FileEntryGraph"/>. Otherwise null will be returned.</param>
protected FileEntryGraph ExtractFilesFromMsi(string msiFileName, string[] fileNamesToExtractOrNull, Path outputDir, bool returnFileEntryGraph)
{
outputDir = GetTestOutputDir(outputDir, msiFileName);
if (FileSystem.Exists(outputDir))
{
FileSystem.RemoveDirectory(outputDir, true);
}
Debug.Assert(!FileSystem.Exists(outputDir), "Directory still exists!");
FileSystem.CreateDirectory(outputDir);
//ExtractViaCommandLine(outputDir, msiFileName);
ExtractInProcess(msiFileName, outputDir.PathString, fileNamesToExtractOrNull);
if (returnFileEntryGraph)
{
// build actual file entries extracted
var actualEntries = FileEntryGraph.GetActualEntries(outputDir.PathString, msiFileName);
// dump to actual dir (for debugging and updating tests)
actualEntries.Save(GetActualOutputFile(msiFileName));
return actualEntries;
}
else
{
return null;
}
}
开发者ID:jozefizso,项目名称:lessmsi,代码行数:33,代码来源:TestBase.cs
示例20: LoadPathOfFile
public static Path LoadPathOfFile(string fileName)
{
Path path = new Path();
using (StreamReader sr = new StreamReader(fileName))
{
string input = sr.ReadToEnd();
string pattern = "{([\\d,.]+), ([\\d,.]+), ([\\d,.]+)}";
var reg = new Regex(pattern);
var matchs = reg.Matches(input);
if (matchs.Count <= 0)
{
throw new ApplicationException("Invalid data in file " + fileName);
}
foreach (Match match in matchs)
{
double x = double.Parse(match.Groups[1].Value);
double y = double.Parse(match.Groups[2].Value);
double z = double.Parse(match.Groups[3].Value);
Point p = new Point(x, y, z);
path.AddPoint(p);
}
}
return path;
}
开发者ID:ScreeM92,项目名称:Software-University,代码行数:31,代码来源:Storage.cs
注:本文中的Path类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论