PotatoPlan/Game1/Sources/Pathing/A-Star/PathSaver/Path.cs
2020-05-04 01:50:43 +02:00

64 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Graphics;
class Path
{
private Nodes[] nodes = new Nodes[512];
private int Count = 0;
public void AddNode(Nodes node)
{
nodes[Count] = new Nodes(node);
Count++;
}
public Nodes Reduce()
{
Count--;
Nodes temp = nodes[0];
for (int i = 0; i < Count; i++)
{
nodes[i] = nodes[i + 1];
}
nodes[Count + 1] = null;
return temp;
}
public Path FlipArray()
{
int j = Count;
Nodes[] tempp = nodes;
Nodes[] newnode = new Nodes[Count];
Path newPath = new Path();
for (int i = 0; i < Count; i++)
{
newnode[i] = tempp[j - 1];
j--;
newPath.AddNode(newnode[i]);
}
return newPath;
}
public Nodes getFinalDest()
{
return nodes[Count];
}
public int getCount()
{
return Count;
}
public Nodes getByIndex(int i)
{
return nodes[i];
}
}