using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/*
 * This class represents a finite list of points, which represents the path of a unit. 
*/
public class Path {

    private LinkedList<Vertex> path;

    public Path() {
        this.path = new LinkedList<Vertex>();
    }

    public void addLast(Vertex pt) {
        path.AddLast(pt);
    }

    public void addFirst(Vertex pt) {
        path.AddFirst(pt);
    }

    //Adds a red line in the game, representing the path in the map
    public void debugDisplay() {
        Vertex last = null;
        bool first = true;
        foreach (Vertex pt in path) {
            if (!first) {
                Debug.DrawLine(last.getVector3(-2.1f), pt.getVector3(-2.1f), Color.red, 2);
            }
            first = false;
            last = pt;
        }
    }

    public List<Vertex> toList() {
        List<Vertex> list = new List<Vertex>();
        foreach (Vertex pt in path) {
            list.Add(pt);
        }

        return list;
    }
}
