Example #1
0
        public Ship(XElement ship)
            : base(ship)
        {
            this._crew              = new ObservableCollection <CMember>();
            this._tradeQueue        = new ObservableCollection <XElement>();
            this._constructionWares = new ObservableCollection <XElement>();
            this._drones            = new ObservableCollection <XElement>();

            if (ship.Attribute("name") == null)
            {
                EntityValueConverter conv = new EntityValueConverter();
                XAttribute           name = new XAttribute("name", conv.Convert(ship.Attribute("macro").Value, null, null, null));
                ship.Add(name);
            }

            IEnumerable <XElement> crewquery =
                from crew in this.Data.Descendants().Elements("component")
                where (string)crew.Attribute("class") == "npc"
                select crew;

            foreach (XElement person in crewquery)
            {
                Crew.Add(new CMember(person));
            }

            foreach (XElement trade in this.Data.Elements("trade").Elements("shopping").Elements("trade"))
            {
                TradeQueue.Add(trade);
            }

            IEnumerable <XElement> buildmodulesQuery =
                from buildmodules in this.Data.Descendants().Elements("connection")
                where (string)buildmodules.Attribute("macro") == "connection_buildmodule01"
                select buildmodules;

            IEnumerable <XElement> constructionWaresQuery =
                from wares in buildmodulesQuery.Descendants <XElement>().Elements("resources").Elements("ware")
                select wares;

            foreach (XElement ware in constructionWaresQuery)
            {
                ConstructionWares.Add(ware);
            }

            foreach (XElement drone in this.Data.Elements("ammunition").Elements("available").Elements("item"))
            {
                Drones.Add(drone);
            }


            IEnumerable <XElement> cargoList =
                from cargo in this.Data.Descendants().Elements("component")
                where (string)cargo.Attribute("class") == "storage" & (string)cargo.Attribute("macro") != "unit_player_ship_storage_macro"
                select cargo;

            foreach (XElement cargoType in cargoList)
            {
                string cargoTypeName = cargoType.Attribute("macro").Value;
                switch (cargoTypeName)
                {
                case "storage_ship_l_bulk_01_macro":
                case "storage_ship_m_bulk_01_macro":
                case "storage_ship_l_bulk_02_macro":
                case "storage_ship_l_bulk_03_macro":
                case "storage_ship_l_bulk_04_macro":
                case "storage_ship_xl_bulk_01_macro":
                    BulkCargo = cargoType;
                    break;

                case "storage_ship_l_container_01_macro":
                case "storage_ship_l_container_02_macro":
                case "storage_ship_m_container_01_macro":
                case "storage_ship_xl_container_01_macro":
                    ContainerCargo = cargoType;
                    break;

                case "storage_ship_l_energy_01_macro":
                case "storage_ship_l_energy_02_macro":
                case "storage_ship_xl_energy_01_macro":
                case "storage_ship_m_energy_01_macro":
                    EnergyCargo = cargoType;
                    break;

                case "storage_ship_l_fuel_01_macro":
                case "storage_ship_xl_fuel_01_macro":
                    FuelCargo = cargoType;
                    break;

                case "storage_ship_l_liquid_01_macro":
                case "storage_ship_l_liquid_02_macro":
                case "storage_ship_l_liquid_03_macro":
                case "storage_ship_xl_liquid_01_macro":
                case "storage_ship_m_liquid_01_macro":
                    LiquidCargo = cargoType;
                    break;

                case "storage_ship_xl_universal_01_macro":
                case "storage_ship_xs_universal_01_macro":
                case "storage_temp_huge_macro":
                    UniversalCargo = cargoType;
                    break;
                }
            }

            Gravidar = this.Data.Element("gravidar");

            LoadDetails();
        }
Example #2
0
        public Ship(XElement ship)
            : base(ship)
        {
            this._crew = new ObservableCollection<CMember>();
            this._tradeQueue = new ObservableCollection<XElement>();
            this._constructionWares = new ObservableCollection<XElement>();
            this._drones = new ObservableCollection<XElement>();

            if (ship.Attribute("name") == null)
            {
                EntityValueConverter conv = new EntityValueConverter();
                XAttribute name = new XAttribute("name", conv.Convert(ship.Attribute("macro").Value, null, null, null));
                ship.Add(name);
            }

            IEnumerable<XElement> crewquery =
            from crew in this.Data.Descendants().Elements("component")
            where (string) crew.Attribute("class") == "npc"
            select crew;

            foreach (XElement person in crewquery)
                Crew.Add(new CMember(person));

            foreach (XElement trade in this.Data.Elements("trade").Elements("shopping").Elements("trade"))
                TradeQueue.Add(trade);

            IEnumerable<XElement> buildmodulesQuery =
            from buildmodules in this.Data.Descendants().Elements("connection")
            where (string) buildmodules.Attribute("macro") == "connection_buildmodule01"
            select buildmodules;

            IEnumerable<XElement> constructionWaresQuery =
            from wares in buildmodulesQuery.Descendants<XElement>().Elements("resources").Elements("ware")
            select wares;

            foreach (XElement ware in constructionWaresQuery)
                ConstructionWares.Add(ware);

            foreach (XElement drone in this.Data.Elements("ammunition").Elements("available").Elements("item"))
                Drones.Add(drone);

            IEnumerable<XElement> cargoList =
            from cargo in this.Data.Descendants().Elements("component")
            where (string) cargo.Attribute("class") == "storage" & (string) cargo.Attribute("macro") != "unit_player_ship_storage_macro"
            select cargo;

            foreach (XElement cargoType in cargoList)
            {
                string cargoTypeName = cargoType.Attribute("macro").Value;
                switch (cargoTypeName)
                {
                    case "storage_ship_l_bulk_01_macro":
                    case "storage_ship_m_bulk_01_macro":
                    case "storage_ship_l_bulk_02_macro":
                    case "storage_ship_l_bulk_03_macro":
                    case "storage_ship_l_bulk_04_macro":
                    case "storage_ship_xl_bulk_01_macro":
                        BulkCargo = cargoType;
                        break;
                    case "storage_ship_l_container_01_macro":
                    case "storage_ship_l_container_02_macro":
                    case "storage_ship_m_container_01_macro":
                    case "storage_ship_xl_container_01_macro":
                        ContainerCargo = cargoType;
                        break;
                    case "storage_ship_l_energy_01_macro":
                    case "storage_ship_l_energy_02_macro":
                    case "storage_ship_xl_energy_01_macro":
                    case "storage_ship_m_energy_01_macro":
                        EnergyCargo = cargoType;
                        break;
                    case "storage_ship_l_fuel_01_macro":
                    case "storage_ship_xl_fuel_01_macro":
                        FuelCargo = cargoType;
                        break;
                    case "storage_ship_l_liquid_01_macro":
                    case "storage_ship_l_liquid_02_macro":
                    case "storage_ship_l_liquid_03_macro":
                    case "storage_ship_xl_liquid_01_macro":
                    case "storage_ship_m_liquid_01_macro":
                        LiquidCargo = cargoType;
                        break;
                    case "storage_ship_xl_universal_01_macro":
                    case "storage_ship_xs_universal_01_macro":
                    case "storage_temp_huge_macro":
                        UniversalCargo = cargoType;
                        break;
                }
            }

            Gravidar = this.Data.Element("gravidar");

            LoadDetails();
        }