public static List <Vector2Int> GeneratePath(int[,] mapValues)
    {
        List <Vector2Int> walkable = new List <Vector2Int>();
        Vector2Int        start    = Vector2Int.zero;
        Vector2Int        end      = Vector2Int.zero;

        for (int x = 0; x < mapValues.GetLength(0); x++)
        {
            for (int y = 0; y < mapValues.GetLength(1); y++)
            {
                int      number = mapValues[x, y];
                TileType type   = TileMethods.TypeById[number];
                if (TileMethods.IsWalkable(type))
                {
                    walkable.Add(new Vector2Int(x, y));
                }
                switch (type)
                {
                case TileType.Start: start = new Vector2Int(x, y); break;

                case TileType.End: end = new Vector2Int(x, y); break;

                default: break;
                }
            }
        }
        AI.IPathFinder pathFinder = new AI.Dijkstra(walkable);
        walkable = (List <Vector2Int>)pathFinder.FindPath(start, end);
        return(walkable);
    }
        private void Start()
        {
            m_MyTileList = m_MapManager.TileList;
            m_PathList   = new List <Vector2Int>();

            foreach (GameObject go in m_MyTileList)
            {
                m_PathList.Add(new Vector2Int(Mathf.RoundToInt(go.transform.position.x * 0.5f), Mathf.RoundToInt(go.transform.position.z * 0.5f)));
            }
            m_PathFinding = new Dijkstra(m_PathList);
            //get constructor to work;
            //get only the tiles that we can go on
            //

            m_ShortestPath = m_PathFinding.FindPath(m_MapManager.start, m_MapManager.end) as List <Vector2Int>; //it returns a list of the Vector2
        }
    private void Awake()
    {
        fileReader = transform.GetComponent <FileReader>();

        fileReader.Read(mapName);

        waveData = fileReader.getWaveData;

        if (!DictionaryObject)
        {
            DictionaryObject = Instantiate(DictionaryPrefab);
            DictionaryObject.transform.parent = transform;

            DictionaryObject.GetComponent <TileDictionary>().SetupDictionary();
            DictionaryObject.GetComponent <UnitDictionary>().SetupDictionary();
        }

        if (!MapBuilderObject)
        {
            MapBuilderObject = Instantiate(MapBuilderPrefab);
            MapBuilderObject.transform.parent = transform;

            builder                   = MapBuilderObject.GetComponent <MapBuilder>();
            builder.setMap            = fileReader.getMapData;
            builder.setTileDictionary = DictionaryObject.GetComponent <TileDictionary>();
            builder.BuildMap();
        }

        dijkstra = new AI.Dijkstra(builder.getPath);

        if (!UnitManager)
        {
            UnitManager = Instantiate(UnitManagerPrefab);
            UnitManager.transform.parent = transform;

            UnitManager.GetComponent <UnitManager>().setUnitDictionary = DictionaryObject.GetComponent <UnitDictionary>();
            UnitManager.GetComponent <UnitManager>().setPath           = (List <Vector2Int>)dijkstra.FindPath(builder.getStart, builder.getEnd);
            UnitManager.GetComponent <UnitManager>().RunWave(waveData[currentWave].x, waveData[currentWave].y);
        }

        if (!PlayerManager)
        {
            PlayerManager = Instantiate(PlayerManagerPrefab);
            PlayerManager.transform.parent = transform;
            PlayerManager.GetComponent <PlayerHealthListener>().SetupListener(HealthPanel.transform.Find("HealthText").gameObject.GetComponent <Text>());
            PlayerManager.GetComponent <PlayerBehaviour>().setupPlayer();
        }
    }