/// <summary> /// Creates a new instance of Calculator form. /// </summary> /// <param name="file"></param> /// <param name="vehicleName"></param> public CalculatorForm(AiFile file, string vehicleName) { InitializeComponent(); // Add vehicle name to window title this.Text += vehicleName; this.WorkingFile = file; // Set default index VehicleStrengthSelect.SelectedIndex = 0; // Get an array of PCO positions AiTemplate[] Pcos = ( from x in file.Objects where x.Value.TemplateType == TemplateType.AiTemplate select x.Value as AiTemplate ).ToArray(); // Create PCO Values array, making a slot for each template PcoValueArray = new PcoObject[Pcos.Length]; // Current vehicle index int index = 0; // Add each vehicle position to the seat selector foreach (AiTemplate template in Pcos) { // Add PCO position ObjectSelect.Items.Add(template); // Create PCO values PcoValueArray[index++] = new PcoObject(); // Only the main vehicle will have an armor type if (template.Plugins.ContainsKey(AiTemplatePluginType.Physical)) { string T = template.Plugins[AiTemplatePluginType.Physical].Properties["setStrType"][0].Values[0]; switch (T.ToLowerInvariant()) { case "lightarmour": VehicleStrengthSelect.SelectedIndex = 1; break; case "heavyarmour": VehicleStrengthSelect.SelectedIndex = 2; break; case "helicopter": case "airplane": VehicleStrengthSelect.SelectedIndex = 3; break; } } } // Set main set as index, which will also remove the Suppression of events ObjectSelect.SelectedIndex = 0; }
private void ObjectSelect_SelectedIndexChanged(object sender, EventArgs e) { // Suppress so calculator doesnt run multiple times here this.SuppressUpdate = true; // Load pco PcoObject pco = PcoValueArray[ObjectSelect.SelectedIndex]; ExposureSelect.SelectedIndex = pco.SoldierExposureIndex; IsDriverBox.Checked = pco.IsDriver; PosHasWeaponBox.Checked = pco.HasWeapon; PosIsPowerfulBox.Checked = pco.WeaponIsPowerful; PosIsEffective.Checked = pco.WeaponIsEffective; CanFireWpnBox.Checked = pco.CanFireHandWeapon; IsMobileBox.Checked = pco.IsMobile; IsStationaryBox.Checked = pco.IsMountedWeapon; CanTakeCPBox.Checked = pco.CanTakeCP; this.SuppressUpdate = false; UpdateValues(); }
/// <summary> /// Reads the values from a PCO object and calculates the basicTemp, Offensive /// strategic strength, and Defensive strategic strength /// </summary> /// <param name="Pco"></param> /// <param name="basicTemp"></param> /// <param name="offStr"></param> /// <param name="defStr"></param> private void CalculateValues(PcoObject Pco, out int basicTemp, out int offStr, out int defStr) { // Reset Base values to 0 basicTemp = offStr = defStr = 0; // Set base temp based on vehicle type switch (VehicleStrengthSelect.SelectedIndex) { case 1: basicTemp = 16; break; case 2: basicTemp = 24; break; case 3: basicTemp = 20; break; case 4: basicTemp = 12; break; } // Soldier Exposure basicTemp += Pco.SoldierExposureIndex; if (Pco.IsDriver) { basicTemp += 9; } if (Pco.HasWeapon) { basicTemp += 5; offStr += 1; defStr += 2; // Is a a powerul cannon? if (Pco.WeaponIsPowerful) { offStr += 5; defStr += 5; } // Effective at killing other Armor's if (Pco.WeaponIsEffective) { defStr += 2; } } else if (Pco.CanFireHandWeapon) { // Only offensive if we arent stationary! if (VehicleStrengthSelect.SelectedIndex < 4) { offStr += 1; } defStr += 2; } if (Pco.IsMobile) { basicTemp += 1; offStr += 5; } if (Pco.CanTakeCP) { offStr += 1; defStr += 2; } if (Pco.IsMountedWeapon) { defStr += 1; } // Do Seat calculation basicTemp -= ((int)Math.Floor(NumberSeats.Value / 2)); }