// ++++++++++++++++++++++++++++++++++++++++++++++++ public void CreateDefaultObjects() { this.shipObjects = new List<ShipObject>(); this.pointCounter = new PointCounter(); this.resourceManager = new ResourceManager(); }
private void CreateUpgradeObject(string selectedItem, string selectedId) { for (int i = 0; i < this.upgradeNodeList.Count; i++) { XmlNode node = this.upgradeNodeList[i]; if (node["Id"].InnerText == selectedId) { UpgradeObject upgrade = new UpgradeObject(node["Type"].InnerText); upgrade.LoadXmlIntoUpgradeObject(node); //UNIQUE UPGRADE CHECK if (upgrade.uniqueFlag) { for (int j = 0; j < this.shipObjects.Count; j++) { for (int k = 0; k < this.shipObjects[j].upgradeObjects.Count; k++) { if (this.shipObjects[j].upgradeObjects[k] != null) { if (this.shipObjects[j].upgradeObjects[k].title == upgrade.title) { MessageBox.Show("Unique upgrade already exists in Squadron List.", "Error"); return; } } } } } // JEM HADAR UPGRADE & SHIP CHECK if ((upgrade.special.ToLower() == "onlyjemhadarships") && (this.shipObjects[this.activeListBoxValue].shipClass.ToLower() != "jem'hadar attack ship")) { MessageBox.Show("This Upgrade can only be added to a Jem'Hadar Ship"); return; } this.shipObjects[this.activeListBoxValue].AssignUpgradeToShip(upgrade); this.pointCounter = new PointCounter(); this.pointCounter.RecalculatePointTotals(this.shipObjects, this.resourceManager.resourceObjects); this.form.RefreshSelectedObjectsListBox(); return; } } }
private void CreateResourceObject(string selectedItem, string selectedId) { for (int i = 0; i < this.resourcesNodeList.Count; i++) { XmlNode node = this.resourcesNodeList[i]; if (node["Id"].InnerText == selectedId) { ResourceObject resource = new ResourceObject(node); //UNIQUE UPGRADE CHECK if (resource.uniqueFlag) { for (int j = 0; j < this.resourceManager.resourceObjects.Count; j++) { if (this.resourceManager.resourceObjects[j].title == resource.title) { MessageBox.Show("Unique Resource already exists in Squadron List.", "Error"); return; } } } this.resourceManager.resourceObjects.Add(resource); this.pointCounter = new PointCounter(); this.pointCounter.RecalculatePointTotals(this.shipObjects, this.resourceManager.resourceObjects); this.form.RefreshSelectedObjectsListBox(); return; } } }
private void CreateNewCaptain(string selectedItem, string selectedId) { for (int i = 0; i < this.captainNodeList.Count; i++) { XmlNode node = this.captainNodeList[i]; if (node["Id"].InnerText == selectedId) { CaptainObject captain = new CaptainObject(node); //UNIQUE CAPTAIN CHECK if (captain.uniqueFlag) { for (int j = 0; j < this.shipObjects.Count; j++) { if (this.shipObjects[j].captainObject != null) { if (this.shipObjects[j].captainObject.title == captain.title) { MessageBox.Show("Unique captain already exists in Squadron List.", "Error"); return; } } } } this.shipObjects[this.activeListBoxValue].AssignCaptainToShip(captain); this.pointCounter = new PointCounter(); this.pointCounter.RecalculatePointTotals(this.shipObjects, this.resourceManager.resourceObjects); this.form.RefreshSelectedObjectsListBox(); return; } } }
public void RemoveSelectedShipBasedObject(string removalItemType, string removalItemName, string removalIndex, string removalUpgradeIndex) { switch(removalItemType.ToLower()) { case "ship": this.shipObjects.RemoveAt(Convert.ToInt32(removalIndex)); break; case "captain": this.shipObjects[Convert.ToInt32(removalIndex)].CreateEmptyCaptainObject(); break; case "upgrade": string upgradeType = this.shipObjects[Convert.ToInt32(removalIndex)].upgradeObjects[Convert.ToInt32(removalUpgradeIndex)].type; this.shipObjects[Convert.ToInt32(removalIndex)].upgradeObjects[Convert.ToInt32(removalUpgradeIndex)] = this.shipObjects[Convert.ToInt32(removalIndex)].CreateEmptyUpgradeObject(upgradeType); break; } this.pointCounter = new PointCounter(); this.pointCounter.RecalculatePointTotals(this.shipObjects, this.resourceManager.resourceObjects); this.form.RefreshSelectedObjectsListBox(); }
public void RemoveSelectedResourceObject(string resourceIndex) { this.resourceManager.resourceObjects.RemoveAt(Convert.ToInt32(resourceIndex)); this.pointCounter = new PointCounter(); this.pointCounter.RecalculatePointTotals(this.shipObjects, this.resourceManager.resourceObjects); this.form.RefreshSelectedObjectsListBox(); }