示例#1
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tbName.Text) || string.IsNullOrEmpty(tbDescription.Text))
            {
                MessageBox.Show("You must enter a name and description", "Error");
                return;
            }

            rpg = new RolePlayingGame(tbName.Text, tbDescription.Text);

            this.Close();
        }
示例#2
0
        private void OpenGame(string path)
        {
            gamePath = path;
            classPath = Path.Combine(gamePath, "Classes");
            itemPath = Path.Combine(gamePath, "Items");
            keyPath = Path.Combine(gamePath, "Keys");
            chestPath = Path.Combine(gamePath, "Chests");
            skillPath = Path.Combine(gamePath, "Skills");

            if (!Directory.Exists(keyPath))
            {
                Directory.CreateDirectory(keyPath);
            }

            if (!Directory.Exists(chestPath))
            {
                Directory.CreateDirectory(chestPath);
            }

            if (!Directory.Exists(skillPath))
            {
                Directory.CreateDirectory(skillPath);
            }

            rolePlayingGame = XnaSerializer.Deserialize<RolePlayingGame>(gamePath + @"\Game.xml");

            FormDetails.ReadEntityData();
            FormDetails.ReadItemData();
            FormDetails.ReadKeyData();
            FormDetails.ReadChestData();
            FormDetails.ReadSkillData();

            PrepareForms();
        }
示例#3
0
        void newGameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            using (FormNewGame frmNewGame = new FormNewGame())
            {
                DialogResult result = frmNewGame.ShowDialog();

                if (result == DialogResult.OK && frmNewGame.RolePlayingGame != null)
                {
                    FolderBrowserDialog folderDialog = new FolderBrowserDialog();

                    folderDialog.Description = "Select directory to create folder in";
                    folderDialog.SelectedPath = Application.StartupPath;

                    DialogResult folderResult = folderDialog.ShowDialog();

                    if (folderResult == DialogResult.OK)
                    {
                        try
                        {
                            gamePath = Path.Combine(folderDialog.SelectedPath, "Game");
                            classPath = Path.Combine(gamePath, "Classes");
                            itemPath = Path.Combine(gamePath, "Items");
                            keyPath = Path.Combine(gamePath, "Keys");
                            chestPath = Path.Combine(gamePath, "Chests");
                            skillPath = Path.Combine(gamePath, "Skills");

                            if (Directory.Exists(gamePath))
                            {
                                throw new Exception("Folder already exists.");
                            }

                            Directory.CreateDirectory(gamePath);
                            Directory.CreateDirectory(classPath);
                            Directory.CreateDirectory(itemPath + @"\Armor");
                            Directory.CreateDirectory(itemPath + @"\Shield");
                            Directory.CreateDirectory(itemPath + @"\Weapon");
                            Directory.CreateDirectory(keyPath);
                            Directory.CreateDirectory(chestPath);
                            Directory.CreateDirectory(skillPath);

                            rolePlayingGame = frmNewGame.RolePlayingGame;
                            XnaSerializer.Serialize<RolePlayingGame>(gamePath + @"\Game.xml", rolePlayingGame);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.ToString());
                            return;
                        }

                        classesToolStripMenuItem.Enabled = true;
                        itemsToolStripMenuItem.Enabled = true;
                        keysToolStripMenuItem.Enabled = true;
                        chestsToolStripMenuItem.Enabled = true;
                        skillsToolStripMenuItem.Enabled = true;
                    }
                }
            }
        }
示例#4
0
        private void OpenGame(string path)
        {
            gamePath = path;
            classPath = Path.Combine(gamePath, "Classes");
            itemPath = Path.Combine(gamePath, "Items");
            keyPath = Path.Combine(gamePath, "Keys");
            chestPath = Path.Combine(gamePath, "Chests");
            skillPath = Path.Combine(gamePath, "Skills");

            rolePlayingGame = XNASerializer.Deserialize<RolePlayingGame>(gamePath + "\\Game.xml");

            FormDetails.ReadEntityData();
            FormDetails.ReadItemData();
            FormDetails.ReadKeyData();
            FormDetails.ReadChestData();
            FormDetails.ReadSkillData();

            PrepareForms();
        }