Beispiel #1
0
        /// <remarks>
        /// This overload creates the world and maps
        ///
        /// If there needs to be an arena along with other items in a world, then make another overload that passes
        /// in the world and an offset, etc
        /// </remarks>
        public ArenaAccessor_FAIL(int numRooms, double roomSize, double roomMargins, bool dividerWalls, bool shouldMapBuildSnapshots, Type[] updateTypes_main, Type[] updateTypes_any)
        {
            if (dividerWalls)
            {
                throw new ApplicationException("TODO: Implement divider walls");
            }

            _numRooms   = numRooms;
            _roomSize   = roomSize;
            _roomMargin = roomMargins;

            var cells = Math3D.GetCells_Cube(roomSize, numRooms, roomMargins).
                        Take(numRooms).
                        ToArray();

            _boundryMin = new Point3D(
                cells.Min(o => o.rect.Location.X - roomMargins),        // technically, this should only be half the room margin, but leaving an extra buffer around the set
                cells.Min(o => o.rect.Location.Y - roomMargins),
                cells.Min(o => o.rect.Location.Z) - roomMargins);

            _boundryMax = new Point3D(
                cells.Max(o => o.rect.Location.X + o.rect.Size.X + roomMargins),
                cells.Max(o => o.rect.Location.Y + o.rect.Size.Y + roomMargins),
                cells.Max(o => o.rect.Location.Z + o.rect.Size.Z) + roomMargins);

            _world = new World(false);
            _world.SetCollisionBoundry(_boundryMin, _boundryMax);
            _world.Updating += World_Updating;

            _roomStorage = cells.
                           Select((o, i) =>
            {
                Map map = new Map(null, null, _world)
                {
                    ShouldBuildSnapshots = shouldMapBuildSnapshots
                };

                TrainingRoom room = new TrainingRoom()
                {
                    Map    = map,
                    World  = _world,
                    Center = o.center,
                    AABB   = (o.rect.Location, o.rect.Location + o.rect.Size.ToVector()),
                    Index  = i,
                };

                return(new RoomStorage()
                {
                    Center = o.center,
                    Rect = o.rect,
                    Map = map,
                    UpdateManager = new UpdateManager(updateTypes_main, updateTypes_any, map, useTimer: false),
                    IsCheckedOut = false,
                    Room = room,
                });
            }).
                           ToArray();
        }