private void GenerateMasteryItemControl(MasteryTreeItemStatic masteryTreeItem, int xPos, int yPos, int row, string treeType) { try { MasteryStatic masteryData = getMasteriesFromServer.masteries.Masteries.FirstOrDefault(o => o.Value.Id == masteryTreeItem.MasteryId).Value; string file = string.Format(@"{0}\Data\Masteries\Images\{1}\{2}", PublicStaticVariables.thisAppDataDir, getMasteriesFromServer.version, masteryData.Image.Sprite); Image masteryImage = Image.FromFile(file); masteryImage = CommonMethods.cropImage(masteryImage, new Rectangle(masteryData.Image.X, masteryData.Image.Y, masteryData.Image.Width, masteryData.Image.Height)); string grayFile = string.Format(@"{0}\Data\Masteries\Images\{1}\{2}", PublicStaticVariables.thisAppDataDir, getMasteriesFromServer.version, "gray_" + masteryData.Image.Sprite); Image masteryGrayImage = Image.FromFile(grayFile); Image grayMasteryImage = CommonMethods.cropImage(masteryGrayImage, new Rectangle(masteryData.Image.X, masteryData.Image.Y, masteryData.Image.Width, masteryData.Image.Height)); MasteryControl masteryControl = new MasteryControl(); masteryControl.GenerateMasteryControl(masteryImage, grayMasteryImage, this, masteryData, row, treeType); masteryControl.Location = new Point(xPos, yPos); picBoxMasteryMain.Controls.Add(masteryControl); masteryControl.SendToBack(); listOfMasteryControls.Add(masteryData.Id.ToString(), masteryControl); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private StatsStatic GetMasteryStats(StatsStatic statsStatic) { foreach (Control c in form1.masteriesTab.picBoxMasteryMain.Controls) { if (c.GetType() == typeof(MasteryControl)) { try { MasteryControl p = c as MasteryControl; if (p.currentRank != 0) { try { StatsStatic statsPreped = (StatsStatic)p.masteryData.StatsList[p.currentRank - 1]; Type myType = typeof(StatsStatic); System.Reflection.PropertyInfo[] properties = myType.GetProperties(); foreach (System.Reflection.PropertyInfo property in properties) { Double statValue = (Double)statsPreped.GetType().GetProperty(property.Name).GetValue(statsPreped); if (statValue != 0.0) { Double newValue = (Double)statsStatic.GetType().GetProperty(property.Name).GetValue(statsStatic); if (property.Name == "PercentSlowReistance" || property.Name == "PercentTenacityMod" || property.Name == "RPercentArmorPenetrationMod" || property.Name == "RFlatMagicPenetrationMod") { newValue = (1 - (1 - statValue) * (1 - newValue)); } else { newValue += statValue; } statsStatic.GetType().GetProperty(property.Name).SetValue(statsStatic, newValue); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } } return(statsStatic); }