private void populateTableRow(Ship ship, ShipMetrics metrics) { try { DataRow row = table.NewRow(); int rowIdx = 0; foreach (var obj in userSelectedFields.Items) { string itm = (string)obj; Option opt = this.mapping[itm]; if (opt != null) { if (opt.ClassName.Equals(typeof(Ship).Name)) { row[rowIdx] = GetFieldValue(ship, opt.Value); } else if (opt.ClassName.Equals(typeof(ShipMetrics).Name)) { row[rowIdx] = GetFieldValue(metrics, opt.Value); //Console.WriteLine(opt.Value) } } rowIdx++; } table.Rows.Add(row); } catch (Exception ex) { Console.WriteLine(ex); } }
// Use this for initialization void Start() { _shipMetrics = FindObjectOfType<ShipMetrics>(); _slider = GetComponent<Slider>(); List<Text> texts = new List<Text>(GetComponentsInChildren<Text>()); _text = texts.Find(text => text.name == "Number"); }
// Use this for initialization void Start() { _slider = GetComponent<Slider>(); _text = GetComponentInChildren<Text>(); List<Text> texts = new List<Text>(GetComponentsInChildren<Text>()); _text = texts.Find(text => text.name == "Setting"); _slider.onValueChanged.AddListener(SetThrust); _shipMetrics = FindObjectOfType<ShipMetrics>(); }
public void SelectShip(Ship RandomizedShip) { LOG.Debug("SelectShip(" + RandomizedShip.Name + ")"); ClearSelections(); selectedShip = RandomizedShip; TableLayoutPanel tl = this.Controls.Find("ShipMetricsTable", true).FirstOrDefault() as TableLayoutPanel; MetricsExctractor Extractor = new MetricsExctractor(RandomizedShip); Metrics = Extractor.GetMetrics(); MetricsDrawer Drawer = new MetricsDrawer(tl); MetricsTableComposer.DrawTable(Extractor, Drawer); picShip.Load(RandomizedShip.Images.Small); this.Text = "Build Manager: " + RandomizedShip.Name; panelCaptainSkills.Enabled = true; panelFlags.Enabled = true; upgradeSlot1.Enabled = true; if (RandomizedShip.Tier >= 3) { upgradeSlot2.Enabled = true; upgradeSlot2.Visible = true; } if (RandomizedShip.Tier >= 5) { upgradeSlot3.Enabled = true; upgradeSlot3.Visible = true; } if (RandomizedShip.Tier >= 6) { upgradeSlot4.Enabled = true; upgradeSlot4.Visible = true; } if (RandomizedShip.Tier >= 8) { upgradeSlot5.Enabled = true; upgradeSlot5.Visible = true; } if (RandomizedShip.Tier >= 9) { upgradeSlot6.Enabled = true; upgradeSlot6.Visible = true; } string type = RandomizedShip.ShipType.ToLower(); LoadSkills(AbbreviateShipType(type)); cbCamoflage.Enabled = true; bmHandler = new BuildManagerHandler(ShipMetricsTable, Metrics); }
private void addRows() { table.Rows.Clear(); List <Ship> ShipQuery; List <string> conditions = AssembleConditions(); if (cbAllShips.Checked) { ShipQuery = new List <Ship>(Program.AllShips); } else { ShipQuery = new List <Ship>(AssembleShipList()); } foreach (Ship ship in ShipQuery) { MetricsExctractor extractor = new MetricsExctractor(ship); if (!(conditions.Contains(CONDITION_ALLSHIPS) || conditions.Contains(ship.ShipType.ToString()))) { { continue; } } if (!(conditions.Contains(CONDITION_ALLTIERS) || conditions.Contains(ship.Tier.ToString()))) { continue; } if (!(conditions.Contains("PS:" + ship.Premium.ToString().ToLower()))) { continue; } if (!(conditions.Contains(CONDITION_ALLNATIONS) || conditions.Contains(ship.Country.ToString()))) { continue; } ShipMetrics metrics = extractor.GetMetrics(); if (isConditionMetForShip(ship, metrics) == false) { continue; } populateTableRow(ship, metrics); } resultGrid.Sort(resultGrid.Columns[0], ListSortDirection.Ascending); }
private bool isConditionMetForShip(Ship ship, ShipMetrics metrics) { foreach (string query in listQuery.Items) { string[] tmp = query.Split(' '); string fldName = tmp[0]; string queryCondition = tmp[1]; string queryValue = tmp[2]; double queryValueDbl = 0.0; string fieldValue = ""; double fieldValueDbl = 0.0; bool compareDouble = false; Option opt = this.mapping[fldName]; if (opt.ClassName.Equals(typeof(Ship).Name)) { object val = GetFieldValue(ship, opt.Value); if (val is double) { fieldValueDbl = (double)val; compareDouble = true; } fieldValue = val.ToString(); } else if (opt.ClassName.Equals(typeof(ShipMetrics).Name)) { object val = GetFieldValue(metrics, opt.Value); if (val is double) { fieldValueDbl = (double)val; compareDouble = true; } fieldValue = val.ToString(); } else { return(false); } if (compareDouble) { queryValueDbl = SafeConvertToDouble(queryValue); } if (queryCondition.Equals("!=")) { if ((compareDouble && queryValueDbl == fieldValueDbl) || (compareDouble == false && fieldValue.Equals(queryValue))) { return(false); } } else if (queryCondition.Equals("=")) { if ((compareDouble && queryValueDbl != fieldValueDbl) || (compareDouble == false && !fieldValue.Equals(queryValue))) { return(false); } } else if (queryCondition.StartsWith("<")) { // This can only be done on values - not strings. If field is string, we need to convert to double; if (compareDouble == false) { queryValueDbl = SafeConvertToDouble(queryValue); fieldValueDbl = SafeConvertToDouble(fieldValue); } bool isEqualOk = queryCondition.Contains("="); if (queryValueDbl < fieldValueDbl) { return(false); } else if (isEqualOk == false && queryValueDbl == fieldValueDbl) { return(false); } } else if (queryCondition.StartsWith(">")) { // This can only be done on values - not strings. If field is string, we need to convert to double; if (compareDouble == false) { queryValueDbl = SafeConvertToDouble(queryValue); fieldValueDbl = SafeConvertToDouble(fieldValue); } bool isEqualOk = queryCondition.Contains("="); if (fieldValueDbl < queryValueDbl) { return(false); } else if (isEqualOk == false && queryValueDbl == fieldValueDbl) { return(false); } } } return(true); }
private void ClearSelections(bool keepSelectedShip = false) { LOG.Debug("ClearSelections(" + keepSelectedShip + ")"); bmHandler = null; upgradeSlot1.Controls.Clear(); upgradeSlot2.Controls.Clear(); upgradeSlot2.Visible = false; upgradeSlot2.Enabled = false; upgradeSlot3.Controls.Clear(); upgradeSlot3.Visible = false; upgradeSlot3.Enabled = false; upgradeSlot4.Controls.Clear(); upgradeSlot4.Visible = false; upgradeSlot4.Enabled = false; upgradeSlot5.Controls.Clear(); upgradeSlot5.Visible = false; upgradeSlot5.Enabled = false; upgradeSlot6.Controls.Clear(); upgradeSlot6.Visible = false; upgradeSlot6.Enabled = false; ShipMetricsTable.Controls.Clear(); foreach (Control ctrl in panelCaptainSkills.Controls) { if (ctrl is PictureBox box) { box.BorderStyle = BorderStyle.None; box.AccessibleDescription = ""; box.Refresh(); box.Image = null; } } totalSkillPoints.Text = "0"; panelCaptainSkills.Enabled = false; foreach (Control ctrl in panelFlags.Controls) { if (ctrl is PictureBox box) { box.BorderStyle = BorderStyle.None; box.AccessibleDescription = ""; box.Refresh(); } } combatFlagsCount.Text = "0"; panelFlags.Enabled = false; cbCamoflage.Checked = false; cbCamoflage.Enabled = false; Metrics = null; if (keepSelectedShip == false) { picShip.Image = null; selectedShip = null; this.Text = "Build Manager"; } else { SelectShip(selectedShip); } }