Esempio n. 1
0
 public PathingQuery(PathingMap map, Rect dest, float range)
 {
     Map         = map;
     Destination = dest;
     Range       = range;
     Initialize();
 }
Esempio n. 2
0
        public void TestParsePathingMap(string pathingMapFile)
        {
            using var original  = FileProvider.GetFile(pathingMapFile);
            using var recreated = new MemoryStream();

            PathingMap.Parse(original, true).SerializeTo(recreated, true);
            StreamAssert.AreEqual(original, recreated, true);
        }
Esempio n. 3
0
        public void TestPathingMap(string pathingMapFile)
        {
            using var fileStream = File.OpenRead(pathingMapFile);
            var pathingMap = PathingMap.Parse(fileStream, true);

            using var memoryStream = new MemoryStream();
            pathingMap.SerializeTo(memoryStream, true);

            StreamAssert.AreEqual(fileStream, memoryStream, true);
        }
Esempio n. 4
0
        private void BuildPathableMap()
        {
            pathFinding = new LibTCOD.TCODPathFindingWrapper();

            pathingMap = new PathingMap(template.Width, template.Height);

            for (int i = 0; i < template.Width; i++)
            {
                for (int j = 0; j < template.Height; j++)
                {
                    pathingMap.setCell(i, j,
                        RoomTemplateTerrainWalkable.terrainWalkable[template.terrainMap[i, j]] ? PathingTerrain.Walkable : PathingTerrain.Unwalkable);
                }
            }

            pathFinding.updateMap(0, pathingMap);
        }
Esempio n. 5
0
        public void updateMap(int level, PathingMap terrainMap)
        {
            TCODFov tcodLevel = new TCODFov(terrainMap.Width, terrainMap.Height);

            for (int j = 0; j < terrainMap.Width; j++)
            {
                for (int k = 0; k < terrainMap.Height; k++)
                {
                    tcodLevel.SetCell(j, k, true, terrainMap.getCell(j, k) == PathingTerrain.Walkable);
                }
            }

            levelTCODMaps[level] = tcodLevel;

            //Ignoring closed doors

            TCODFov tcodLevelNoClosedDoors = new TCODFov(terrainMap.Width, terrainMap.Height);

            for (int j = 0; j < terrainMap.Width; j++)
            {
                for (int k = 0; k < terrainMap.Height; k++)
                {
                    tcodLevelNoClosedDoors.SetCell(j, k, true, terrainMap.getCell(j, k) == PathingTerrain.Walkable || terrainMap.getCell(j, k) == PathingTerrain.ClosedDoor);
                }
            }

            levelTCODMapsIgnoringClosedDoors[level] = tcodLevelNoClosedDoors;


            //Ignoring closed doors and locks

            TCODFov tcodLevelNoClosedDoorsAndLocks = new TCODFov(terrainMap.Width, terrainMap.Height);

            for (int j = 0; j < terrainMap.Width; j++)
            {
                for (int k = 0; k < terrainMap.Height; k++)
                {
                    tcodLevelNoClosedDoorsAndLocks.SetCell(j, k, true, terrainMap.getCell(j, k) == PathingTerrain.Walkable ||
                                                           terrainMap.getCell(j, k) == PathingTerrain.ClosedDoor ||
                                                           terrainMap.getCell(j, k) == PathingTerrain.ClosedLock);
                }
            }

            levelTCODMapsIgnoringClosedDoorsAndLocks[level] = tcodLevelNoClosedDoorsAndLocks;
        }
        public void updateMap(int level, PathingMap terrainMap)
        {
            TCODFov tcodLevel = new TCODFov(terrainMap.Width, terrainMap.Height);

            for (int j = 0; j < terrainMap.Width; j++)
            {
                for (int k = 0; k < terrainMap.Height; k++)
                {
                    tcodLevel.SetCell(j, k, true, terrainMap.getCell(j,k) == PathingTerrain.Walkable);
                }
            }

            levelTCODMaps[level] = tcodLevel;

            //Ignoring closed doors

            TCODFov tcodLevelNoClosedDoors = new TCODFov(terrainMap.Width, terrainMap.Height);

            for (int j = 0; j < terrainMap.Width; j++)
            {
                for (int k = 0; k < terrainMap.Height; k++)
                {
                    tcodLevelNoClosedDoors.SetCell(j, k, true, terrainMap.getCell(j,k) == PathingTerrain.Walkable || terrainMap.getCell(j,k) == PathingTerrain.ClosedDoor);
                }
            }

            levelTCODMapsIgnoringClosedDoors[level] = tcodLevelNoClosedDoors;

            //Ignoring closed doors and locks

            TCODFov tcodLevelNoClosedDoorsAndLocks = new TCODFov(terrainMap.Width, terrainMap.Height);

            for (int j = 0; j < terrainMap.Width; j++)
            {
                for (int k = 0; k < terrainMap.Height; k++)
                {
                    tcodLevelNoClosedDoorsAndLocks.SetCell(j, k, true, terrainMap.getCell(j, k) == PathingTerrain.Walkable ||
                        terrainMap.getCell(j, k) == PathingTerrain.ClosedDoor ||
                        terrainMap.getCell(j, k) == PathingTerrain.ClosedLock);
                }
            }

            levelTCODMapsIgnoringClosedDoorsAndLocks[level] = tcodLevelNoClosedDoorsAndLocks;
        }
Esempio n. 7
0
        private bool ArePointsConnected(Point firstPoint, Point secondPoint)
        {
            //Build map representations
            PathingMap map = new PathingMap(Width, Height);
            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    map.setCell(i, j, baseMap.mapSquares[i, j].Walkable ? PathingTerrain.Walkable : PathingTerrain.Unwalkable);
                }
            }

            //Try to walk a path between the 2 staircases
            LibTCOD.TCODPathFindingWrapper pathFinder = new LibTCOD.TCODPathFindingWrapper();
            pathFinder.updateMap(0, map);
            return pathFinder.arePointsConnected(0, firstPoint, secondPoint, Pathing.PathingPermission.Normal);
        }
Esempio n. 8
0
        private void BuildPathableMap()
        {
            thisMap = new PathingMap(template.Width, template.Height);

            for (int i = 0; i < template.Width; i++)
            {
                for (int j = 0; j < template.Height; j++)
                {
                    thisMap.setCell(i, j,
                        RoomTemplateTerrainWalkable.terrainWalkable[template.terrainMap[i, j]] ? PathingTerrain.Walkable : PathingTerrain.Unwalkable);
                }
            }
        }