Пример #1
0
        private string CreateJSON()
        {
            JSONClass JSON = new JSONClass();

            string[] ObjectNamesArray = new string[Objects.Count];

            for (int i = 0; i < Objects.Count; i++)
            {
                ObjectNamesArray[i] = this.Objects[i].Name;
            }

            int[][] RandomizationGroupsArray = new int[RandomizationGroups.Count][];

            for (int i = 0; i < RandomizationGroups.Count; i++)
            {
                int[] Group = RandomizationGroups[i].ToArray();
                RandomizationGroupsArray[i] = Group;
            }

            object[][] TilesArray = new object[765][];

            for (int i = 0; i < 765; i++)
            {
                TilesArray[i] = new object[3] {
                    Tiles[i].ID, Tiles[i].FlipX, Tiles[i].FlipY
                }
            }
            ;

            JSON.object_names         = ObjectNamesArray;
            JSON.randomization_groups = RandomizationGroupsArray;
            JSON.tiles           = TilesArray;
            JSON.textures        = Textures.ToArray();
            JSON.version         = Version;
            JSON.texture_formats = TextureFormats.ToArray();

            var    Serializer = new DataContractJsonSerializer(typeof(JSONClass));
            string JSONString = "";

            using (var MS = new MemoryStream())
            {
                Serializer.WriteObject(MS, JSON);
                JSONString = Encoding.Default.GetString(MS.ToArray());
            }

            return(JSONString);
        }