1
0
forked from s425077/PotatoPlan
JoelForkTest/Game1/Sources/Pathing/A-Star/PathSaver/Path.cs

64 lines
1.2 KiB
C#
Raw Normal View History

2020-05-03 13:05:05 +02:00
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;
2020-05-03 16:35:46 +02:00
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];
}
2020-05-03 22:28:52 +02:00
nodes[Count + 1] = null;
2020-05-03 16:35:46 +02:00
return temp;
}
2020-05-03 19:30:41 +02:00
public Path FlipArray()
2020-05-03 16:35:46 +02:00
{
int j = Count;
2020-05-03 17:06:03 +02:00
Nodes[] tempp = nodes;
2020-05-03 19:30:41 +02:00
Nodes[] newnode = new Nodes[Count];
Path newPath = new Path();
2020-05-03 16:35:46 +02:00
for (int i = 0; i < Count; i++)
{
2020-05-03 19:30:41 +02:00
newnode[i] = tempp[j - 1];
2020-05-03 16:35:46 +02:00
j--;
2020-05-03 19:30:41 +02:00
newPath.AddNode(newnode[i]);
2020-05-03 16:35:46 +02:00
}
2020-05-03 19:30:41 +02:00
return newPath;
2020-05-03 16:35:46 +02:00
}
public Nodes getFinalDest()
{
return nodes[Count];
}
public int getCount()
{
return Count;
}
public Nodes getByIndex(int i)
{
return nodes[i];
}
2020-05-03 13:05:05 +02:00
}