Before changing Piece[,] to Dictionary<string,Piece>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
|
||||
@@ -34,7 +35,7 @@ namespace PathFinding
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var element = collection[origin.X, origin.Y];
|
||||
var element = collection[origin.Y, origin.X];
|
||||
if (element == null) return false;
|
||||
|
||||
var path = FindDirectionTowardsDestination(element.MoveSet.GetMoves(), origin, destination);
|
||||
@@ -49,7 +50,7 @@ namespace PathFinding
|
||||
while (shouldPath && next != destination)
|
||||
{
|
||||
next = Vector2.Add(next, path.Direction);
|
||||
var collider = collection[(int)next.X, (int)next.Y];
|
||||
var collider = collection[(int)next.Y, (int)next.X];
|
||||
if (collider != null)
|
||||
{
|
||||
callback?.Invoke(collider, next);
|
||||
@@ -65,14 +66,19 @@ namespace PathFinding
|
||||
|
||||
public void PathEvery(Vector2 from, Callback callback)
|
||||
{
|
||||
var element = collection[from.X, from.Y];
|
||||
var element = collection[from.Y, from.X];
|
||||
if (element == null)
|
||||
{
|
||||
Console.WriteLine("Null element in PathEvery");
|
||||
return;
|
||||
}
|
||||
foreach (var path in element.MoveSet.GetMoves())
|
||||
{
|
||||
var shouldPath = true;
|
||||
var next = Vector2.Add(from, path.Direction); ;
|
||||
while (shouldPath && next.X < width && next.Y < height && next.X >= 0 && next.Y >= 0)
|
||||
{
|
||||
var collider = collection[(int)next.X, (int)next.Y];
|
||||
var collider = collection[(int)next.Y, (int)next.X];
|
||||
if (collider != null)
|
||||
{
|
||||
callback(collider, next);
|
||||
@@ -97,7 +103,7 @@ namespace PathFinding
|
||||
var next = Vector2.Add(origin, direction);
|
||||
while (next.X >= 0 && next.X < width && next.Y >= 0 && next.Y < height)
|
||||
{
|
||||
var element = collection[next.X, next.Y];
|
||||
var element = collection[next.Y, next.X];
|
||||
if (element != null) callback(element, next);
|
||||
next = Vector2.Add(next, direction);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user