Пример #1
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();
        }
Пример #2
0
 public void Draw(SpriteBatch spriteBatch, TileDatabase tdb)
 {
     currentRoom.Draw(spriteBatch, tdb);
     #if MAPDEBUG
     map.Draw(spriteBatch, currentRoom);
     #endif
 }
Пример #3
0
        /****************
        * Methods
        ****************/

        public Room(Game game, int X, int Y, Texture2D shadowTexture, TileDatabase tileDatabaseReference, Player playerReference, Texture2D tileTexture)
            : base(game)
        {
            gameReference              = game;
            location.X                 = X;
            location.Y                 = Y;
            this.shadowTexture         = shadowTexture;
            this.playerReference       = playerReference;
            this.tileDatabaseReference = tileDatabaseReference;
            this.tileTexture           = tileTexture;
            Random r = new Random();

            roomBrightnessType = r.Next(10);
            if (roomBrightnessType >= 4)
            {
                roomBrightnessType = REGULAR;
            }
            else if (roomBrightnessType >= 2)
            {
                roomBrightnessType = DARKER;
            }
            else
            {
                roomBrightnessType = BRIGHT;
            }
        }
Пример #4
0
        public void Draw(SpriteBatch spriteBatch, TileDatabase tdb)
        {
            currentRoom.Draw(spriteBatch, tdb);
#if MAPDEBUG
            map.Draw(spriteBatch, currentRoom);
#endif
        }
Пример #5
0
        public void Draw(SpriteBatch spriteBatch, TileDatabase tdb)
        {
            for (int x = 0; x < ROOM_WIDTH; x++)
            {
                for (int y = 0; y < ROOM_HEIGHT; y++)
                {
                    //Automatically Draws the tile given the position and tile kind
                    tdb.drawTile(spriteBatch, new Vector2(x * TILE_SIZE, y * TILE_SIZE), roomDesign[x, y]);
                }
            }

            // Entities
            foreach (Entity e in listOfEntities)
            {
                e.Draw(spriteBatch);
            }

            // Items
            foreach (Item i in itemsSpawned)
            {
                i.Draw(spriteBatch);
            }
        }
Пример #6
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

        }
Пример #7
0
        public void Draw(SpriteBatch spriteBatch, TileDatabase tdb)
        {
            for (int x = 0; x < ROOM_WIDTH; x++)
            {
                for (int y = 0; y < ROOM_HEIGHT; y++)
                {
                    //Automatically Draws the tile given the position and tile kind
                    tdb.drawTile(spriteBatch,new Vector2(x * TILE_SIZE, y * TILE_SIZE),roomDesign[x, y]);
                }
            }
            
            // Entities
            foreach (Entity e in listOfEntities)
            {
                e.Draw(spriteBatch);
            }

            // Items
            foreach (Item i in itemsSpawned)
            {
                i.Draw(spriteBatch);
            }


        }
Пример #8
0
        /****************
         * Methods
         ****************/

        public Room(Game game, int X, int Y, Texture2D shadowTexture, TileDatabase tileDatabaseReference, Player playerReference, Texture2D tileTexture)
            : base(game)
        {
            gameReference = game;
            location.X = X;
            location.Y = Y;
            this.shadowTexture = shadowTexture;
            this.playerReference = playerReference;
            this.tileDatabaseReference = tileDatabaseReference;
            this.tileTexture = tileTexture;
            Random r = new Random();
            roomBrightnessType = r.Next(10);
            if (roomBrightnessType >= 4)
                roomBrightnessType = REGULAR;
            else if (roomBrightnessType >= 2)
                roomBrightnessType = DARKER;
            else
                roomBrightnessType = BRIGHT;

        }
Пример #9
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
        }
Пример #10
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();
        }