コード例 #1
0
ファイル: MapLayer.cs プロジェクト: ChampRain/BurningSteel
        public MapLayer(int height, int width)
        {
            map = new Tile[height,width];

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    map[x,y] = new Tile(0,0);
                }
            }
        }
コード例 #2
0
        protected override void LoadContent()
        {
            base.LoadContent();

            var tilesets = new List<Tileset>();

            var tileset1 = Game.Content.Load<Texture2D>(@"Tilesets\tileset1");
            var tileset2 = Game.Content.Load<Texture2D>(@"Tilesets\tileset2");
            tilesets.Add(new Tileset(tileset1, 8, 8, 32, 32));
            tilesets.Add(new Tileset(tileset2, 8, 8, 32, 32));

            var layer = new MapLayer(40, 40);
            for (var y = 0; y < layer.Height; y++) {
                for (var x = 0; x < layer.Width; x++) {
                    var tile = new Tile(0, 0);
                    layer.SetTile(x, y, tile);
                }
            }

            var splatter = new MapLayer(40, 40);
            var random = new Random();

            for (var i = 0; i < 80; i++) {
                var x = random.Next(0, 40);
                var y = random.Next(0, 40);
                var index = random.Next(2, 14);

                splatter.SetTile(x, y, new Tile(index, 0));
            }

            splatter.SetTile(1, 0, new Tile(0, 1));
            splatter.SetTile(2, 0, new Tile(2, 1));
            splatter.SetTile(3, 0, new Tile(0, 1));

            var mapLayers = new List<MapLayer> {layer, splatter};
            _map = new TileMap(tilesets, mapLayers);
        }
コード例 #3
0
ファイル: MapLayer.cs プロジェクト: ChampRain/BurningSteel
 public void SetTile(int x, int y, int tileIndex, int tileSet)
 {
     map[y,x] = new Tile(tileIndex, tileSet);
 }
コード例 #4
0
ファイル: MapLayer.cs プロジェクト: ChampRain/BurningSteel
 public void SetTile(int x, int y, Tile tile)
 {
     map[y, x] = tile;
 }
コード例 #5
0
ファイル: MapLayer.cs プロジェクト: ChampRain/BurningSteel
 public MapLayer(Tile[,] map)
 {
     this.map = (Tile[,])map.Clone();
 }
コード例 #6
0
        private void CreateWorld()
        {
            Texture2D tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset1");
            Tileset tileset1 = new Tileset(tilesetTexture, 8, 8, 32, 32);

            tilesetTexture = Game.Content.Load<Texture2D>(@"Tilesets\tileset2");
            Tileset tileset2 = new Tileset(tilesetTexture, 8, 8, 32, 32);

            List<Tileset> tilesets = new List<Tileset>();
            tilesets.Add(tileset1);
            tilesets.Add(tileset2);

            MapLayer layer = new MapLayer(100, 100);

            for (int y = 0; y < layer.Height; y++)
            {
                for (int x = 0; x < layer.Width; x++)
                {
                    XRpgLibrary.TileEngine.Tile tile = new XRpgLibrary.TileEngine.Tile(0, 0);

                    layer.SetTile(x, y, tile);
                }
            }

            MapLayer splatter = new MapLayer(100, 100);

            Random random = new Random();

            for (int i = 0; i < 80; i++)
            {
                int x = random.Next(0, 100);
                int y = random.Next(0, 100);
                int index = random.Next(2, 14);

                XRpgLibrary.TileEngine.Tile tile = new XRpgLibrary.TileEngine.Tile(index, 0);
                splatter.SetTile(x, y, tile);
            }

            splatter.SetTile(1, 0, new XRpgLibrary.TileEngine.Tile(0, 1));
            splatter.SetTile(2, 0, new XRpgLibrary.TileEngine.Tile(2, 1));
            splatter.SetTile(3, 0, new XRpgLibrary.TileEngine.Tile(0, 1));

            List<MapLayer> mapLayers = new List<MapLayer>();
            mapLayers.Add(layer);
            mapLayers.Add(splatter);

            TileMap map = new TileMap(tilesets, mapLayers);
            Level level = new Level(map);

            ChestData chestData = Game.Content.Load<ChestData>(@"Game\Chests\Plain Chest");

            Chest chest = new Chest(chestData);

            BaseSprite chestSprite = new BaseSprite(
                containers,
                new Rectangle(0, 0, 32, 32),
                new Point(10, 10));

            ItemSprite itemSprite = new ItemSprite(
                chest,
                chestSprite);
            level.Chests.Add(itemSprite);

            World world = new World(GameRef, GameRef.ScreenRectangle);
            world.Levels.Add(level);
            world.CurrentLevel = 0;

            GamePlayScreen.World = world;
        }