小编Joe*_*oel的帖子

Regex.Split()在保留空格的同时判断单词

我正在使用Regex.Split()用户输入并将其转换为列表中的单个单词,但目前它删除了他们添加的任何空格,我希望它保留空白.

string[] newInput = Regex.Split(updatedLine, @"\s+");
Run Code Online (Sandbox Code Playgroud)

c# regex split

5
推荐指数
1
解决办法
3324
查看次数

如何加快我的A*寻路速度?

当没有障碍物移动或从障碍物的顶部移动到侧面时,我的寻路工作正常,但是当它需要从障碍物的顶部到底部找到它时,它太慢了.

我很确定这是我排序每个循环或循环通过封闭集的方式,但我不知道如何避免这种情况,因为在Windows Phone 7上没有SortedLists

//This Vivid Destination means it doesn't have to find the exact location 
//which is helpful as it is continuous environment  
Rectangle vividDestination = new Rectangle((int)character.destination.X - 10, (int)character.destination.Y - 10, 20, 20);

while (!vividDestination.Contains(Maths.vectorToPoint(OpenNodes[0].position)))
{
    Node Current = OpenNodes[0];
    OpenNodes.RemoveAt(0);
    ClosedNodes.Add(Current);
    Current.calculateNeightbours();

    foreach (Node neighbour in Current.neighbours)
    {
        neighbour.parents = Current.parents + 1;
        //The cost of the node is the amount of parent nodes + the distance to destination
        neighbour.cost = calculateCost(neighbour.position, character.destination, neighbour.parents);

        for (int …
Run Code Online (Sandbox Code Playgroud)

c# xna path-finding windows-phone-7

-1
推荐指数
1
解决办法
872
查看次数

标签 统计

c# ×2

path-finding ×1

regex ×1

split ×1

windows-phone-7 ×1

xna ×1