Пример #1
0
        public void Serializator(Dungeon Dungeon, DirectoryInfo dir)
        {
            //FileStream FileStrm = new FileStream(Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory) + "\\DungeonCreator", FileMode.OpenOrCreate);
            //File.Create(Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory) + "\\DungeonCreator\\"+Dungeon.Name);
            string       Dir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + "\\DungeonCreator\\" + dir.Name + Dungeon.Name + ".dungeon";
            FileStream   Fs  = new FileStream(Dir, FileMode.Create);
            StreamWriter SW  = new StreamWriter(Fs, Encoding.UTF8);

            SW.WriteLine("<Name>");
            SW.WriteLine(Dungeon.Name);
            SW.WriteLine("<Discription>");
            SW.WriteLine(Dungeon.GetDescription());
            SW.WriteLine("<ToEnter>");
            SW.WriteLine(Dungeon.GetToenter());
            SW.WriteLine("<Answer>");
            SW.WriteLine(Dungeon.GetAnswer());
            SW.WriteLine("<Encounters>");
            foreach (Encounter enc in Dungeon.GetEncounters)
            {
                SW.WriteLine("<EncounterName>");
                SW.WriteLine(enc.Name);
                SW.WriteLine("<Discription>");
                SW.WriteLine(enc.Dis);
                SW.WriteLine("<Actions>");
                foreach (Action action in enc.GetActions)
                {
                    SW.WriteLine("<Discription>");
                    SW.WriteLine(action.Dis);
                    SW.WriteLine("<Cons>");
                    SW.WriteLine(action.Cons);
                }
                SW.WriteLine("<EndEncounter>");
            }
            SW.WriteLine("<Map-BitMap>");
            SW.WriteLine(Dungeon.imageWidth);
            SW.WriteLine(Dungeon.imageHeigh);
            for (int h = 0; h != Dungeon.imageHeigh; h++)
            {
                for (int w = 0; w != Dungeon.imageWidth; w++)
                {
                    if (Dungeon.image[w, h, 0] > 99)
                    {
                        SW.Write(3);
                    }
                    else if (Dungeon.image[w, h, 0] > 9)
                    {
                        SW.Write(2);
                    }
                    else if (Dungeon.image[w, h, 0] >= 0)
                    {
                        SW.Write(1);
                    }
                    SW.Write(Dungeon.image[w, h, 0]);

                    if (Dungeon.image[w, h, 1] > 99)
                    {
                        SW.Write(3);
                    }
                    else if (Dungeon.image[w, h, 1] > 9)
                    {
                        SW.Write(2);
                    }
                    else if (Dungeon.image[w, h, 1] >= 0)
                    {
                        SW.Write(1);
                    }
                    SW.Write(Dungeon.image[w, h, 1]);

                    if (Dungeon.image[w, h, 2] > 99)
                    {
                        SW.Write(3);
                    }
                    else if (Dungeon.image[w, h, 2] > 9)
                    {
                        SW.Write(2);
                    }
                    else if (Dungeon.image[w, h, 2] >= 0)
                    {
                        SW.Write(1);
                    }
                    SW.Write(Dungeon.image[w, h, 2]);
                }
                SW.Write(SW.NewLine);
            }
            SW.WriteLine("<End>");
            SW.Close();
            Fs.Close();
        }
Пример #2
0
 private void Enter_Click(object sender, RoutedEventArgs e)
 {
     MainData.Text = NewDungeon.GetToenter();
     CurrentMode   = "Enter";
 }