예제 #1
0
파일: XmlLoader.cs 프로젝트: MrMallet/Scrap
        //public XmlLoader(ScrapGame game)
        //{
        //    Level current = new Level();
        //    Crate crate1 = new Crate();
        //    Crate crate2 = new Crate();
        //    //Wheel wheel1 = new Wheel(game, new Vector2(21.55f, -10));
        //    //Wheel wheel2 = new Wheel(game, new Vector2(22.55f, -10));
        //    //current.EntityList.Add(crate1);
        //    //current.EntityList.Add(crate2);
        //    //current.EntityList.Add(wheel1);
        //    //current.EntityList.Add(wheel2);
        //    current.CrateList.Add(crate1);
        //    current.CrateList.Add(crate2);
        //    //current.WheelList.Add(wheel1);
        //    //current.WheelList.Add(wheel2);
        //    WriteXMl(current);
        //    Level newTask = GetTask();
        //}
        public void SaveLevel(List<Segment> itemList)
        {
            Level currentLevel = new Level();
            //foreach(Entity current in itemList)
            //{
            //    currentLevel.EntityList.Add(current);
            //}
            currentLevel.EntityList = itemList;

            WriteXMl(currentLevel);
        }
예제 #2
0
파일: XmlLoader.cs 프로젝트: MrMallet/Scrap
        public void WriteXMl(Level level)
        {
            XmlSerializer serializer;
            serializer = new XmlSerializer(level.GetType());

            MemoryStream stream = new MemoryStream();

            StreamWriter writer = new StreamWriter(stream, Encoding.Unicode);
            serializer.Serialize(writer, level);

            int count = (int)stream.Length;

            byte[] arr = new byte[count];
            stream.Seek(0, SeekOrigin.Begin);

            stream.Read(arr, 0, count);

            using (BinaryWriter binWriter = new BinaryWriter(File.Open(gesturefile, FileMode.Create)))
            {
                binWriter.Write(arr);
            }
        }