private void TradePalladium(UnitWrapper2 sender, UnitWrapper2 receiver) { if (CharactersLoaded()) { int palladiumToTrade = (int)nud_palladium.Value; //check if the sending character has enough palladium to trade if (palladiumToTrade > sender.CharacterWrapper.CharacterValues.Palladium) { palladiumToTrade = sender.CharacterWrapper.CharacterValues.Palladium; } //calculate the maximum amount of palladium the receiving character can store int maximumTradableAmount = receiver.CharacterWrapper.CharacterValues.MaxPalladium - receiver.CharacterWrapper.CharacterValues.Palladium; //calculate the real amount of palladium for trading if (maximumTradableAmount < palladiumToTrade) { palladiumToTrade = maximumTradableAmount; } receiver.CharacterWrapper.CharacterValues.Palladium += palladiumToTrade; sender.CharacterWrapper.CharacterValues.Palladium -= palladiumToTrade; l_palladium1.Text = _characterUnit1.CharacterWrapper.CharacterValues.Palladium.ToString(); l_palladium2.Text = _characterUnit2.CharacterWrapper.CharacterValues.Palladium.ToString(); RequiresUserVerification(); } }
private void InitInventory(UnitWrapper2 unit, ItemPanel itemPanel) { itemPanel.Controls.Clear(); try { CharacterInventoryType inv = unit.CharacterWrapper.CharacterInventory.GetInventoryById((int)INVENTORYTYPE); if (inv == null) return; foreach (CharacterItems item in inv.Items) { //Unit.StatBlock.Stat atat = item.Stats.GetStatById((int)ItemValueNames.applied_affix); itemPanel.IsMale = _isMale; InventoryItem iItem = new InventoryItem(item); iItem.InitButton(_displayNamesAndQuantity); itemPanel.AddItem(iItem, true); } } catch (Exception ex) { MessageBox.Show(ex.Message, "InitInventory: " + unit.Name); } }
private void b_loadCharacter2_Click(object sender, EventArgs e) { l_selectedItem.ResetText(); l_selectedItem.Tag = null; _characterPath2 = _characterFolder + @"\" + cb_selectCharacter2.SelectedItem + ".hg1"; if (_characterPath1 != _characterPath2) { _characterUnit2 = new UnitWrapper2(_characterPath2, fileManager); if (_characterUnit2 != null) { //_itemHelpFunctions.LoadCharacterValues(character); //_characterUnit2 = null;// todo: rewrite new UnitWrapper(_dataSet, character); //if (WeaponSlotsPopulated(_characterUnit2)) //{ // DisplayWeaponSlotWarning(); //} gb_characterName2.Text = cb_selectCharacter2.SelectedItem.ToString(); int level = _characterUnit2.CharacterWrapper.CharacterValues.Level; gb_characterName2.Text += " (Level " + level.ToString() + " " + _characterUnit2.CharacterWrapper.ClassName + ")"; l_palladium2.Text = _characterUnit2.CharacterWrapper.CharacterValues.Palladium.ToString(); if (_characterUnit2.CharacterWrapper.CharacterInventory.CheckIfInventoryIsPopulated((int)InventoryTypes.CurrentWeaponSet)) { SetCharacterStatus(_characterStatus2, CharacterStatus.WeaponSetDetected, p_status2, l_status2); } else { SetCharacterStatus(_characterStatus2, CharacterStatus.Loaded, p_status2, l_status2); } InitInventory(_characterUnit2, _characterItemPanel2); } else { _characterPath2 = null; _characterUnit2 = null; _characterItemPanel2.Controls.Clear(); l_palladium2.Text = "-"; SetCharacterStatus(_characterStatus2, CharacterStatus.Error, p_status2, l_status2); //MessageBox.Show("Error while parsing the character file!"); } } else { _characterPath2 = null; _characterUnit2 = null; _characterItemPanel2.Controls.Clear(); l_palladium2.Text = "-"; SetCharacterStatus(_characterStatus2, CharacterStatus.AlreadyLoaded, p_status2, l_status2); SameCharacterSelected(); } CheckAndSetButtonStatus(); }
private void b_loadCharacter1_Click(object sender, EventArgs e) { l_selectedItem.ResetText(); l_selectedItem.Tag = null; _characterPath1 = _characterFolder + @"\" + cb_selectCharacter1.SelectedItem + ".hg1"; if (_characterPath1 != _characterPath2) { _characterUnit1 = new UnitWrapper2(_characterPath1, fileManager); if (_characterUnit1 != null)// && character.IsGood) { //_itemHelpFunctions.LoadCharacterValues(_characterUnit1.BaseCharacter.Character); gb_characterName1.Text = cb_selectCharacter1.SelectedItem.ToString(); int level = _characterUnit1.CharacterWrapper.CharacterValues.Level; gb_characterName1.Text += " (Level " + level.ToString() + " " + _characterUnit1.CharacterWrapper.ClassName + ")"; l_palladium1.Text = _characterUnit1.CharacterWrapper.CharacterValues.Palladium.ToString(); if (_characterUnit1.CharacterWrapper.CharacterInventory.CheckIfInventoryIsPopulated((int)InventoryTypes.CurrentWeaponSet)) { SetCharacterStatus(_characterStatus1, CharacterStatus.WeaponSetDetected, p_status1, l_status1); } else { SetCharacterStatus(_characterStatus1, CharacterStatus.Loaded, p_status1, l_status1); } InitInventory(_characterUnit1, _characterItemPanel1); } else { _characterPath1 = null; _characterUnit1 = null; _characterItemPanel1.Controls.Clear(); l_palladium1.Text = "-"; SetCharacterStatus(_characterStatus1, CharacterStatus.Error, p_status1, l_status1); //MessageBox.Show("Error while parsing the character file!"); } } else { _characterPath1 = null; _characterUnit1 = null; _characterItemPanel1.Controls.Clear(); l_palladium1.Text = "-"; SetCharacterStatus(_characterStatus1, CharacterStatus.AlreadyLoaded, p_status1, l_status1); SameCharacterSelected(); } CheckAndSetButtonStatus(); }
private void savegameOverviewToolStripMenuItem_Click(object sender, EventArgs e) { //pre-load the tables to prevent additional waiting times when accessing certain information later on _fileManager.PreLoadTable("ITEMS"); _fileManager.PreLoadTable("PLAYERS"); _fileManager.PreLoadTable("SKILLS"); _fileManager.PreLoadTable("STATS"); string[] savegames = Directory.GetFiles(Config.SaveDir, "*.hg1"); SavegameOverviewForm savegameForm = new SavegameOverviewForm(); foreach (string savegame in savegames) { UnitWrapper2 wrapper = new UnitWrapper2(savegame, _fileManager); savegameForm.AddCharacter(wrapper); } savegameForm.Show(this); }
public void AddCharacter(UnitWrapper2 wrapper) { savegameOverviewControl1.AddCharacter(wrapper); }