Beispiel #1
0
        public void Update(WallLayer wallLayer, TerrainLayer terrainLayer)
        {
            // Generate navigatable mesh

            for (int x = 0; x < bounds.X; x++)
            {
                for (int y = 0; y < bounds.Y; y++)
                {
                    var cell = new PathfinderCell(new MPos(x, y))
                    {
                        TerrainCost = 1f / terrainLayer.Terrain[x, y].Type.Speed
                    };

                    cells[x, y] = cell;
                }
            }
Beispiel #2
0
            static void connect(Wall between, PathfinderCell a, PathfinderCell b)
            {
                if (between != null && between.Type.Blocks)
                {
                    return;
                }

                if (float.IsInfinity(a.TerrainCost) || float.IsInfinity(b.TerrainCost))
                {
                    return;
                }

                var cost = (a.TerrainCost + b.TerrainCost) / 2;

                a.Connections.Add((cost, b));
                b.Connections.Add((cost, a));
            };