Example #1
0
 /// <summary>
 /// Adds a missile to the series
 /// </summary>
 /// <param name="Missile">missile to be added.</param>
 public void AddMissileToSeries(OrdnanceDefTN Missile)
 {
     MissilesInSeries.Add(Missile);
 }
Example #2
0
        public void CollierOrdersTest()
        {
            Faction PlayerFaction1 = new Faction(0);

            StarSystem System1 = SystemGen.CreateSol();

            SystemBody pl1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            SystemBody pl2 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            System1.Stars[0].Planets.Add(pl1);
            System1.Stars[0].Planets.Add(pl2);

            System1.Stars[0].Planets[0].Position.X = 1.0;
            System1.Stars[0].Planets[0].Position.Y = 1.0;

            System1.Stars[0].Planets[1].Position.X = 2.0;
            System1.Stars[0].Planets[1].Position.Y = 2.0;


            PlayerFaction1.AddNewShipDesign("Blucher");

            MissileEngineDefTN TestMissileEngine = new MissileEngineDefTN("Testbed", 5.0f, 1.0f, 1.0f, 1.0f);
            OrdnanceSeriesTN Series = new OrdnanceSeriesTN("BLANK STANDIN");
            OrdnanceDefTN TestMissile = new OrdnanceDefTN("Test Missile", Series, 1.0f, 0, 1.0f, 1.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 1, 0, 0.0f, 0.0f, 0, false, 0, false, 0, TestMissileEngine, 1);

            PlayerFaction1.ShipDesigns[0].AddEngine(PlayerFaction1.ComponentList.Engines[0], 1);
            PlayerFaction1.ShipDesigns[0].AddCrewQuarters(PlayerFaction1.ComponentList.CrewQuarters[0], 2);
            PlayerFaction1.ShipDesigns[0].AddFuelStorage(PlayerFaction1.ComponentList.FuelStorage[0], 2);
            PlayerFaction1.ShipDesigns[0].AddEngineeringSpaces(PlayerFaction1.ComponentList.EngineeringSpaces[0], 2);
            PlayerFaction1.ShipDesigns[0].AddOtherComponent(PlayerFaction1.ComponentList.OtherComponents[0], 1);
            PlayerFaction1.ShipDesigns[0].AddMagazine(PlayerFaction1.ComponentList.MagazineDef[0], 1);

            PlayerFaction1.ShipDesigns[0].SetPreferredOrdnance(TestMissile, 3);

            PlayerFaction1.AddNewTaskGroup("P1 TG 01", System1.Stars[0].Planets[0], System1);

            PlayerFaction1.TaskGroups[0].AddShip(PlayerFaction1.ShipDesigns[0], "Test Ship");

            PlayerFaction1.TaskGroups[0].Ships[0].Refuel(200000.0f);

            Population P1 = new Population(System1.Stars[0].Planets[0], PlayerFaction1,0);
            Population P2 = new Population(System1.Stars[0].Planets[1], PlayerFaction1,0);

            System1.Stars[0].Planets[0].Populations[0].LoadMissileToStockpile(TestMissile, 4);


            Order Load = new Order(Constants.ShipTN.OrderType.LoadOrdnanceFromColony, -1, -1, 0, System1.Stars[0].Planets[0].Populations[0]);
            Order Unload = new Order(Constants.ShipTN.OrderType.UnloadOrdnanceToColony, -1, -1, 0, System1.Stars[0].Planets[1].Populations[0]);

            PlayerFaction1.TaskGroups[0].IssueOrder(Load);
            PlayerFaction1.TaskGroups[0].IssueOrder(Unload);

            bool CK = System1.Stars[0].Planets[1].Populations[0].MissileStockpile.ContainsKey(TestMissile);
            Console.WriteLine("Missiles on P1 and P2:{0} {1}", System1.Stars[0].Planets[0].Populations[0].MissileStockpile[TestMissile],
                CK);


            while (PlayerFaction1.TaskGroups[0].TaskGroupOrders.Count > 0)
            {
                Console.WriteLine("Current Order Time: {0} {1}", PlayerFaction1.TaskGroups[0].TimeRequirement,
    PlayerFaction1.TaskGroups[0].TaskGroupOrders[0].orderTimeRequirement);

                PlayerFaction1.TaskGroups[0].FollowOrders(Constants.TimeInSeconds.TwentyMinutes);

                Console.WriteLine("Order Count: {0}", PlayerFaction1.TaskGroups[0].TaskGroupOrders.Count);
            }

            bool CK1 = System1.Stars[0].Planets[0].Populations[0].MissileStockpile.ContainsKey(TestMissile);
            bool CK2 = System1.Stars[0].Planets[1].Populations[0].MissileStockpile.ContainsKey(TestMissile);
            Console.WriteLine("Missiles on P1 and P2:{0} {1}", CK1,
                            CK2);

            if (CK1 == true)
            {
                Console.WriteLine("P1 Missiles {0}", System1.Stars[0].Planets[0].Populations[0].MissileStockpile[TestMissile]);
            }

            if (CK2 == true)
            {
                Console.WriteLine("P2 Missiles {0}", System1.Stars[0].Planets[1].Populations[0].MissileStockpile[TestMissile]);
            }

            CK = PlayerFaction1.TaskGroups[0].Ships[0].ShipOrdnance.ContainsKey(TestMissile);
            Console.WriteLine("Missile count on Ships[0] after unload :{0}", CK);
        }
