예제 #1
0
        static void Load(string fileName)
        {
            SerializableMap map = new SerializableMap();

            try
            {
                JsonSerializer serializer = new JsonSerializer();
                using (StreamReader file = File.OpenText(fileName))
                {
                    using (JsonReader reader = new JsonTextReader(file))
                    {
                        map = serializer.Deserialize <SerializableMap>(reader);
                    }
                }
            }
            catch (Exception)
            {
                Console.WriteLine("can't load map");
            }
            Utilites.u.CurrentMap = map.CurrentMap;
            Utilites.u.Collisions = map.Collisions;
            foreach (var item in map.Players)
            {
                Renderer.AddChar(item);
            }
            foreach (var item in map.Enemys)
            {
                Renderer.AddChar(item);
            }
            foreach (var item in map.Doors)
            {
                Renderer.AddChar(item);
            }
            foreach (var item in map.FakeWalls)
            {
                Renderer.AddChar(item);
            }
            foreach (var item in map.ItemConteiners)
            {
                Renderer.AddChar(item);
            }
            foreach (var item in map.Leavers)
            {
                Renderer.AddChar(item);
            }
            foreach (var item in map.Characters)
            {
                Renderer.AddChar(item);
            }
        }