Exemplo n.º 1
0
        public static List <Tile> Load(string filepath)
        {
            if (!File.Exists(filepath))
            {
                throw new FileNotFoundException("Failure to load tiles from provided file. File not found.", filepath);
            }
            string fileData = File.ReadAllText(filepath);

            return(TileSerializer.DeserializeList(fileData));
        }
Exemplo n.º 2
0
        public void JsonDeserializesToTileList()
        {
            string      source = "[{\"MovementFlags\":5,\"Id\":123},{\"MovementFlags\":4,\"Id\":127}]";
            List <Tile> tiles  = TileSerializer.DeserializeList(source);

            Assert.That(tiles, Has.Count.EqualTo(2));
            Assert.That(tiles[0].Id, Is.EqualTo(123));
            Assert.That(tiles[0].MovementFlags, Is.EqualTo(TileMovementFlags.BulletPassable | TileMovementFlags.Passable));
            Assert.That(tiles[1].Id, Is.EqualTo(127));
            Assert.That(tiles[1].MovementFlags, Is.EqualTo(TileMovementFlags.BulletPassable));
        }