Example #3
0
        public void OrdnanceTest()
        {
            /// <summary>
            /// Need to hook missiles into the distance table calculations, as well as sensor model.
            /// </summary>


            /// <summary>
            ///The Damage table MUST be initialized.
            /// </summary>
            DamageValuesTN.init();

            /// <summary>
            /// Factions ARE necessary.
            /// </summary>
            Faction PlayerFaction1 = new Faction(0);
            Faction PlayerFaction2 = new Faction(1);

            /// <summary>
            /// No StarSystem no contacts!
            /// </summary>
            StarSystem System1 = new StarSystem("This is not Sol", 0);
            System1.Populations = new BindingList<Population>();
            Star S1 = new Star();
            System1.Stars.Add(S1);

            PlayerFaction1.AddNewContactList(System1);
            PlayerFaction2.AddNewContactList(System1);

            /// <summary>
            /// No global RNG, no Damage or tohit.
            /// </summary>
            Random RNG = new Random();

            /// <summary>
            /// Planets and populations are needed for house keeping.
            /// </summary>
            SystemBody pl1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            SystemBody pl2 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            pl1.Position.System = System1;
            pl2.Position.System = System1;
            System1.Stars[0].Planets.Add(pl1);
            System1.Stars[0].Planets.Add(pl2);

            Population P1 = new Population(System1.Stars[0].Planets[0], PlayerFaction1,0);
            Population P2 = new Population(System1.Stars[0].Planets[1], PlayerFaction2,0);

            System1.Stars[0].Planets[0].Position.X = 1.0;
            System1.Stars[0].Planets[0].Position.Y = 1.0;

            System1.Stars[0].Planets[1].Position.X = 1.04;
            System1.Stars[0].Planets[1].Position.Y = 1.04;


            PlayerFaction1.AddNewShipDesign("Blucher");
            PlayerFaction2.AddNewShipDesign("Tribal");

            MissileEngineDefTN TestMissileEngine = new MissileEngineDefTN("Testbed", 5.0f, 4.0f, 1.0f, 1.0f);

            OrdnanceSeriesTN Series = new OrdnanceSeriesTN("BLANK STANDIN");
            OrdnanceDefTN TestMissile = new OrdnanceDefTN("Test Missile", Series, 1.0f, 0, 1.0f, 1.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 1, 0, 0.0f, 0.0f, 0, false, 0, false, 0, TestMissileEngine, 1);

            ActiveSensorDefTN Spotter = new ActiveSensorDefTN("Spotter", 6.0f, 12, 6, 19, false, 1.0f, 0);
            ActiveSensorDefTN FControl = new ActiveSensorDefTN("FCtrl", 6.0f, 12, 6, 19, true, 1.0f, 0);

            PlayerFaction1.ShipDesigns[0].AddEngine(PlayerFaction1.ComponentList.Engines[0], 1);
            PlayerFaction1.ShipDesigns[0].AddCrewQuarters(PlayerFaction1.ComponentList.CrewQuarters[0], 2);
            PlayerFaction1.ShipDesigns[0].AddFuelStorage(PlayerFaction1.ComponentList.FuelStorage[0], 2);
            PlayerFaction1.ShipDesigns[0].AddEngineeringSpaces(PlayerFaction1.ComponentList.EngineeringSpaces[0], 2);
            PlayerFaction1.ShipDesigns[0].AddOtherComponent(PlayerFaction1.ComponentList.OtherComponents[0], 1);
            PlayerFaction1.ShipDesigns[0].AddMagazine(PlayerFaction1.ComponentList.MagazineDef[0], 1);
            PlayerFaction1.ShipDesigns[0].AddLauncher(PlayerFaction1.ComponentList.MLauncherDef[0], 1);
            PlayerFaction1.ShipDesigns[0].AddMFC(FControl, 1);
            PlayerFaction1.ShipDesigns[0].AddActiveSensor(Spotter, 1);

            PlayerFaction2.ShipDesigns[0].AddEngine(PlayerFaction1.ComponentList.Engines[0], 1);
            PlayerFaction2.ShipDesigns[0].AddCrewQuarters(PlayerFaction1.ComponentList.CrewQuarters[0], 2);
            PlayerFaction2.ShipDesigns[0].AddFuelStorage(PlayerFaction1.ComponentList.FuelStorage[0], 2);
            PlayerFaction2.ShipDesigns[0].AddEngineeringSpaces(PlayerFaction1.ComponentList.EngineeringSpaces[0], 2);
            PlayerFaction2.ShipDesigns[0].AddOtherComponent(PlayerFaction1.ComponentList.OtherComponents[0], 1);
            PlayerFaction2.ShipDesigns[0].NewArmor("Duranium", 5, 4);

            PlayerFaction1.ShipDesigns[0].SetPreferredOrdnance(TestMissile, 3);

            PlayerFaction1.AddNewTaskGroup("P1 TG 01", System1.Stars[0].Planets[0], System1);
            PlayerFaction2.AddNewTaskGroup("P2 TG 01", System1.Stars[0].Planets[1], System1);


            PlayerFaction1.TaskGroups[0].AddShip(PlayerFaction1.ShipDesigns[0], "Test Ship 1");
            PlayerFaction2.TaskGroups[0].AddShip(PlayerFaction2.ShipDesigns[0], "Test Ship 2");


            PlayerFaction1.TaskGroups[0].Ships[0].Refuel(200000.0f);
            PlayerFaction2.TaskGroups[0].Ships[0].Refuel(200000.0f);

            System1.Stars[0].Planets[0].Populations[0].LoadMissileToStockpile(TestMissile, 4);

            Order Load = new Order(Constants.ShipTN.OrderType.LoadOrdnanceFromColony, -1, -1, 0, System1.Stars[0].Planets[0].Populations[0]);

            PlayerFaction1.TaskGroups[0].IssueOrder(Load);

            while (PlayerFaction1.TaskGroups[0].TaskGroupOrders.Count > 0)
            {
                PlayerFaction1.TaskGroups[0].FollowOrders(Constants.TimeInSeconds.TwentyMinutes);
            }

            /// <summary>
            /// Magazine loading isn't handled anywhere.
            /// </summary>
            PlayerFaction1.TaskGroups[0].Ships[0].ShipMLaunchers[0].loadedOrdnance = TestMissile;

            PlayerFaction1.TaskGroups[0].Ships[0].ShipMLaunchers[0].AssignMFC(PlayerFaction1.TaskGroups[0].Ships[0].ShipMFC[0]);
            PlayerFaction1.TaskGroups[0].Ships[0].ShipMFC[0].assignLaunchTube(PlayerFaction1.TaskGroups[0].Ships[0].ShipMLaunchers[0]);

            PlayerFaction1.TaskGroups[0].Ships[0].ShipMFC[0].assignTarget(PlayerFaction2.TaskGroups[0].Ships[0]);
            PlayerFaction1.TaskGroups[0].Ships[0].ShipMFC[0].openFire = true;
            PlayerFaction1.TaskGroups[0].SetActiveSensor(0, 0, true);


            GameState.Instance.CurrentSecond += 10;
            GameState.Instance.LastTimestep = 10;

            PlayerFaction1.SensorSweep();



            bool ret = PlayerFaction1.TaskGroups[0].Ships[0].ShipFireWeapons(RNG);


            Console.WriteLine("Did we fire: {0} Detected Contacts:{1}", ret, PlayerFaction1.DetectedContactLists.Count);


            bool done = false;
            while (!done)
            {
                Console.WriteLine("TimeStep:{0} {1} Detected Contacts:{2}", GameState.Instance.CurrentSecond, GameState.Instance.LastTimestep, PlayerFaction1.DetectedContactLists.Count);

                PlayerFaction1.SensorSweep();

                PlayerFaction1.MissileGroups[0].ProcessOrder((uint)GameState.Instance.LastTimestep, RNG);

                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7}", PlayerFaction1.MissileGroups[0].currentHeading, PlayerFaction1.MissileGroups[0].currentSpeedX,
                    PlayerFaction1.MissileGroups[0].currentSpeedY, PlayerFaction1.MissileGroups[0].timeReq, PlayerFaction1.MissileGroups[0].dx, PlayerFaction1.MissileGroups[0].dy,
                    PlayerFaction1.MissileGroups[0].missiles.Count, PlayerFaction1.MissileGroups[0].missilesDestroyed);

                GameState.Instance.CurrentSecond += 5;
                GameState.Instance.LastTimestep = 5;






                if (PlayerFaction1.MissileGroups[0].missiles.Count == PlayerFaction1.MissileGroups[0].missilesDestroyed)
                {
                    PlayerFaction1.MissileGroups.Clear();
                    done = true;
                }
            }


            Console.WriteLine("Armor:");
            for (int loop = 0; loop < PlayerFaction2.TaskGroups[0].Ships[0].ShipArmor.armorColumns.Count; loop++)
            {
                Console.WriteLine("{0} ", PlayerFaction2.TaskGroups[0].Ships[0].ShipArmor.armorColumns[loop]);
            }

        }
Example #4
0
        /// <summary>
        /// Set preferred ordnance adds or subtracts missiles from the preferred ordnance list of this class.
        /// </summary>
        /// <param name="missile">Missile to be added or subtracted.</param>
        /// <param name="inc">Amount to add/remove.</param>
        public void SetPreferredOrdnance(OrdnanceDefTN missile, int inc)
        {
            /// <summary>
            /// Handle the condition of no magazines for PDC silos or ships with all box launchers.
            /// </summary
            if (ShipMagazineDef.Count == 0 && inc > 0)
            {
                /// <summary>
                /// Is this missile smaller than or equal to the size of the largest launcher?
                /// </summary>
                if (Math.Ceiling(missile.size) <= LargestLauncher)
                {
                    /// <summary>
                    /// Do we want to add more missiles than we have launchers for?
                    /// </summary>
                    if (PreferredOrdnanceCount + inc > LauncherCount)
                    {
                        /// <summary>
                        /// Change increment to the remainder of LauncherCount minus PreferredOrdnanceCount
                        /// </summary>
                        inc = LauncherCount - PreferredOrdnanceCount;
                    }
                }
            }


            int MissileSizeInMagazine = (int)Math.Ceiling(missile.size);
            int loadSize = MissileSizeInMagazine * inc;

            int loadAmt = 0;

            if (inc > 0)
            {
                if (PreferredOrdnanceSize + loadSize <= TotalMagazineCapacity)
                {
                    loadAmt = inc;
                }
                else
                {
                    if (PreferredOrdnanceSize == TotalMagazineCapacity)
                    {
                        return;
                    }
                    else
                    {
                        int capRemaining = TotalMagazineCapacity - PreferredOrdnanceSize;
                        loadAmt = (int)Math.Floor(((float)capRemaining / (float)MissileSizeInMagazine));

                        loadSize = loadAmt * MissileSizeInMagazine;
                    }
                }

                if (ShipClassOrdnance.ContainsKey(missile))
                {
                    ShipClassOrdnance[missile] = ShipClassOrdnance[missile] + loadAmt;
                    PreferredOrdnanceSize = PreferredOrdnanceSize + loadSize;

                    PreferredOrdnanceCost = PreferredOrdnanceCost + (loadAmt * missile.cost);

                    PreferredOrdnanceCount = PreferredOrdnanceCount + loadAmt;
                }
                else
                {
                    ShipClassOrdnance.Add(missile, loadAmt);
                    PreferredOrdnanceSize = PreferredOrdnanceSize + loadSize;

                    PreferredOrdnanceCost = PreferredOrdnanceCost + (loadAmt * missile.cost);

                    PreferredOrdnanceCount = PreferredOrdnanceCount + loadAmt;
                }
            }
            else
            {
                if (ShipClassOrdnance.ContainsKey(missile) == false)
                {
                    return;
                }
                else
                {
                    /// <summary>
                    /// Have to remember that inc is negative here.
                    /// </summary>

                    if ((inc * -1) < ShipClassOrdnance[missile])
                    {
                        loadAmt = inc;

                        ShipClassOrdnance[missile] = ShipClassOrdnance[missile] + inc;
                        PreferredOrdnanceSize = PreferredOrdnanceSize + loadSize;
                        PreferredOrdnanceCost = PreferredOrdnanceCost + (loadAmt * missile.cost);
                        PreferredOrdnanceCount = PreferredOrdnanceCount + loadAmt;
                    }
                    else
                    {
                        loadAmt = ShipClassOrdnance[missile] * -1;
                        loadSize = loadAmt * MissileSizeInMagazine;

                        PreferredOrdnanceSize = PreferredOrdnanceSize + loadSize;
                        PreferredOrdnanceCost = PreferredOrdnanceCost + (loadAmt * missile.cost);
                        PreferredOrdnanceCount = PreferredOrdnanceCount + loadAmt;
                        ShipClassOrdnance[missile] = 0;
                        ShipClassOrdnance.Remove(missile);
                    }
                }
            }
        }
