private void btnCreate_Click(object sender, EventArgs e) { string name = txtName.Text; if (name == "") { MessageBox.Show("You need a name friend."); } else { if (statCount == 3) { Player p = new Player(name, str, con, dex); XElement player = new XElement("Player", new XElement("Name", name), new XElement("Strength", str), new XElement("Dexterity", dex), new XElement("Constitution", con) ); player.Save("player.xml"); string createChar = File.ReadAllText("player.xml"); Console.WriteLine(player); HubUI hubUi = new HubUI(p); hubUi.Show(); this.Close(); } else { MessageBox.Show("You still have some unallocated stat points!"); } } }
public HubUI(Player p) { User = p; InitializeComponent(); txtExp.Text = User.Experience.ToString(); txtExpNeeded.Text = ((User.Level * (User.Level - 1)) * 50).ToString(); txt_LVL.Text = User.Level.ToString(); }
public Shop(Player p) { User = p; InitializeComponent(); txt_Cash.Text = User.Cash.ToString(); lbo_Inventory.DataSource = User.Inventory; lbo_Inventory.DisplayMember = "Name"; lbo_Inventory.ValueMember = "Value"; }
public Battle(Player p, Monster m) { User = p; Mon = m; InitializeComponent(); txt_PlayerHP.Text = User.Health.ToString(); txt_EnemyHP.Text = Mon.Health.ToString(); lbl_EnemyName.Text = Mon.Name; foreach (var i in User.Inventory) { if (!i.Equipable) { lbo_Items.Items.Add(i.Name); } } }
private void btn_loadgame_Click(object sender, EventArgs e) { try { XElement plyr = XElement.Load("Player.xml"); string name = (string)plyr.Element("Name"); int str = (int)plyr.Element("Strength"); int con = (int)plyr.Element("Constitution"); int dex = (int)plyr.Element("Dexterity"); int lvl = (int)plyr.Element("Level"); int cash = (int)plyr.Element("Cash"); int xp = (int)plyr.Element("Experience"); Player p = new Player(name, str, con, dex, lvl, cash, xp); HubUI hubUi = new HubUI(p); hubUi.User = p; hubUi.Show(); Hide(); } catch { throw new NullReferenceException("No character to load!"); } }
public LevelUp(Player p) { User = p; InitializeComponent(); }
public Inventory(Player p) { User = p; InitializeComponent(); txt_Cash.Text = User.Cash.ToString(); txt_hp.Text = User.Health.ToString(); txt_str.Text = User.Strength.ToString(); txt_dex.Text = User.Dexterity.ToString(); txt_con.Text = User.Constitution.ToString(); txt_crit.Text = User.Crit.ToString(); txt_attpow.Text = User.AttPower.ToString(); txt_def.Text = User.Defense.ToString(); foreach (var i in User.Inventory) { if (!i.Equipable) { lbx_Backpack.Items.Add(i.Name); } else { foreach (XElement item in element.Elements("Armor")) { string n = (string)item.Element("Name"); int d = (int)item.Element("Defense"); int s = (int)item.Element("Slot"); int dm = (int)item.Element("DodgeMod"); int val = (int)item.Element("Value"); if (i.Name == (string)item.Element("Name")) { if (s == 1) { cbx_Head.Items.Add(i.Name); } else if (s == 2) { cbx_Chest.Items.Add(i.Name); } else if (s == 3) { cbx_Legs.Items.Add(i.Name); } else if (s == 4) { cbx_LeftHand.Items.Add(i.Name); } } } foreach (XElement item in element2.Elements("Weapon")) { string n = (string)item.Element("Name"); int ap = (int)item.Element("AttkPower"); bool th = (bool)item.Element("TwoHanded"); int init = (int)item.Element("Initiative"); int cc = (int)item.Element("CritChance"); int cdm = (int)item.Element("CritDmgMod"); int val = (int)item.Element("Value"); if (i.Name == (string)item.Element("Name")) { cbx_RightHand.Items.Add(i.Name); } } } } }