Esempio n. 1
0
        public void Create_Map()
        {
            StringBuilder sb         = new StringBuilder();
            int           squareSize = 20;

            CreateMap cm  = new CreateMap();
            var       map = cm.CreateMapTiles(squareSize);

            for (int i = 0; i < squareSize; i++)
            {
                for (int j = 0; j < squareSize; j++)
                {
                    if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True)
                    {
                        sb.Append("#");
                    }
                    else
                    {
                        sb.Append(".");
                    }
                }
                Debug.WriteLine(sb.ToString());
                sb.Clear();
            }

            FindPath       fp         = new FindPath();
            List <History> mapHistory = fp.FindPathThroughMap(map);

            for (int i = 0; i < squareSize; i++)
            {
                for (int j = 0; j < squareSize; j++)
                {
                    if (map.GetLocationType(j, i) == RTSGameMap.RTSGameMapOccupied.True)
                    {
                        sb.Append("#");
                    }
                    else
                    {
                        if (mapHistory.Where(x => x.Location.x == j && x.Location.y == i).Any())
                        {
                            sb.Append("X");
                        }
                        else
                        {
                            sb.Append(".");
                        }
                    }
                }
                Debug.WriteLine(sb.ToString());
                sb.Clear();
            }
        }