private void btnCreate_Click(object sender, EventArgs e) { player = new Player(HitPoints, HitPoints, 10, 0, 1, Strength, Dex, Int, Mana, Mana, currentRace); if (currentRace.ID == World.RACE_ID_HUNMAN) { player.Gold += 10; } else if (currentRace.ID == World.RACE_ID_ELF) { player.AddSpell(World.SpellByID(World.SPELL_ID_FIREBALL)); } else if (currentRace.ID == World.RACE_ID_ORC) { player.AddItem((Armour)World.ItemByID(World.ITEM_ID_METAL_ARMOUR), 1); player.ArmourUsed = (Armour)World.ItemByID(World.ITEM_ID_METAL_ARMOUR); } else if (currentRace.ID == World.RACE_ID_DWARF) { player.AddItem(World.ItemByID(World.ITEM_ID_IRON_SWORD), 1); } player.CurrentLocation = World.LocationByID(World.LOCATION_ID_HOME); player.AddItem(World.ItemByID(World.ITEM_ID_RUSTY_SWORD), 1); GlobalSetting.CreateNewSave(fileName); FormAdventurePlus formAdventure = new FormAdventurePlus(player, fileName + ".xml"); formAdventure.Show(); this.Close(); }
private void btnLoad_Click(object sender, EventArgs e) { menu.Close(); this.Close(); try { Player player = Player.LoadPlayerInformationFromXml(File.ReadAllText(cbSavesList.SelectedItem.ToString() + ".xml")); FormAdventurePlus formAdventurePlus = new FormAdventurePlus(player, cbSavesList.SelectedItem.ToString() + ".xml"); formAdventurePlus.Show(); } catch { MessageBox.Show("The program couldn't load your save file, it may be missing or corrupted"); Application.Exit(); } }