Exemplo n.º 1
0
        private AdjacencyMatrix <LayerTile> GetAdjacencyMatrixFromTiledMapLayer(TiledMapLayer tiledMapLayer, IDictionary <int, int> weights)
        {
            var result = new AdjacencyMatrix <LayerTile>();

            foreach (var tile in tiledMapLayer.Tiles)
            {
                if (weights.ContainsKey(tile.Id))
                {
                    foreach (var neighbour in tiledMapLayer.GetNeighboursFromTile(tile))
                    {
                        if (neighbour != null && weights.ContainsKey(neighbour.Id))
                        {
                            result.AddAdjacent(tile, neighbour, weights[neighbour.Id]);
                        }
                    }
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        private AdjacencyMatrix<LayerTile> GetAdjacencyMatrixFromTiledMapLayer(TiledMapLayer tiledMapLayer, IDictionary<int, int> weights)
        {
            var result = new AdjacencyMatrix<LayerTile>();

            foreach (var tile in tiledMapLayer.Tiles)
            {
                if (weights.ContainsKey(tile.Id))
                {
                    foreach (var neighbour in tiledMapLayer.GetNeighboursFromTile(tile))
                    {
                        if (neighbour != null && weights.ContainsKey(neighbour.Id))
                        {
                            result.AddAdjacent(tile, neighbour, weights[neighbour.Id]);
                        }
                    }
                }
            }

            return result;
        }