Пример #1
0
        private static void InitFloorToContext(TestFloorPlan floorPlan, Rect rect, Rect[] rooms, Rect[] halls, Tuple <char, char>[] links)
        {
            floorPlan.InitRect(rect);

            // a quick way to set up rooms, halls, and connections
            // a list of rects for rooms, a list of rects for halls
            for (int ii = 0; ii < rooms.Length; ii++)
            {
                var gen = new TestFloorPlanGen((char)('A' + ii));
                gen.PrepareDraw(rooms[ii]);
                floorPlan.PublicRooms.Add(new FloorRoomPlan(gen, new ComponentCollection()));
            }

            for (int ii = 0; ii < halls.Length; ii++)
            {
                var gen = new TestFloorPlanGen((char)('a' + ii));
                gen.PrepareDraw(halls[ii]);
                floorPlan.PublicHalls.Add(new FloorHallPlan(gen, new ComponentCollection()));
            }

            // and finally a list of tuples that link rooms to rooms and halls to halls
            for (int ii = 0; ii < links.Length; ii++)
            {
                bool           hall1  = links[ii].Item1 >= 'a';
                int            index1 = hall1 ? links[ii].Item1 - 'a' : links[ii].Item1 - 'A';
                bool           hall2  = links[ii].Item2 >= 'a';
                int            index2 = hall2 ? links[ii].Item2 - 'a' : links[ii].Item2 - 'A';
                var            link1  = new RoomHallIndex(index1, hall1);
                var            link2  = new RoomHallIndex(index2, hall2);
                IFloorRoomPlan from1  = floorPlan.GetRoomHall(link1);
                IFloorRoomPlan from2  = floorPlan.GetRoomHall(link2);
                from1.Adjacents.Add(link2);
                from2.Adjacents.Add(link1);
            }
        }