private void applyButton_Click(object sender, EventArgs e)
        {
            string filePrefix = int.Parse(characterID.Text).ToString("D4");
            string filePath   = "./Data/Characters/" + filePrefix + nameBox.Text + ".txt";
            string exAddress  = "./Data/Characters/" + curCharacter;

            if (File.Exists(filePath) && filePath != exAddress)
            {
                if (notification0 == null)
                {
                    notification0 = new message0();
                }
                if (notification0.ShowDialog() == DialogResult.OK)
                {
                    File.Create(filePath).Close();
                }
            }
            else
            {
                if (File.Exists(exAddress))
                {
                    File.Delete(exAddress);
                }
                File.Create(filePath).Close();
            }

            StreamWriter file = new StreamWriter(filePath);

            file.WriteLine(characterID.Text);
            file.WriteLine(nameBox.Text);
            file.WriteLine(experienceBox.Text);  //Checked in Verify for int
            file.WriteLine(healthBox.Text);      //
            file.WriteLine(agilityBox.Text);     //
            file.WriteLine(precisionBox.Text);   //
            file.WriteLine(energyBox.Text);      //
            file.WriteLine(masteryBox.Text);     //
            file.WriteLine(actionsBox.Text);     //
            file.WriteLine(weaponsList.Text);
            file.WriteLine(wDropChanceBox.Text); //
            file.WriteLine(armorsList.Text);
            file.WriteLine(aDropChanceBox.Text); //
            file.WriteLine(agilityGainBox.Text);
            file.WriteLine(actionsGainBox.Text);
            file.WriteLine(maxEnergyGainBox.Text);
            file.WriteLine(maxHealthGainBox.Text);
            file.WriteLine(precisionGainBox.Text);
            file.WriteLine(ability1Box.Text);
            file.WriteLine(ability2Box.Text);
            file.WriteLine(ability3Box.Text);
            file.Close();
            curCharacter = filePrefix + nameBox.Text + ".txt";


            verifyCharacter();
            refreshButton.PerformClick();
        }
示例#2
0
        void create()
        {
            string        fileDirectory = "./Data/Characters";
            List <string> localTemp     = new List <string>();
            DirectoryInfo d             = new DirectoryInfo(fileDirectory); //Assuming Test is your Folder

            FileInfo[] Files = d.GetFiles("*.txt");                         //Getting Text files
            int        newID = 0;

            foreach (FileInfo character in Files)
            {
                newID++;
            }
            string filePrefix = newID.ToString("D4");
            string filePath   = "./Data/Characters/" + filePrefix + charName + ".txt";

            if (File.Exists(filePath))
            {
                if (notification0 == null)
                {
                    notification0 = new message0();
                }
                if (notification0.ShowDialog() == DialogResult.OK)
                {
                    File.Create(filePath).Close();
                }
            }
            else
            {
                File.Create(filePath).Close();
            }


            StreamWriter file = new StreamWriter(filePath);

            file.WriteLine(newID);
            file.WriteLine(charName);
            file.WriteLine(exp);
            file.WriteLine(maxHealth);
            file.WriteLine(agilityNum);
            file.WriteLine(precisionNum);
            file.WriteLine(maxEnergy);
            file.WriteLine(masteryNum);
            file.WriteLine(actionsNum);
            for (int i = 9; i < 20; i++)
            {
                file.WriteLine("");
            }
            file.Close();
        }