Exemple #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            //spritebatch for 2d stuff
            spriteBatch = new SpriteBatch(GraphicsDevice);

            //map generation + textue setting
            String   jsonString = File.ReadAllText("content/map_1.json");
            MapTiled maptiled   = JsonConvert.DeserializeObject <MapTiled>(jsonString);

            sunVector = new Vector3(1f, -1f, 1f);
            sunVector.Normalize();
            //init mapdata
            map         = new Map();
            map.Texture = Content.Load <Texture2D>("Tilesheets\\" + maptiled.tilesets[0].name);
            map.initialize(maptiled);

            avatar.avatarPos = map.spawnLocation;
            avatar.texture   = Content.Load <Texture2D>("Sprites\\Characters_NPCs\\Main_char_walking_animation");
            effectOur        = Content.Load <Effect>("Shaders\\BasicShader");
        }
Exemple #2
0
        public void initialize(MapTiled obj)
        {
            int width  = obj.width;
            int height = obj.height;

            IdTiles = new int[height, width];

            Layer layer = obj.layers[1];

            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    IdTiles[i, j] = layer.data[i * width + j] - obj.tilesets[1].firstgid + 1;
                }
            }

            Tiles = new int[height + 1, width + 1];
            createHeightMap(width, height);


            layer = obj.layers[0];
            for (int i = 0; i < height; i++)
            {
                for (int j = 0; j < width; j++)
                {
                    IdTiles[i, j] = layer.data[i * width + j] - obj.tilesets[0].firstgid + 1;
                }
            }

            TextureInfo = obj.tilesets[0];

            generate();

            GenerateStatic(obj.layers[2], obj.tilesets[2]);
        }