Example #5
0
        /// <summary>
        /// Every faction will start with some components defined and ready to use, though the engines and sensors shouldn't be here just yet.
        /// </summary>
        public void AddInitialComponents()
        {
            /// <summary>
            /// Watch total component count when adding or subtracting from this function
            /// </summary>
            TotalComponents = 0;

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN CrewQS = new GeneralComponentDefTN("Crew Quarters - Small", 0.2f, 0, 2.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN FuelTS = new GeneralComponentDefTN("Fuel Storage - Small", 0.2f, 0, 3.0m, ComponentTypeTN.Fuel);
            GeneralComponentDefTN EBay = new GeneralComponentDefTN("Engineering Spaces", 1.0f, 5, 10.0m, ComponentTypeTN.Engineering);
            GeneralComponentDefTN Bridge = new GeneralComponentDefTN("Bridge", 1.0f, 5, 10.0m, ComponentTypeTN.Bridge);
            TotalComponents = TotalComponents + 6;

            CrewQuarters.Add(CrewQ);
            CrewQuarters.Add(CrewQS);
            FuelStorage.Add(FuelT);
            FuelStorage.Add(FuelTS);
            EngineeringSpaces.Add(EBay);
            OtherComponents.Add(Bridge);

            /// <summary>
            /// These components aren't really basic, but I'll put them in anyway for the time being. Count 6 to 17
            /// </summary>
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5.0f, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);
            ActiveSensorDefTN ActDef = new ActiveSensorDefTN("Search 5M - 5000", 1.0f, 10, 5, 100, false, 1.0f, 1);
            PassiveSensorDefTN ThPasDef = new PassiveSensorDefTN("Thermal Sensor TH1-5", 1.0f, 5, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN EMPasDef = new PassiveSensorDefTN("EM Sensor EM1-5", 1.0f, 5, PassiveSensorType.EM, 1.0f, 1);
            BeamFireControlDefTN BFCDef = new BeamFireControlDefTN("Fire Control S01 10-1250", 0, 0, 1.0f, 1.0f, false, false, 1.0f, 1);
            BeamDefTN BeamDef = new BeamDefTN("10cm C1 Infrared Laser", ComponentTypeTN.Laser, 0, 0, 0, 1.0f);
            ReactorDefTN ReactDef = new ReactorDefTN("PWR S1 P2", 0, 1.0f, 1.0f);
            ShieldDefTN AShieldDef = new ShieldDefTN("Alpha R300/240 Shields", 0, 0, 1.0f, 1.0f, ComponentTypeTN.Shield);
            MissileLauncherDefTN TubeDef = new MissileLauncherDefTN("Size 1 Launcher", 1.0f, 1, false, 0);
            MagazineDefTN MagDef = new MagazineDefTN("Mag S1", 1.0f, 1, 0, 0, 1);
            ActiveSensorDefTN MFCDef = new ActiveSensorDefTN("Wasp I FC", 1.0f, 10, 5, 100, true, 1.0f, 1);
            TotalComponents = TotalComponents + 11;


            Engines.Add(EngDef);
            ActiveSensorDef.Add(ActDef);
            PassiveSensorDef.Add(ThPasDef);
            PassiveSensorDef.Add(EMPasDef);

            BeamFireControlDef.Add(BFCDef);
            BeamWeaponDef.Add(BeamDef);
            ReactorDef.Add(ReactDef);

            ShieldDef.Add(AShieldDef);

            MLauncherDef.Add(TubeDef);
            MagazineDef.Add(MagDef);
            MissileFireControlDef.Add(MFCDef);

            TurretableBeamDef.Add(BeamDef);


            /// <summary>
            /// Everyone starts with cargoholds. Count 17 to 19
            /// </summary>
            CargoDefTN CargoStandard = new CargoDefTN("Cargo Hold - Standard", 500.0f, 50.0m, 5);
            CargoDefTN CargoSmall = new CargoDefTN("Cargo Hold - Small", 100.0f, 12.5m, 2);
            TotalComponents = TotalComponents + 2;

            CargoHoldDef.Add(CargoStandard);
            CargoHoldDef.Add(CargoSmall);

            /// <summary>
            /// Cryostorage is a TN only starting option. otherwise it must be researched. Count, 19 to 22
            /// </summary>
            ColonyDefTN ColonyStandard = new ColonyDefTN("Cryogenic Transport", 50.0f, 100.0m, 10);
            ColonyDefTN ColonySmall = new ColonyDefTN("Cryogenic Transport - Small", 5.0f, 20.0m, 2);
            ColonyDefTN ColonyEmergency = new ColonyDefTN("Cryogenic Transport - Emergency", 1.0f, 5.0m, 0);
            TotalComponents = TotalComponents + 3;

            ColonyBayDef.Add(ColonyStandard);
            ColonyBayDef.Add(ColonySmall);
            ColonyBayDef.Add(ColonyEmergency);


            /// <summary>
            /// Only TN starts begin with this component for now. the improved,advanced, and grav-assisted variants have to be researched. Count 22, to 23
            /// </summary>
            CargoHandlingDefTN CHS = new CargoHandlingDefTN("Cargo Handling System", 5, 10.0m);
            CargoHandleSystemDef.Add(CHS);
            TotalComponents = TotalComponents + 1;

            /// <summary>
            /// Alpha build components: Count 23, to 39
            /// </summary>

            EngineDefTN AlphaEngine = new EngineDefTN("Ion Engine 120", 12.0f, 1.0f, 0.7f, 1.0f, 1, 10.0f, -1.0f);
            ActiveSensorDefTN AlphaBigSensor = new ActiveSensorDefTN("Search 181M - 10000", 10.0f, 16, 8, 200, false, 1.0f, 1);
            ActiveSensorDefTN AlphaSmallSensor = new ActiveSensorDefTN("Search 57M - 1000", 10.0f, 16, 8, 20, false, 1.0f, 1);
            ActiveSensorDefTN AlphaMissileSensor = new ActiveSensorDefTN("Search 1.4M - Missile", 10.0f, 16, 8, 1, false, 1.0f, 1);
            PassiveSensorDefTN AlphaEMSensor = new PassiveSensorDefTN("EM Detection Sensor EM10-80", 10.0f, 8, PassiveSensorType.EM, 1.0f, 1);
            PassiveSensorDefTN AlphaTHSensor = new PassiveSensorDefTN("TH Detection Sensor TH10-80", 10.0f, 8, PassiveSensorType.Thermal, 1.0f, 1);
            BeamFireControlDefTN AlphaFireControl = new BeamFireControlDefTN("Primary III FC R96K T6K", 2, 2, 4.0f, 2.0f, false, false, 1.0f, 1);

            BeamDefTN AlphaRailGun = new BeamDefTN("15cm Railgun V3/C3", ComponentTypeTN.Rail, 2, 2, 2, 1.0f);
            BeamDefTN AlphaLaser = new BeamDefTN("15cm C3 Near UV Laser", ComponentTypeTN.Laser, 2, 2, 2, 1.0f);
            BeamDefTN AlphaParticle = new BeamDefTN("PBW-4 150K", ComponentTypeTN.Particle, 2, 2, 2, 1.0f);
            BeamDefTN AlphaPlasma = new BeamDefTN("15cm C3 Plasma Beam", ComponentTypeTN.Plasma, 2, 2, 2, 1.0f);
            BeamDefTN AlphaMeson = new BeamDefTN("R9/C3 Meson Cannon", ComponentTypeTN.Meson, 2, 2, 2, 1.0f);
            BeamDefTN AlphaHPM = new BeamDefTN("R9/C3 Microwave", ComponentTypeTN.Microwave, 2, 2, 2, 1.0f);
            BeamDefTN AlphaGauss = new BeamDefTN("Gauss R3-100", ComponentTypeTN.Gauss, 0, 2, 2, 1.0f);

            ReactorDefTN AlphaReactor = new ReactorDefTN("GCFR S1 P4.5", 2, 1.0f, 1.0f);

            ShieldDefTN AlphaShield = new ShieldDefTN("Gamma R300/336 Shields", 2, 2, 0.7f, 1.0f, ComponentTypeTN.Shield);
            TotalComponents = TotalComponents + 16;

            Engines.Add(AlphaEngine);

            ActiveSensorDef.Add(AlphaBigSensor);
            ActiveSensorDef.Add(AlphaSmallSensor);
            ActiveSensorDef.Add(AlphaMissileSensor);

            PassiveSensorDef.Add(AlphaEMSensor);
            PassiveSensorDef.Add(AlphaTHSensor);

            BeamFireControlDef.Add(AlphaFireControl);

            BeamWeaponDef.Add(AlphaRailGun);
            BeamWeaponDef.Add(AlphaLaser);
            BeamWeaponDef.Add(AlphaParticle);
            BeamWeaponDef.Add(AlphaPlasma);
            BeamWeaponDef.Add(AlphaMeson);
            BeamWeaponDef.Add(AlphaHPM);
            BeamWeaponDef.Add(AlphaGauss);

            ReactorDef.Add(AlphaReactor);

            ShieldDef.Add(AlphaShield);

            TurretableBeamDef.Add(AlphaLaser);
            TurretableBeamDef.Add(AlphaMeson);
            TurretableBeamDef.Add(AlphaGauss);

            /// <summary>
            /// Missile Combat Alpha Components: Count at 44 from 39 OrdnanceDefTN and MissileEngineDefTN are _NOT_ included in the total count.
            /// </summary>
            EngineDefTN AlphaMCEngine = new EngineDefTN("Military 5000 EP Photonic Drive", 100.0f, 1.0f, 0.1f, 1.0f, 1, 50.0f, -1.0f);
            ActiveSensorDefTN AlphaMCSensor = new ActiveSensorDefTN("Active Search Sensor MR13500-R100", 10.0f, 180, 75, 100, false, 1.0f, 0);
            ActiveSensorDefTN AlphaMCMissileFireControl = new ActiveSensorDefTN("Missile Fire Control FC40500-R100", 10.0f, 180, 75, 100, true, 1.0f, 0);
            MagazineDefTN MagazineMCDef = new MagazineDefTN("Capacity 587 Magazine: Exp 1%  HTK4", 30.0f, 4, 8, 8, 12);
            MissileLauncherDefTN TubeMCDef = new MissileLauncherDefTN("Size 4 Launcher", 4.0f, 11, false, 0);
            MissileEngineDefTN MissileEngineMCDef = new MissileEngineDefTN("Photonic Missile Drive", 100.0f, 1.0f, 0.1f, 1.5f);
            OrdnanceDefTN MissileMCDef = new OrdnanceDefTN("Size 4 Missile", null, 0.5f, 11, 1.0f, 1.0f, 11, 0.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 100, 0, 0.0f, 0.0f, 0, false, 0, false, 0,
                                                           MissileEngineMCDef, 1);
            TotalComponents = TotalComponents + 5;

            Engines.Add(AlphaMCEngine);
            ActiveSensorDef.Add(AlphaMCSensor);
            MissileFireControlDef.Add(AlphaMCMissileFireControl);
            MagazineDef.Add(MagazineMCDef);
            MLauncherDef.Add(TubeMCDef);
            MissileEngineDef.Add(MissileEngineMCDef);
            MissileDef.Add(MissileMCDef);

            MissileLauncherDefTN TubeAMMDef = new MissileLauncherDefTN("Size 1 Launcher", 1.0f, 11, false, 0);
            MissileEngineDefTN MissileEngineAMMDef = new MissileEngineDefTN("Small Photonic Missile Drive", 100.0f, 6.0f, 0.1f, 0.4f);
            ActiveSensorDefTN AMMSensor = new ActiveSensorDefTN("AMM Sensor", 10.0f, 180, 75, 1, false, 1.0f, 0);
            ActiveSensorDefTN AMMMFC = new ActiveSensorDefTN("AMM MFC", 10.0f, 180, 75, 1, true, 1.0f, 0);
            OrdnanceDefTN MissileAMMDef = new OrdnanceDefTN("Size 1 Missile", null, 0.14f, 11, 0.23f, 0.23f, 11, 0.0f, 0, 0.0f, 0, 0.0f, 0, 0.0f, 0, 1, 0, 0.0f, 0.0f, 0, false, 0, false, 0,
                                                            MissileEngineAMMDef, 1);

            TotalComponents = TotalComponents + 3;

            MLauncherDef.Add(TubeAMMDef);
            MissileEngineDef.Add(MissileEngineAMMDef);
            ActiveSensorDef.Add(AMMSensor);
            MissileFireControlDef.Add(AMMMFC);
            MissileDef.Add(MissileAMMDef);



        }
        /// <summary>
        /// when the faction is changed this will be run.
        /// </summary>
        private void OnFactionChanged()
        {
            MissileSeries = _CurrnetFaction.OrdnanceSeries;

            /// <summary>
            /// The 1st missile series should always be present, and cannot be deleted. it is the "No Missile Series" Series. Ain't I a stinker?
            /// </summary.
            if (MissileSeries.Count != 0)
                CurrentMissileSeries = MissileSeries[0];

            MissileEngines = _CurrnetFaction.ComponentList.MissileEngineDef;

            if (MissileEngines.Count != 0)
                CurrentMissileEngine = MissileEngines[0];

            Missiles = _CurrnetFaction.ComponentList.MissileDef;

            if (Missiles.Count != 0)
            {
                CurrentMissile = Missiles[0];
            }

            if (FactionChanged != null)
            {
                FactionChanged(this, new EventArgs());
            }
        }
        /// <summary>
        /// Constructor for individual launchers.
        /// </summary>
        /// <param name="definition">Definition for this launcher</param>
        public MissileLauncherTN(MissileLauncherDefTN definition)
        {
            MissileLauncherDef = definition;

            LoadTime = 0;
            LoadedOrdnance = null;
            MFC = null;

            isDestroyed = false;
        }
Example #8
0
        /// <summary>
        /// Add a missile to the missile build queue.
        /// </summary>
        /// <param name="MissileDef">Missile to add</param>
        /// <param name="BuildAmt">missile build count</param>
        /// <param name="RequestedBuildPercentage">percentage of Ordnance factories to devote to construction.</param>
        public void BuildQueueAddMissile(OrdnanceDefTN MissileDef, float BuildAmt, float RequestedBuildPercentage)
        {
            MissileBuildQueueItem NewMBQItem = new MissileBuildQueueItem(MissileDef);
            NewMBQItem.UpdateBuildQueueInfo(BuildAmt, RequestedBuildPercentage, true, MissileDef.cost);

            MissileBuildQueue.Add(NewMBQItem);
        }
Example #9
0
        /// <summary>
        /// Constructor for Missile Build Queue Items
        /// </summary>
        /// <param name="Definition"></param>
        public MissileBuildQueueItem(OrdnanceDefTN Definition)
            : base()
        {
            numToBuild = 0.0f;
            buildCapacity = 0.0f;
            productionRate = 0.0f;
            costPerItem = Definition.cost;

            inProduction = false;

            m_OrdanceDef = Definition;
        }
        /// <summary>
        /// sets all fields to the value of the previous ordnance
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PreviousOrdnanceComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            String Entry;

            Entry = String.Format("{0:N4}", CurrentMissile.wMSP);

            if (Entry == "0.0000")
                Entry = "0";

            m_oMissileDesignPanel.WHMSPTextBox.Text = Entry;

            Entry = String.Format("{0:N4}", (CurrentMissile.fuel / 2500.0f));

            if (Entry == "0.0000")
                Entry = "0";

            m_oMissileDesignPanel.FuelMSPTextBox.Text = Entry;

            Entry = String.Format("{0:N4}", CurrentMissile.agMSP);

            if (Entry == "0.0000")
                Entry = "0";

            m_oMissileDesignPanel.AgilityMSPTextBox.Text = Entry;

            Entry = String.Format("{0:N4}", CurrentMissile.acMSP);

            if (Entry == "0.0000")
                Entry = "0";

            m_oMissileDesignPanel.ActiveMSPTextBox.Text = Entry;

            Entry = String.Format("{0:N4}", CurrentMissile.tMSP);

            if (Entry == "0.0000")
                Entry = "0";

            m_oMissileDesignPanel.ThermalMSPTextBox.Text = Entry;

            Entry = String.Format("{0:N4}", CurrentMissile.eMSP);

            if (Entry == "0.0000")
                Entry = "0";

            m_oMissileDesignPanel.EMMSPTextBox.Text = Entry;

            Entry = String.Format("{0:N4}", CurrentMissile.gMSP);

            if (Entry == "0.0000")
                Entry = "0";

            m_oMissileDesignPanel.GeoMSPTextBox.Text = Entry;

            if (CurrentMissile.activeStr != 0)
                m_oMissileDesignPanel.ResolutionTextBox.Text = CurrentMissile.aSD.resolution.ToString();
            else
                m_oMissileDesignPanel.ResolutionTextBox.Text = "1";

            m_oMissileDesignPanel.ArmourMSPTextBox.Text = CurrentMissile.armor.ToString();

            if (CurrentMissile.eCMValue != 0)
                m_oMissileDesignPanel.ECMMSPTextBox.Text = "1";
            else
                m_oMissileDesignPanel.ECMMSPTextBox.Text = "0";

            /// <summary>
            /// radValue is not equal to warhead if the warhead is a bomb pumped laser so handle that one first.
            /// </summary>
            if (CurrentMissile.isLaser == true)
                m_oMissileDesignPanel.LaserWCheckBox.Checked = true;
            else if (CurrentMissile.radValue != CurrentMissile.warhead)
                m_oMissileDesignPanel.ERCheckBox.Checked = true;
            else
            {
                m_oMissileDesignPanel.LaserWCheckBox.Checked = false;
                m_oMissileDesignPanel.ERCheckBox.Checked = false;
            }

            CurrentMissileSeries = CurrentMissile.ordSeries;
            int index = _CurrnetFaction.OrdnanceSeries.IndexOf(CurrentMissileSeries);
            m_oMissileDesignPanel.MSeriesComboBox.SelectedIndex = index;

            if (CurrentMissile.ordnanceEngine != null)
            {
                index = _CurrnetFaction.ComponentList.MissileEngineDef.IndexOf(CurrentMissile.ordnanceEngine);
                m_oMissileDesignPanel.MissileEngineComboBox.SelectedIndex = index;
                CurrentMissileEngine = CurrentMissile.ordnanceEngine;
            }

            m_oMissileDesignPanel.NumEnginesTextBox.Text = CurrentMissile.engineCount.ToString();

            if (CurrentMissile.subRelease != null)
            {
                index = _CurrnetFaction.ComponentList.MissileDef.IndexOf(CurrentMissile.subRelease);

                BuildSubMunitionComboBox();

                m_oMissileDesignPanel.SubMunitionComboBox.SelectedIndex = index;
                SubMunition = CurrentMissile.subRelease;
                m_oMissileDesignPanel.SubNumberTextBox.Text = CurrentMissile.subReleaseCount.ToString();
                m_oMissileDesignPanel.SepRangeTextBox.Text = CurrentMissile.subReleaseDistance.ToString();
            }
            else
            {
                m_oMissileDesignPanel.SubNumberTextBox.Text = "0";
                m_oMissileDesignPanel.SepRangeTextBox.Text = "150";
            }

            BuildMissileDesignPage();
        }
        /// <summary>
        /// On submunition selection change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SubMunitionComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = m_oMissileDesignPanel.SubMunitionComboBox.SelectedIndex;

            SubMunition = _CurrnetFaction.ComponentList.MissileDef[index];
            BuildMissileDesignPage();
        }
        /// <summary>
        /// When a new empire/faction is selected this will be run
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EmpireComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_CurrnetFaction.ComponentList.MissileEngineDef.Count != 0)
            {
                _CurrnetMissileEngine = _CurrnetFaction.ComponentList.MissileEngineDef[0];
            }
            else
            {
                m_oMissileDesignPanel.TotalEngineCostTextBox.Text = "";
                m_oMissileDesignPanel.TotalEngineSizeTextBox.Text = "";
                m_oMissileDesignPanel.TotalEPTextBox.Text = "";
                m_oMissileDesignPanel.MissileEngineComboBox.Text = "";
                _CurrnetMissileEngine = null;
            }

            if (_CurrnetFaction.OrdnanceSeries.Count != 0)
            {
                _CurrnetMissileSeries = _CurrnetFaction.OrdnanceSeries[0];
                m_oMissileDesignPanel.MSeriesComboBox.SelectedIndex = 0;
            }
            else
            {
                String Error = String.Format("Faction {0} somehow has no default missile series \"No Series Selected\".", _CurrnetFaction.Name);
                MessageEntry MessageEntry = new MessageEntry(MessageEntry.MessageType.Error, null, null,
                                                      GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Error);
                _CurrnetFaction.MessageLog.Add(MessageEntry);
                _CurrnetMissileSeries = null;
            }

            if (_CurrnetFaction.ComponentList.MissileDef.Count == 0)
            {
                m_oMissileDesignPanel.WHMSPTextBox.Text = "0";
                m_oMissileDesignPanel.FuelMSPTextBox.Text = "0";
                m_oMissileDesignPanel.AgilityMSPTextBox.Text = "0";
                m_oMissileDesignPanel.ActiveMSPTextBox.Text = "0";
                m_oMissileDesignPanel.ThermalMSPTextBox.Text = "0";
                m_oMissileDesignPanel.EMMSPTextBox.Text = "0";
                m_oMissileDesignPanel.GeoMSPTextBox.Text = "0";
                m_oMissileDesignPanel.ResolutionTextBox.Text = "1";
                m_oMissileDesignPanel.ArmourMSPTextBox.Text = "0";
                m_oMissileDesignPanel.ECMMSPTextBox.Text = "0";
                m_oMissileDesignPanel.LaserWCheckBox.Checked = false;
                m_oMissileDesignPanel.ERCheckBox.Checked = false;
                m_oMissileDesignPanel.NumEnginesTextBox.Text = "1";
                m_oMissileDesignPanel.SubNumberTextBox.Text = "0";
                m_oMissileDesignPanel.SepRangeTextBox.Text = "150";
                m_oMissileDesignPanel.SubSizeTextBox.Text = "0";
                m_oMissileDesignPanel.SubCostTextBox.Text = "0";
                m_oMissileDesignPanel.SubTotalSizeTextBox.Text = "0";
                m_oMissileDesignPanel.SubTotalCostTextBox.Text = "0";
                SubMunition = null;

                m_oMissileDesignPanel.PreviousOrdnanceComboBox.Text = "";
            }

            BuildSubMunitionComboBox();

            BuildMissileDesignPage();
        }
        /// <summary>
        /// Constructor for missile design handler.
        /// </summary>
        public MissileDesignHandler()
        {
            m_oMissileDesignPanel = new Panels.MissileDesign();
            m_oNameSeriesPanel = new Panels.ClassDes_RenameClass();


            VM = new MissileDesignViewModel();

            /// <summary>
            /// Bind factions to the empire selection combo box.
            /// </summary>
            m_oMissileDesignPanel.EmpireComboBox.Bind(c => c.DataSource, VM, d => d.Factions);
            m_oMissileDesignPanel.EmpireComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentFaction, DataSourceUpdateMode.OnPropertyChanged);
            m_oMissileDesignPanel.EmpireComboBox.DisplayMember = "Name";
            VM.FactionChanged += (s, args) => _CurrnetFaction = VM.CurrentFaction;
            _CurrnetFaction = VM.CurrentFaction;
            m_oMissileDesignPanel.EmpireComboBox.SelectedIndexChanged += (s, args) => m_oMissileDesignPanel.EmpireComboBox.DataBindings["SelectedItem"].WriteValue();
            m_oMissileDesignPanel.EmpireComboBox.SelectedIndexChanged += new EventHandler(EmpireComboBox_SelectedIndexChanged);

            /// <summary>
            /// Binding missile engines to the appropriate combo box.
            /// </summary>
            m_oMissileDesignPanel.MissileEngineComboBox.Bind(c => c.DataSource, VM, d => d.MissileEngines);
            m_oMissileDesignPanel.MissileEngineComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentMissileEngine, DataSourceUpdateMode.OnPropertyChanged);
            m_oMissileDesignPanel.MissileEngineComboBox.DisplayMember = "Name";
            VM.MissileEngineChanged += (s, args) => _CurrnetMissileEngine = VM.CurrentMissileEngine;
            _CurrnetMissileEngine = VM.CurrentMissileEngine;
            m_oMissileDesignPanel.MissileEngineComboBox.SelectedIndexChanged += (s, args) => m_oMissileDesignPanel.MissileEngineComboBox.DataBindings["SelectedItem"].WriteValue();
            m_oMissileDesignPanel.MissileEngineComboBox.SelectedIndexChanged += new EventHandler(MissileEngineComboBox_SelectedIndexChanged);

            m_oMissileDesignPanel.MSeriesComboBox.Bind(c => c.DataSource, VM, d => d.MissileSeries);
            m_oMissileDesignPanel.MSeriesComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentMissileSeries, DataSourceUpdateMode.OnPropertyChanged);
            m_oMissileDesignPanel.MSeriesComboBox.DisplayMember = "Name";
            VM.MissileSeriesChanged += (s, args) => _CurrnetMissileSeries = VM.CurrentMissileSeries;
            _CurrnetMissileSeries = VM.CurrentMissileSeries;
            m_oMissileDesignPanel.MSeriesComboBox.SelectedIndexChanged += (s, args) => m_oMissileDesignPanel.MSeriesComboBox.DataBindings["SelectedItem"].WriteValue();
            m_oMissileDesignPanel.MSeriesComboBox.SelectedIndexChanged += new EventHandler(MSeriesComboBox_SelectedIndexChanged);

            m_oMissileDesignPanel.PreviousOrdnanceComboBox.Bind(c => c.DataSource, VM, d => d.Missiles);
            m_oMissileDesignPanel.PreviousOrdnanceComboBox.Bind(c => c.SelectedItem, VM, d => d.CurrentMissile, DataSourceUpdateMode.OnPropertyChanged);
            m_oMissileDesignPanel.PreviousOrdnanceComboBox.DisplayMember = "Name";
            VM.MissileChanged += (s, args) => _CurrnetMissile = VM.CurrentMissile;
            _CurrnetMissile = VM.CurrentMissile;
            m_oMissileDesignPanel.PreviousOrdnanceComboBox.SelectedIndexChanged += (s, args) => m_oMissileDesignPanel.PreviousOrdnanceComboBox.DataBindings["SelectedItem"].WriteValue();
            m_oMissileDesignPanel.PreviousOrdnanceComboBox.SelectedIndexChanged += new EventHandler(PreviousOrdnanceComboBox_SelectedIndexChanged);

            m_oMissileDesignPanel.SubMunitionComboBox.SelectedIndexChanged += new EventHandler(SubMunitionComboBox_SelectedIndexChanged);

            m_oMissileDesignPanel.CloseMDButton.Click += new EventHandler(CloseMDButton_Click);

            m_oMissileDesignPanel.NumEnginesTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.WHMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.FuelMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.AgilityMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);

            m_oMissileDesignPanel.ActiveMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.ThermalMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.EMMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.GeoMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.ResolutionTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);

            m_oMissileDesignPanel.ArmourMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.ECMMSPTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);

            m_oMissileDesignPanel.LaserWCheckBox.CheckedChanged += new EventHandler(LWCheckBox_CheckedChanged);
            m_oMissileDesignPanel.ERCheckBox.CheckedChanged += new EventHandler(ERCheckBox_CheckedChanged);

            m_oMissileDesignPanel.CreateSeriesButton.Click += new EventHandler(CreateSeriesButton_Click);
            m_oMissileDesignPanel.DeleteSeriesButton.Click += new EventHandler(DeleteSeriesButton_Click);
            m_oMissileDesignPanel.InstantButton.Click += new EventHandler(InstantButton_Click);
            m_oMissileDesignPanel.ClearDesignButton.Click += new EventHandler(ClearDesignButton_Click);
            m_oMissileDesignPanel.SetSeriesButton.Click += new EventHandler(SetSeriesButton_Click);
            m_oMissileDesignPanel.ReplaceAllButton.Click += new EventHandler(ReplaceAllButton_Click);
            m_oMissileDesignPanel.CreateMissileButton.Click += new EventHandler(CreateMissileButton_Click);
            m_oMissileDesignPanel.ToggleInfoButton.Click += new EventHandler(ToggleInfoButton_Click);

            m_oMissileDesignPanel.SepRangeTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);
            m_oMissileDesignPanel.SubNumberTextBox.TextChanged += new EventHandler(AnyTextBox_TextChanged);


            m_oNameSeriesPanel.NewClassNameLabel.Text = "Please enter the name of the new Missile Series";
            m_oNameSeriesPanel.OKButton.Click += new EventHandler(OKButton_Click);
            m_oNameSeriesPanel.CancelRenameButton.Click += new EventHandler(CancelRenameButton_Click);
            m_oNameSeriesPanel.RenameClassTextBox.KeyPress += new KeyPressEventHandler(RenameClassTextBox_KeyPress);

            InfoToggle = false;

            m_oMissileDesignPanel.TechDataGrid.SelectionMode = DataGridViewSelectionMode.CellSelect;
            m_oMissileDesignPanel.TechDataGrid.RowHeadersVisible = false;
            m_oMissileDesignPanel.TechDataGrid.AutoGenerateColumns = false;
            SetupTechDataGrid();
        }
        /// <summary>
        /// Builds the summary textbox and name.
        /// </summary>
        private void BuildMissileSummary()
        {
            m_oMissileDesignPanel.MissileNameTextBox.Clear();
            m_oMissileDesignPanel.MissileSummaryTextBox.Clear();

            int ECMTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.MissileECM];
            if (ECMTech == -1)
                m_oMissileDesignPanel.ECMMSPTextBox.ReadOnly = true;
            else
                m_oMissileDesignPanel.ECMMSPTextBox.ReadOnly = false;

            int ERTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.EnhancedRadiationWarhead];
            if (ERTech == -1)
                m_oMissileDesignPanel.ERCheckBox.Enabled = false;
            else
                m_oMissileDesignPanel.ERCheckBox.Enabled = true;

            int LWTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.LaserWarhead];
            if (LWTech == -1)
                m_oMissileDesignPanel.LaserWCheckBox.Enabled = false;
            else
                m_oMissileDesignPanel.LaserWCheckBox.Enabled = true;

            double TotalSize = WarheadMSP + FuelMSP + AgilityMSP + ActiveMSP + ThermalMSP + EMMSP + GeoMSP + ReactorMSP + ECMMSP + ArmourMSP;
            if (_CurrnetMissileEngine != null && EngineCount != 0)
            {
                TotalSize = TotalSize + (EngineCount * _CurrnetMissileEngine.size * 20.0f);
            }

            if (SubMunition != null && SubNumber != 0)
            {
                TotalSize = TotalSize + (SubMunition.size * SubNumber);
            }

            if (TotalSize != 0.0 && TotalSize <= Constants.OrdnanceTN.MaxSize)
            {
                #region Tech
                int WHTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.WarheadStrength];
                if (WHTech > 11)
                    WHTech = 11;

                int AgilTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.MissileAgility];
                if (AgilTech > 11)
                    AgilTech = 11;

                int ActTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.ActiveSensorStrength];
                if (ActTech > 11)
                    ActTech = 11;

                int THTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.ThermalSensorSensitivity];
                if (THTech > 11)
                    THTech = 11;

                int EMTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.EMSensorSensitivity];
                if (EMTech > 11)
                    EMTech = 11;

                int GeoTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.GeoSensor];
                if (GeoTech > 3)
                    GeoTech = 3;

                int ReactorTech = _CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.ReactorBaseTech];
                if (ReactorTech > 11)
                    ReactorTech = 11;

                if (ECMTech > 9)
                    ECMTech = 9;

                if (ERTech > 3)
                    ERTech = 3;

                if (LWTech > 3)
                    LWTech = 3;

                #endregion

                m_oMissileDesignPanel.MissileNameTextBox.Text = String.Format("Size {0:N4} Missile", TotalSize);

                OrdnanceProject = new OrdnanceDefTN(m_oMissileDesignPanel.MissileNameTextBox.Text, null, WarheadMSP, WHTech, FuelMSP, AgilityMSP, AgilTech, ActiveMSP, ActTech, ThermalMSP, THTech, EMMSP, EMTech, GeoMSP, GeoTech, Resolution,
                                                    ReactorTech, ArmourValue, ECMMSP, ECMTech, Enhanced, ERTech, Laser, LWTech, _CurrnetMissileEngine, EngineCount, SubMunition, SubNumber, SepRange);

                String Entry = String.Format("Missile Size: {0:N4} MSP  ({1} HS)     Warhead: {2}    Armour: {3}     Manoeuvre Rating: {4}\n",
                                              OrdnanceProject.size, OrdnanceProject.size / 20.0f, OrdnanceProject.warhead, OrdnanceProject.armor, OrdnanceProject.manuever);
                m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

                String FormattedSpeed = OrdnanceProject.maxSpeed.ToString("#,##0");

                String EndString = "N/A";
                String RangeString = "N/A";

                if (OrdnanceProject.fuel == 0.0f || OrdnanceProject.totalFuelConsumption == 0.0f)
                {
                    RangeString = "0.0M km";
                    EndString = "0 Minutes";
                }
                else
                {
                    float Endurance = (OrdnanceProject.fuel / OrdnanceProject.totalFuelConsumption);

                    if (Endurance >= 8640.0f)
                    {
                        float YE = Endurance / 8640.0f;
                        EndString = String.Format("{0:N1} Years", YE);
                    }
                    else if (Endurance >= 720.0f)
                    {
                        float ME = Endurance / 720.0f;
                        EndString = String.Format("{0:N1} Months", ME);
                    }
                    else if (Endurance >= 24.0f)
                    {
                        float DE = Endurance / 24.0f;
                        EndString = String.Format("{0:N1} Days", DE);
                    }
                    else if (Endurance >= 1.0f)
                    {
                        EndString = String.Format("{0:N1} hours", Endurance);
                    }
                    else if ((Endurance * 60.0f) >= 1.0f)
                    {
                        EndString = String.Format("{0:N1} minutes", (Endurance * 60.0f));
                    }
                    else
                    {
                        EndString = String.Format("0 minutes");
                    }

                    if (Endurance != 0.0f)
                    {
                        float TimeOneBillionKM = (1000000000.0f / OrdnanceProject.maxSpeed) / 3600.0f;
                        float test = Endurance / TimeOneBillionKM;

                        if (test >= 1.0f)
                        {
                            RangeString = String.Format("{0:N1}B km", test);
                        }
                        else
                        {
                            float range = (Endurance * (OrdnanceProject.maxSpeed * 3600.0f)) / 1000000.0f;
                            RangeString = String.Format("{0:N1}M km", range);
                        }
                    }
                }

                Entry = String.Format("Speed: {0} km/s    Engine Endurance: {1}   Range: {2}\n", FormattedSpeed, EndString, RangeString);
                m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

                if (OrdnanceProject.activeStr != 0.0f)
                {
                    Entry = String.Format("Active Sensor Strength: {0}   Sensitivity Modifier: {1}%\n", OrdnanceProject.activeStr, (_CurrnetFaction.FactionTechLevel[(int)Faction.FactionTechnology.EMSensorSensitivity] * 10.0f));
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

                    String FormattedSRange = (OrdnanceProject.aSD.maxRange * 10000).ToString("#,##0");
                    Entry = String.Format("Resolution: {0}    Maximum Range vs {1} ton object (or larger): {2} km\n", OrdnanceProject.aSD.resolution, ((float)OrdnanceProject.aSD.resolution * 50.0f), FormattedSRange);
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }

                if (OrdnanceProject.thermalStr != 0.0f)
                {
                    String FormattedSRange = (OrdnanceProject.tHD.range * 10000).ToString("#,##0");
                    Entry = String.Format("Thermal Sensor Strength: {0}    Detect Sig Strength 1000:  {1} km\n", OrdnanceProject.thermalStr, FormattedSRange);
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }

                if (OrdnanceProject.eMStr != 0.0f)
                {
                    String FormattedSRange = (OrdnanceProject.eMD.range * 10000).ToString("#,##0");
                    Entry = String.Format("EM Sensor Strength: {0}    Detect Sig Strength 1000:  {1} km\n", OrdnanceProject.eMStr, FormattedSRange);
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }

                if (OrdnanceProject.geoStr != 0.0f)
                {
                    float maxPoints = 0.0f;

                    if (OrdnanceProject.engineCount > 0 && OrdnanceProject.fuel > 0.0f)
                    {
                        float Endurance = (OrdnanceProject.fuel / OrdnanceProject.totalFuelConsumption);
                        maxPoints = OrdnanceProject.geoStr * Endurance;
                    }

                    Entry = String.Format("Geo Sensor Strength: {0}    Maximum points: {1:N4}\n", OrdnanceProject.geoStr, maxPoints);
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }

                if (OrdnanceProject.isLaser == true)
                {
                    Entry = String.Format("Laser Warhead\n");
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }
                else if (OrdnanceProject.radValue != OrdnanceProject.warhead)
                {
                    Entry = String.Format("Radiation Damage: {0}\n", OrdnanceProject.radValue);
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }

                if (OrdnanceProject.eCMValue != 0)
                {
                    Entry = String.Format("ECM Level: {0}\n", ((float)OrdnanceProject.eCMValue / 10.0f));
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }

                Entry = String.Format("Cost Per Missile: {0}\n", OrdnanceProject.cost);
                m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);


                if (OrdnanceProject.subRelease != null && OrdnanceProject.subReleaseCount != 0)
                {
                    Entry = String.Format("Second Stage: {0} x{1}\n", OrdnanceProject.subRelease, OrdnanceProject.subReleaseCount);
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

                    if (OrdnanceProject.subReleaseDistance <= 1000000)
                    {
                        String FormattedSubRange = (OrdnanceProject.subReleaseDistance * 1000).ToString("#,##0");
                        Entry = String.Format("Second Stage Separation Range: {0} km\n", FormattedSubRange);
                    }
                    else
                    {
                        float SD = (OrdnanceProject.subReleaseDistance / 1000000.0f);
                        Entry = String.Format("Second Stage Separation Range: {0} B km\n", SD);
                    }
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

                    float Endurance = (OrdnanceProject.fuel / OrdnanceProject.totalFuelConsumption);
                    float SubEndurance = (OrdnanceProject.subRelease.fuel / OrdnanceProject.subRelease.totalFuelConsumption);

                    float TotalEndurance = Endurance + SubEndurance;

                    if (TotalEndurance >= 8640.0f)
                    {
                        float YE = TotalEndurance / 8640.0f;
                        EndString = String.Format("{0:N1} Years", YE);
                    }
                    else if (TotalEndurance >= 720.0f)
                    {
                        float ME = TotalEndurance / 720.0f;
                        EndString = String.Format("{0:N1} Months", ME);
                    }
                    else if (TotalEndurance >= 24.0f)
                    {
                        float DE = TotalEndurance / 24.0f;
                        EndString = String.Format("{0:N1} Days", DE);
                    }
                    else if (TotalEndurance >= 1.0f)
                    {
                        EndString = String.Format("{0:N1} hours", TotalEndurance);
                    }
                    else if ((TotalEndurance * 60.0f) >= 1.0f)
                    {
                        EndString = String.Format("{0:N1} minutes", (TotalEndurance * 60.0f));
                    }
                    else
                    {
                        EndString = String.Format("0 minutes");
                    }

                    if (TotalEndurance != 0.0f)
                    {
                        float TimeOneBillionKM = (1000000000.0f / OrdnanceProject.maxSpeed) / 3600.0f;
                        float TimeOneBillionKMSub = (1000000000.0f / OrdnanceProject.subRelease.maxSpeed) / 3600.0f;

                        float test1 = Endurance / TimeOneBillionKM;
                        float test2 = SubEndurance / TimeOneBillionKMSub;

                        float test = test1 + test2;

                        if (test >= 1.0f)
                        {
                            RangeString = String.Format("{0:N1}B km", test);
                        }
                        else
                        {
                            float range = (Endurance * (OrdnanceProject.maxSpeed * 3600.0f)) / 1000000.0f + (SubEndurance * (OrdnanceProject.subRelease.maxSpeed * 3600.0f)) / 1000000.0f;
                            RangeString = String.Format("{0:N1}M km", range);
                        }
                    }
                    else
                        RangeString = "0.0M";

                    Entry = String.Format("Overall Endurance: {0}   Overall Range: {1} km\n", EndString, RangeString);
                    m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
                }

                Entry = String.Format("Chance to Hit: 1k km/s {0}%   3k km/s {1}%   5k km/s {2}%   10k km/s {3}%\n", OrdnanceProject.ToHit(1000.0f), OrdnanceProject.ToHit(3000.0f),
                                                                                                                   OrdnanceProject.ToHit(5000.0f), OrdnanceProject.ToHit(10000.0f));
                m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

                Entry = "Materials Required: ";
                for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
                {
                    if (OrdnanceProject.minerialsCost[mineralIterator] != 0.0m)
                    {
                        Entry = String.Format("{0}   {1:N3}x {2}", Entry, OrdnanceProject.minerialsCost[mineralIterator], (Constants.Minerals.MinerialNames)mineralIterator);
                    }
                }
                if (OrdnanceProject.fuel != 0.0f)
                {
                    Entry = String.Format("{0}   Fuel x{1}\n", Entry, Math.Floor(OrdnanceProject.fuelCost));
                }

                m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

                Entry = String.Format("\nDevelopment Cost for Project: {0}RP\n", (OrdnanceProject.cost * 100));
                m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);

            }
            else if (TotalSize > Constants.OrdnanceTN.MaxSize)
            {
                String Entry = String.Format("Missile Exceeds max size.\n");
                m_oMissileDesignPanel.MissileSummaryTextBox.AppendText(Entry);
            }
        }
