package ei.game.algo;

import java.util.ArrayList;
import java.util.LinkedList;

import ei.engine.math.Vector2i;

/**
 * A path from one point to another generated by the path finding code
 * 
 * @author Kevin Glass
 */
public class Path {
	/** The maximum path length */
	private static final int MAX_PATH = 200;
	/** The path coordinates */
	private int[][] path = new int[MAX_PATH][2];
	/** The size of the path */
	private int size;
	
	/**
	 * Create a new empty path
	 */
	public Path() {
	}
	
	/**
	 * Add a point to the path
	 * 
	 * @param x The x coordinate of the point being added
	 * @param y The y coordinate of the point being added
	 */
	public void addPoint(int x,int y) {
		path[size][0] = x;
		path[size][1] = y;
		
		size++;
	}
	
	/**
	 * Get the X coordinate of the point at the specified index
	 * 
	 * @param index The index of the point to retrieve 
	 * @return The x coordinate of the point at the specified index
	 */
	public int getX(int index) {
		return path[index][0];
	}

	/**
	 * Get the Y coordinate of the point at the specified index
	 * 
	 * @param index The index of the point to retrieve 
	 * @return The y coordinate of the point at the specified index
	 */
	public int getY(int index) {
		return path[index][1];
	}
	
	/**
	 * Get the size/length of the path
	 * 
	 * @return The size of the path
	 */
	public int getSize() {
		return size;
	}
	
	public ArrayList<Vector2i> getArray(){
		ArrayList<Vector2i> array = new ArrayList<Vector2i>();
		
		for(int i=0; i<size ;i++){
			array.add(new Vector2i(path[i][0],path[i][1]));
		}
		
		return array;
	}
	
	public LinkedList<Vector2i> getList(){
		LinkedList<Vector2i> array = new LinkedList<Vector2i>();
		
		for(int i=0; i<size ;i++){
			array.add(new Vector2i(path[i][0],path[i][1]));
		}
		
		return array;
	}
}
