Пример #1
0
        /// <summary>
        /// This initializes a new map given a rectangle which has
        /// the starting X and Y locations of the player and the 
        /// width and size of the map (not the room).
        /// </summary>
        /// <param name="init"></param>
        public void Initialize(Game game, Player playerReference, ContentManager Content, Rectangle init, Texture2D tileTexture, List<Texture2D> mapDebuggingTextures, RoomDatabase roomDatabaseReference, TileDatabase tileDatabaseReference)
        {
            gameReference = game;
            this.shadowTexture = Content.Load<Texture2D>("shadow");
            this.playerReference = playerReference;
            mapDefinition = init;
            debugTextures = mapDebuggingTextures;
            this.roomDatabaseReference = roomDatabaseReference;
            // Generate rooms
            int width = init.Width;
            int height = init.Height;
            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    Room r = new Room(gameReference, x, y, shadowTexture, tileDatabaseReference, playerReference, tileTexture);
                    listOfRooms.Add(r);

#if !KRUSKAL
                    r.Initialize();
#else
                    kruskalRooms.Add(r);
                    
                    // In Kruskal's, each room has a set of their own.
                    List<Room> list = new List<Room>();
                    list.Add(r);
                    sets.Add(list);
#endif

                }
            }

            // Generate maze
            int destination_x = random.Next(width);
            int destination_y = random.Next(height);
            endLocation.X = destination_x;
            endLocation.Y = destination_y;
#if KRUSKAL
            generateMaze();
#else
            generateMaze(destination_x, destination_y, null);
#endif

        }
Пример #2
0
        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public void Initialize(RoomDatabase rdb)
        {
            initTypeAndRotation();
            initRoomDesign(rdb);

            initShadowHandlers();
            initWallHitTests();
            initDoors();
            initEntities();
            initItems();
            base.Initialize();
        }
Пример #3
0
 /// <summary>
 /// This method initializes the room's design by randomly selecting
 /// from a list of valid room designs (e.g. a list of all TRIADs facing UP)
 /// </summary>
 /// <param name="rdb">The database that contains all room designs</param>
 private void initRoomDesign(RoomDatabase rdb)
 {
     int[,] roomDesign = rdb.getRoomDesign(roomType, rotation);
     if (roomDesign != null)
     {
         setRoomDesign(roomDesign);
     }
     else
     {
         throw new Exception("Null Room Design Exception! No room design for type: " + Room.getRoomTypeString(roomType) + " and rotation: " + Room.getRoomRotationString(rotation));
     }
 }
Пример #4
0
        protected override void Initialize()
        {
            // Sample texture, 1x1 pixel for testing.
            simpleTexture = new Texture2D(GraphicsDevice, 1, 1);
            simpleTexture.SetData(new[] { Color.White });

            // Initializes the accelerometer.
            initializeAccelerometer();

            // Databases
            tileDatabase = new TileDatabase();
            roomDatabase = new RoomDatabase();

            // Handlers
            songHandler = new SongHandler();
            inventoryHandler = new InventoryHandler();
            eventHandler = new EventHandler();
            locationHandler = new LocationHandler();

            // Objects
            mapDefinition = new Map();
            sadakoReference = new Sadako();
            playerReference = new Player();

            // M! game profiler for FPS and other related stuff
            #if DEBUG
            Components.Add(new GameProfiler(this, Content));
            #endif

            base.Initialize();
        }