Example #1
0
        /// <summary>
        /// Get all connections on level. Also includes connections from this level to other levels
        /// </summary>
        /// <param name="level"></param>
        /// <returns></returns>
        public IEnumerable <Connection> GetConnectionsOnLevel(int level)
        {
            var roomIndicesForLevel = GetRoomIndicesForLevel(level);

            //This may be slow and better done by the underlying map representation
            return(map.GetAllConnections().Where(c => roomIndicesForLevel.Contains(c.Source) || roomIndicesForLevel.Contains(c.Target)));
        }
Example #2
0
        public void ConnectionCanBeAddedFromAnotherMap()
        {
            ConnectivityMap newMap = new ConnectivityMap();

            newMap.AddRoomConnection(1, 2);
            newMap.AddRoomConnection(2, 3);

            ConnectivityMap newMap2 = new ConnectivityMap();

            newMap2.AddRoomConnection(3, 4);
            newMap2.AddRoomConnection(4, 5);

            newMap.AddAllConnections(newMap2);

            CollectionAssert.AreEquivalent(new List <Connection>(new Connection[] { new Connection(1, 2), new Connection(2, 3),
                                                                                    new Connection(3, 4), new Connection(4, 5) }), newMap.GetAllConnections().ToList());
        }
 private Connection GetRandomEdgeInMap(ConnectivityMap generatedMap)
 {
     return(generatedMap.GetAllConnections().RandomElementUsing(random));
 }
Example #4
0
        public void MapsFromDifferentLevelsCanBeConnected()
        {
            var mapInfo = new MapInfoBuilder();

            var l1ConnectivityMap = new ConnectivityMap();

            l1ConnectivityMap.AddRoomConnection(1, 2);
            l1ConnectivityMap.AddRoomConnection(2, 3);

            var l2ConnectivityMap = new ConnectivityMap();

            l2ConnectivityMap.AddRoomConnection(5, 6);
            l2ConnectivityMap.AddRoomConnection(6, 7);

            mapInfo.AddConstructedLevel(0, l1ConnectivityMap, new List <TemplatePositioned>(), new Dictionary <Connection, Point>(), 0);
            mapInfo.AddConstructedLevel(1, l2ConnectivityMap, new List <TemplatePositioned>(), new Dictionary <Connection, Point>(), new Connection(3, 5));

            ConnectivityMap fullMap = mapInfo.FullConnectivityMap;

            CollectionAssert.AreEquivalent(new List <Connection>(new Connection[] { new Connection(1, 2), new Connection(2, 3),
                                                                                    new Connection(3, 5), new Connection(5, 6), new Connection(6, 7) }), fullMap.GetAllConnections().ToList());
        }