Ejemplo n.º 1
0
        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;
                }
            }
        }