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!"); } } }
private void btn_DexPlus_Click(object sender, EventArgs e) { Player p = User; User.Dexterity += 1; User.Level += 1; User.Health = 100 + (10 * User.Constitution) + (User.Level * 5); p.Calculate_SubStats(); HubUI hub = new HubUI(p); hub.Show(); this.Close(); }
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!"); } }
private void btn_ExitShop_Click(object sender, EventArgs e) { Player p = User; HubUI hub = new HubUI(p); hub.Show(); this.Hide(); }
private void btn_Attack_Click(object sender, EventArgs e) { double monDmg = Mon.AttPower; double userDmg = User.AttPower; if (rnd.Next(1, 100) < User.Crit*100 ) { userDmg = User.AttPower * 2; } if (rnd.Next(1, 100) < Mon.Crit*100) { monDmg = Mon.AttPower * 2; } if (monDmg >= User.Health) { User.Health = 0; aar = Mon.Name + " inflicted a near-fatal blow on " + User.Name + "!"; lbo_BattleLog.Items.Add(aar); User.Health = 1; User.Experience = User.Experience - Mon.ExperienceValue; MessageBox.Show(User.Name + " barely makes it away in one piece. Be more careful next time!"); Player p = User; HubUI newHub = new HubUI(p); newHub.Show(); this.Close(); } else if (userDmg >= Mon.Health) { aar = User.Name + " inflicted a fatal blow on " + Mon.Name + "!"; lbo_BattleLog.Items.Add(aar); User.Experience = User.Experience + Mon.ExperienceValue; User.Cash += Mon.RndCashLoot; MessageBox.Show(User.Name + " vanquished the " + Mon.Name + "! You gain " + Mon.ExperienceValue + "XP and " + Mon.RndCashLoot + " bucks!"); if (User.Experience >= ((User.Level * (User.Level - 1)) * 50)) { Player p = User; LevelUp lvlup = new LevelUp(p); lvlup.Show(); this.Close(); } else { Player p = User; HubUI hub = new HubUI(p); hub.Show(); this.Close(); } } else { Mon.Health -= Convert.ToInt32((userDmg - (Mon.Defense * 1.0))); aar = User.Name + " hit " + Mon.Name + " for " + User.AttPower + " DMG!"; lbo_BattleLog.Items.Add(aar); User.Health -= Convert.ToInt32((monDmg - (User.Defense * 1.0))); aar = Mon.Name + " hit " + User.Name + " for " + Mon.AttPower + " DMG!"; lbo_BattleLog.Items.Add(aar); txt_PlayerHP.Text = User.Health.ToString(); txt_EnemyHP.Text = Mon.Health.ToString(); monDmg = Mon.AttPower; userDmg = User.AttPower; } }
private void btn_Flee_Click(object sender, EventArgs e) { double monDmg = Mon.AttPower; if ((User.GearInitiativeMod + (User.Dexterity * 3)) < ((Mon.Dexterity * 3) + Mon.Initiative)) { User.Health -= Convert.ToInt32((monDmg - (User.Defense * 2.0))); aar = Mon.Name + " hit " + User.Name + " for " + (monDmg - (User.Defense * 2.0)) + " DMG!"; MessageBox.Show(User.Name + " took a hit but ran away from the " + Mon.Name); Player p = User; HubUI hub = new HubUI(p); hub.Show(); this.Close(); } else { MessageBox.Show(User.Name + " ran away from the " + Mon.Name + " before getting hit!"); Player p = User; HubUI hub = new HubUI(p); hub.Show(); this.Close(); } }