Beispiel #1
0
        /// <Summary>
        /// Save the the design when the OK button is pressed
        /// </Summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param>
        private void OK_Click(object sender, System.EventArgs e)
        {
            ShipDesign newDesign      = new ShipDesign(clientState.EmpireState.GetNextDesignKey());
            Hull       hullProperties = selectedHull.Properties["Hull"] as Hull;

            hullProperties.Modules = HullGrid.ActiveModules;
            newDesign.Name         = DesignName.Text;
            newDesign.Owner        = clientState.EmpireState.Id;
            newDesign.Blueprint    = selectedHull;
            newDesign.Icon         = shipIcon;
            newDesign.Update();

            if (hullProperties.IsStarbase)
            {
                newDesign.Type = ItemType.Starbase;
            }
            else
            {
                newDesign.Type = ItemType.Ship;
                if (newDesign.Engine == null)
                {
                    Report.Error("A ship design must have an engine");
                    return;
                }
            }
            DesignCommand command = new DesignCommand(CommandMode.Add, newDesign);

            if (command.IsValid(clientState.EmpireState))
            {
                clientState.Commands.Push(command);
                command.ApplyToState(clientState.EmpireState);
            }
            Close();
        }
Beispiel #2
0
        /// <Summary>
        /// Display Design
        /// </Summary>
        /// <param name="design">The <see cref="ShipDesign"/> to display.</param>
        private void DisplayDesign(ShipDesign design)
        {
            design.Update();
            Hull hullProperties = design.Hull;

            this.hullGrid.ActiveModules = hullProperties.Modules;
            this.hullImage.Image        = design.Blueprint.ComponentImage;
            this.designResources.Value  = design.Cost;
            this.designName.Text        = design.Name;
            this.shipMass.Text          = design.Mass.ToString(System.Globalization.CultureInfo.InvariantCulture);
            this.shipArmor.Text         = design.Armor.ToString(System.Globalization.CultureInfo.InvariantCulture);
            this.shipShields.Text       = design.Shield.ToString(System.Globalization.CultureInfo.InvariantCulture);
            this.cargoCapacity.Text     = design.CargoCapacity.ToString(System.Globalization.CultureInfo.InvariantCulture);

            if (design.Type == ItemType.Starbase)
            {
                this.capacityType.Text  = "Dock Capacity";
                this.capacityUnits.Text = "kT";
                this.maxCapacity.Text   = design.DockCapacity.ToString(System.Globalization.CultureInfo.InvariantCulture);
            }
            else
            {
                this.capacityType.Text  = "Fuel Capacity";
                this.capacityUnits.Text = "mg";
                this.maxCapacity.Text   = design.FuelCapacity.ToString(System.Globalization.CultureInfo.InvariantCulture);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initialize some starting designs.
        /// </summary>
        /// <param name="race">The <see cref="Race"/> of the player being initialized.</param>
        /// <param name="player">The player being initialized.</param>
        private void PrepareDesigns(EmpireData empire, string player)
        {
            // Read components data and create some basic stuff
            AllComponents components = new AllComponents();

            Component colonyShipHull = null, scoutHull = null;
            Component colonizer = null;
            Component scaner    = components.Fetch("Bat Scanner");
            Component armor     = components.Fetch("Tritanium");
            Component shield    = components.Fetch("Mole-skin Shield");
            Component laser     = components.Fetch("Laser");
            Component torpedo   = components.Fetch("Alpha Torpedo");

            Component starbaseHull     = components.Fetch("Space Station");
            Component engine           = components.Fetch("Quick Jump 5");
            Component colonyShipEngine = null;

            if (empire.Race.Traits.Primary.Code != "HE")
            {
                colonyShipHull = components.Fetch("Colony Ship");
            }
            else
            {
                colonyShipEngine = components.Fetch("Settler's Delight");
                colonyShipHull   = components.Fetch("Mini-Colony Ship");
            }

            scoutHull = components.Fetch("Scout");

            if (empire.Race.HasTrait("AR") == true)
            {
                colonizer = components.Fetch("Orbital Construction Module");
            }
            else
            {
                colonizer = components.Fetch("Colonization Module");
            }


            if (colonyShipEngine == null)
            {
                colonyShipEngine = engine;
            }

            ShipDesign cs = new ShipDesign(empire.GetNextDesignKey());

            cs.Blueprint = colonyShipHull;
            foreach (HullModule module in cs.Hull.Modules)
            {
                if (module.ComponentType == "Engine")
                {
                    module.AllocatedComponent = colonyShipEngine;
                    module.ComponentCount     = 1;
                }
                else if (module.ComponentType == "Mechanical")
                {
                    module.AllocatedComponent = colonizer;
                    module.ComponentCount     = 1;
                }
            }
            cs.Icon = new ShipIcon(colonyShipHull.ImageFile, (Bitmap)colonyShipHull.ComponentImage);

            cs.Type = ItemType.Ship;
            cs.Name = "Santa Maria";
            cs.Update();

            ShipDesign scout = new ShipDesign(empire.GetNextDesignKey());

            scout.Blueprint = scoutHull;
            foreach (HullModule module in scout.Hull.Modules)
            {
                if (module.ComponentType == "Engine")
                {
                    module.AllocatedComponent = engine;
                    module.ComponentCount     = 1;
                }
                else if (module.ComponentType == "Scanner")
                {
                    module.AllocatedComponent = scaner;
                    module.ComponentCount     = 1;
                }
            }
            scout.Icon = new ShipIcon(scoutHull.ImageFile, (Bitmap)scoutHull.ComponentImage);

            scout.Type = ItemType.Ship;
            scout.Name = "Scout";
            scout.Update();

            ShipDesign starbase = new ShipDesign(empire.GetNextDesignKey());

            starbase.Name      = "Starbase";
            starbase.Blueprint = starbaseHull;
            starbase.Type      = ItemType.Starbase;
            starbase.Icon      = new ShipIcon(starbaseHull.ImageFile, (Bitmap)starbaseHull.ComponentImage);
            bool weaponSwitcher = false; // start with laser
            bool armorSwitcher  = false; // start with armor

            foreach (HullModule module in starbase.Hull.Modules)
            {
                if (module.ComponentType == "Weapon")
                {
                    if (weaponSwitcher == false)
                    {
                        module.AllocatedComponent = laser;
                    }
                    else
                    {
                        module.AllocatedComponent = torpedo;
                    }
                    weaponSwitcher        = !weaponSwitcher;
                    module.ComponentCount = 8;
                }
                if (module.ComponentType == "Shield")
                {
                    module.AllocatedComponent = shield;
                    module.ComponentCount     = 8;
                }
                if (module.ComponentType == "Shield or Armor")
                {
                    if (armorSwitcher == false)
                    {
                        module.AllocatedComponent = armor;
                    }
                    else
                    {
                        module.AllocatedComponent = shield;
                    }
                    module.ComponentCount = 8;
                    armorSwitcher         = !armorSwitcher;
                }
            }

            starbase.Update();

            empire.Designs[starbase.Key] = starbase;
            empire.Designs[cs.Key]       = cs;
            empire.Designs[scout.Key]    = scout;

            /*
             * switch (race.Traits.Primary.Code)
             * {
             *  case "HE":
             *      // Start with one armed scout + 3 mini-colony ships
             *  case "SS":
             *      // Start with one scout + one colony ship.
             *  case "WM":
             *      // Start with one armed scout + one colony ship.
             *      break;
             *
             *  case "CA":
             *      // Start with an orbital terraforming ship
             *      break;
             *
             *  case "IS":
             *      // Start with one scout and one colony ship
             *      break;
             *
             *  case "SD":
             *      // Start with one scout, one colony ship, Two mine layers (one standard, one speed trap)
             *      break;
             *
             *  case "PP":
             *      empireData.ResearchLevel[TechLevel.ResearchField.Energy] = 4;
             *      // Two shielded scouts, one colony ship, two starting planets in a non-tiny universe
             *      break;
             *
             *  case "IT":
             *      empireData.ResearchLevel[TechLevel.ResearchField.Propulsion] = 5;
             *      empireData.ResearchLevel[TechLevel.ResearchField.Construction] = 5;
             *      // one scout, one colony ship, one destroyer, one privateer, 2 planets with 100/250 stargates (in non-tiny universe)
             *      break;
             *
             *  case "AR":
             *      empireData.ResearchLevel[TechLevel.ResearchField.Energy] = 1;
             *
             *      // starts with one scout, one orbital construction colony ship
             *      break;
             *
             *  case "JOAT":
             *      // two scouts, one colony ship, one medium freighter, one mini miner, one destroyer
             *      break;
             */
        }