Example #15
0
        /// <summary>
        /// Ordnance Constructor.
        /// </summary>
        /// <param name="title">Name</param>
        /// <param name="Series">Series of missile</param>
        /// <param name="whMSP">Size devoted to Warhead</param>
        /// <param name="whTech">warhead tech</param>
        /// <param name="fuelMSP">Size devoted to fuel</param>
        /// <param name="AgilityMSP">Size devoted to agility</param>
        /// <param name="agilTech">Agility tech</param>
        /// <param name="activeMSP">Size devoted to actives</param>
        /// <param name="activeTech">Active tech</param>
        /// <param name="thermalMSP">Size devoted to thermal</param>
        /// <param name="thermalTech">thermal tech</param>
        /// <param name="emMSP">size devoted to EM</param>
        /// <param name="emTech">em tech</param>
        /// <param name="geoMSP">size devoted to geosurvey</param>
        /// <param name="geoTech">geo tech</param>
        /// <param name="aRes">Active sensor resolution</param>
        /// <param name="reactorTech">Reactor tech</param>
        /// <param name="armor">Armor amount</param>
        /// <param name="ECM">is ecm present?</param>
        /// <param name="ecmTech">ecm tech</param>
        /// <param name="enhanced">is warhead rad enhanced?</param>
        /// <param name="radTech">rad tech</param>
        /// <param name="laser">is laser warhead?</param>
        /// <param name="laserTech">laser tech</param>
        /// <param name="SubMunition">Secondary munition</param>
        /// <param name="SubMunitionCount">number of secondary munition</param>
        /// <param name="SeparationDist">release separation of secondary munition from target</param>
        /// <param name="Engine">Missile engine</param>
        /// <param name="missileEngineCount">number of missile engines</param>
        public OrdnanceDefTN(string title, OrdnanceSeriesTN Series,
                             float whMSP, int whTech, float fuelMSP, float AgilityMSP, int agilTech,
                             float activeMSP, int activeTech, float thermalMSP, int thermalTech, float emMSP, int emTech, float geoMSP, int geoTech, ushort aRes, int reactorTech,
                             float armorMSP, float ECMMSP, int ecmTech, bool enhanced, int radTech, bool laser, int laserTech, MissileEngineDefTN Engine, int missileEngineCount,
                             OrdnanceDefTN SubMunition = null, int SubMunitionCount = 0, int SeparationDist = -1)
        {
            /// <summary>
            /// Ignore these:
            /// </summary>
            Name = title;
            Id = Guid.NewGuid();
            crew = 0;
            isMilitary = true;
            isSalvaged = false;
            isDivisible = false;
            isElectronic = false;

            /// <summary>
            /// Size will be total MSP here rather than HS.
            /// </summary>
            size = 0;
            cost = 0;

            WMSP = whMSP;
            AgMSP = AgilityMSP;
            AcMSP = activeMSP;
            TMSP = thermalMSP;
            EMSP = emMSP;
            GMSP = geoMSP;

            /// <summary>
            /// Warhead handling section.
            /// </summary>
            Warhead = (int)Math.Floor(whMSP * (float)Constants.OrdnanceTN.warheadTech[whTech]);
            RadValue = Warhead;

            if (enhanced == true)
            {
                RadValue = Warhead * Constants.OrdnanceTN.radTech[radTech];
                Warhead = Warhead / Constants.OrdnanceTN.radTech[radTech];
                IsLaser = false;
            }
            else if (laser == true)
            {

                /// <summary>
                /// These weren't ever really implemented, so I'm not quite sure what to do with them. I'll have them use laser damage penetration and atmospheric reductions.
                /// </summary>
                Warhead = (int)Math.Floor(whMSP * (float)Constants.OrdnanceTN.laserTech[laserTech]);
                IsLaser = true;

                /// <summary>
                /// Laser warheads won't do radiation, but won't pierce atmosphere.
                /// </summary>
                RadValue = 0;

            }
            size = size + whMSP;

            /// <summary>
            /// Fuel handling Section.
            /// </summary>
            Fuel = fuelMSP * 2500.0f;
            FuelCost = Fuel;

            size = size + fuelMSP;


            /// <summary>
            /// Engine Handling.
            /// </summary>
            OrdnanceEngine = Engine;
            EngineCount = missileEngineCount;

            if (OrdnanceEngine != null)
            {
                TotalEnginePower = (OrdnanceEngine.enginePower * (float)EngineCount);
                TotalThermalSignature = (OrdnanceEngine.thermalSignature * (float)EngineCount);
                TotalFuelConsumption = (OrdnanceEngine.fuelConsumption * (float)EngineCount);

                /// <summary>
                /// Engine sizes are divided by 20 to make their formula work.
                /// </summary>
                size = size + (OrdnanceEngine.size * (float)EngineCount * 20.0f);
            }

            /// <summary>
            /// Agility Handling.
            /// </summary>
            Agility = (int)Math.Floor(AgilityMSP * (float)Constants.OrdnanceTN.agilityTech[agilTech]);
            size = size + AgilityMSP;



            /// <summary>
            /// Sensor Handling Section:
            /// </summary>
            ActiveStr = activeMSP * Constants.OrdnanceTN.activeTech[activeTech];
            size = size + activeMSP;

            if (ActiveStr != 0.0f)
            {
                ASD = new ActiveSensorDefTN(ActiveStr, (byte)Math.Floor(Constants.OrdnanceTN.passiveTech[emTech] * 20.0f), aRes);
            }

            ThermalStr = thermalMSP * Constants.OrdnanceTN.passiveTech[thermalTech];
            size = size + thermalMSP;

            if (ThermalStr != 0.0f)
            {
                THD = new PassiveSensorDefTN(ThermalStr, PassiveSensorType.Thermal);
            }

            EMStr = emMSP * Constants.OrdnanceTN.passiveTech[emTech];
            size = size + emMSP;

            if (EMStr != 0.0f)
            {
                EMD = new PassiveSensorDefTN(EMStr, PassiveSensorType.EM);
            }

            GeoStr = geoMSP * Constants.OrdnanceTN.geoTech[geoTech];
            size = size + geoMSP;

            ReactorValue = ((ActiveStr + ThermalStr + EMStr + GeoStr) / 5.0f);
            ReactorMSP = ReactorValue / Constants.OrdnanceTN.reactorTech[reactorTech];
            size = size + ReactorMSP;

            if (ECMMSP != 0.0f)
            {
                if (ECMMSP > 1.0f)
                    ECMMSP = 1.0f;

                ECMValue = (int)Math.Round((float)(ecmTech + 1) * 10.0f * ECMMSP);
                size = size + ECMMSP;
            }

            Armor = armorMSP;
            size = size + Armor;

            /// <summary>
            /// Do secondary missiles here.
            /// </summary>
            /// 
            if (SubMunition != null)
            {
                SubRelease = SubMunition;
                SubReleaseCount = SubMunitionCount;
                SubReleaseDistance = SeparationDist;
            }
            else
            {
                SubRelease = null;
                SubReleaseCount = -1;
                SubReleaseDistance = -1;
            }

            /// <summary>
            /// now that the size of the missile is known, we can see what its detection characteristics should be.
            /// </summary>
            DetectMSP = (int)Math.Floor(size);

            if (DetectMSP <= 6)
            {
                DetectMSP = 0;
            }
            else if (DetectMSP >= 20)
            {
                DetectMSP = 14;
            }
            else
            {
                DetectMSP = DetectMSP - 6;
            }

            if (Warhead == RadValue || RadValue == 0)
            {
                cost = cost + (decimal)((float)Warhead / 4.0f);
            }
            else
            {
                cost = cost + (decimal)((float)(Warhead * Constants.OrdnanceTN.radTech[radTech]) / 4.0f);
            }
            if (OrdnanceEngine != null)
            {
                cost = cost + (OrdnanceEngine.cost * EngineCount);
            }
            cost = cost + (decimal)((Agility) / 50.0f);
            cost = cost + (decimal)(ReactorValue * 3.0f);
            cost = cost + (decimal)(ThermalStr);
            cost = cost + (decimal)(EMStr);
            cost = cost + (decimal)(ActiveStr);
            cost = cost + (decimal)(GeoStr * 25.0f);
            cost = cost + (decimal)((float)Armor / 4.0f);
            cost = cost + (decimal)((float)ECMValue / 20.0f);

            minerialsCost = new decimal[Constants.Minerals.NO_OF_MINERIALS];
            for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
            {
                minerialsCost[mineralIterator] = 0;
            }

            if (Warhead == RadValue || RadValue == 0)
            {
                minerialsCost[(int)Constants.Minerals.MinerialNames.Tritanium] = (decimal)(((float)Warhead / 4.0f) + ((float)Armor / 4.0f));
            }
            else
            {
                minerialsCost[(int)Constants.Minerals.MinerialNames.Tritanium] = (decimal)((float)(Warhead * Constants.OrdnanceTN.radTech[radTech]) / 4.0f);
            }
            minerialsCost[(int)Constants.Minerals.MinerialNames.Gallicite] = (decimal)(OrdnanceEngine.cost * EngineCount) + (decimal)((float)Agility / 50.0f);
            minerialsCost[(int)Constants.Minerals.MinerialNames.Uridium] = (decimal)(ThermalStr + EMStr + ActiveStr + (GeoStr * 25.0f) + ((float)ECMValue / 20.0f));
            minerialsCost[(int)Constants.Minerals.MinerialNames.Boronide] = (decimal)(ReactorValue * 3.0f);

            if (SubMunition != null)
            {
                size = size + (SubMunition.size * SubMunitionCount);
                cost = cost + (SubMunition.cost * SubMunitionCount);

                for (int mineralIterator = 0; mineralIterator < (int)Constants.Minerals.MinerialNames.MinerialCount; mineralIterator++)
                {
                    minerialsCost[mineralIterator] = minerialsCost[mineralIterator] + (SubMunition.minerialsCost[mineralIterator] * SubMunitionCount);
                }

                FuelCost = FuelCost + (SubMunition.FuelCost * SubMunitionCount);
            }

            isObsolete = false;

            MaxSpeed = (float)TotalEnginePower * (1000.0f / (size * 0.05f));

            if (MaxSpeed > Constants.OrdnanceTN.MaximumSpeed)
            {
                MaxSpeed = Constants.OrdnanceTN.MaximumSpeed;
            }

            /// <summary>
            /// Bombs dropped directly on target, or otherwise things I really don't want to move, but don't want to screw up TimeReq for.
            /// </summary>
            if (MaxSpeed == 0)
                MaxSpeed = 1;

            Manuever = 10.0f + (Agility / size);

            if (Series != null)
            {
                OrdSeries = Series;
                Series.AddMissileToSeries(this);
            }
        }
Example #16
0
        /// <summary>
        /// Loads or unloads missiles from a population.
        /// </summary>
        /// <param name="Missile">Ordnance type to be loaded or unloaded.</param>
        /// <param name="inc">Amount to load or unload.</param>
        /// <returns>Missiles placed into stockpile or taken out of it.</returns>
        public float LoadMissileToStockpile(OrdnanceDefTN Missile, float inc)
        {
            if (inc > 0)
            {
                if (MissileStockpile.ContainsKey(Missile))
                {
                    MissileStockpile[Missile] = MissileStockpile[Missile] + inc;
                }
                else
                {
                    MissileStockpile.Add(Missile, inc);
                }
                return inc;
            }
            else
            {
                if (MissileStockpile.ContainsKey(Missile) == false)
                {
                    return 0;
                }
                else
                {
                    /// <summary>
                    /// Inc is negative here.
                    /// </summary>
                    float retVal = MissileStockpile[Missile];
                    MissileStockpile[Missile] = MissileStockpile[Missile] + inc;

                    if (MissileStockpile[Missile] <= 0)
                    {
                        MissileStockpile.Remove(Missile);

                        return retVal;
                    }

                    return inc;
                }
            }
        }
Example #17
0
        /// <summary>
        /// End Copy Paste from Ship.cs
        /// </summary>

        /// <summary>
        /// Constructor for missiles.
        /// </summary>
        /// <param name="mfCtrl">MFC directing this missile.</param>
        /// <param name="definition">definition of the missile.</param>
        public OrdnanceTN(MissileFireControlTN mfCtrl, OrdnanceDefTN definition, ShipTN ShipFiredFrom)
            : base()
        {
            Name = definition.Name;

            MFC = mfCtrl;

            Target = MFC.target;

            FiringShip = ShipFiredFrom;

            MissileDef = definition;

            /// <summary>
            /// Litres of fuel available to this missile.
            /// </summary>
            Fuel = definition.fuel * 2500.0f;

            Separated = false;
            OnOwnSensors = false;
        }
        /// <summary>
        /// Constructor for this view model.
        /// </summary>
        public MissileDesignViewModel()
        {
            _CurrnetFaction = GameState.Instance.Factions[0];
            Factions = GameState.Instance.Factions;

            MissileEngines = _CurrnetFaction.ComponentList.MissileEngineDef;

            if (MissileEngines.Count != 0)
                CurrentMissileEngine = MissileEngines[0];

            MissileSeries = _CurrnetFaction.OrdnanceSeries;

            if (MissileSeries.Count != 0)
                CurrentMissileSeries = MissileSeries[0];

            Missiles = _CurrnetFaction.ComponentList.MissileDef;

            if (Missiles.Count != 0)
            {
                CurrentMissile = Missiles[0];
            }
        }