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

        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructor for basic faction.
        /// </summary>
        /// <param name="ID">placement of this faction in the factionsystemdetection lists. must be in order.</param>
        public Faction(int ID, string name = "Human Federation", Species species = null)
            : base()
        {
            Name = name;
            if (species == null)
                Species = new Species(); // go with the default Species!
            else
                Species = species;

            KnownSystems = new BindingList<StarSystem>();
            TaskForces = new BindingList<TaskForce>();
            Commanders = new BindingList<Commander>();
            Populations = new BindingList<Population>();

            ComponentList = new ComponentDefListTN();
            ShipDesigns = new BindingList<ShipClassTN>();
            TaskGroups = new BindingList<TaskGroupTN>();
            Ships = new BindingList<ShipTN>();
            ComponentList.AddInitialComponents();

            SystemContacts = new Dictionary<StarSystem, FactionSystemDetection>();
            DetectedContactLists = new Dictionary<StarSystem, DetectedContactsList>();

            FactionID = ID;

            InstallationTypes = new BindingList<Installation>();
            for (int loop = 0; loop < (int)Installation.InstallationType.InstallationCount; loop++)
            {
                Installation NewInst = new Installation((Installation.InstallationType)loop);
                InstallationTypes.Add(NewInst);
            }

            MessageLog = new BindingList<MessageEntry>();

            MissileGroups = new BindingList<OrdnanceGroupTN>();

            OrdnanceSeries = new BindingList<OrdnanceSeriesTN>();
            OrdnanceSeriesTN NewOrd = new OrdnanceSeriesTN("No Series Selected");
            OrdnanceSeries.Add(NewOrd);

            BaseTracking = Constants.GameSettings.FactionBaseTrackingSpeed;

            OpenFireFC = new Dictionary<ComponentTN, ShipTN>();
            OpenFireFCType = new Dictionary<ComponentTN, bool>();

            PointDefense = new Dictionary<StarSystem, PointDefenseList>();

            MissileRemoveList = new BindingList<OrdnanceGroupTN>();

            RechargeList = new Dictionary<ShipTN, int>();

            FactionTechLevel = new BindingList<SByte>();

            for (int loop = 0; loop < (int)FactionTechnology.Count; loop++)
            {
                FactionTechLevel.Add(-1);
            }

            /// <summary>
            /// Hardening is a special case that must start at zero and not negative 1.
            /// </summary>
            FactionTechLevel[(int)Faction.FactionTechnology.Hardening] = 0;

            /// <summary>
            /// These are conventional tech starts, each conventional faction starts with them researched.
            /// If anyone has a better idea about how these should be organized feel free, but note that changing this will have repercussions in Component design(specifically components.cs)
            /// </summary>
            FactionTechLevel[(int)Faction.FactionTechnology.ThermalSensorSensitivity] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.EMSensorSensitivity] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.FuelConsumption] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.ThermalReduction] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.CapacitorChargeRate] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.EngineBaseTech] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.ReducedSizeLaunchers] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.ArmourProtection] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.WarheadStrength] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.MissileAgility] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.TurretTracking] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.ECCM] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.DSTSSensorStrength] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.MinJumpEngineSize] = 0;
            FactionTechLevel[(int)Faction.FactionTechnology.ShipProdRate] = 0;

            ShipBPTotal = Constants.GameSettings.FactionStartingShipBP;
            PDCBPTotal = Constants.GameSettings.FactionStartingPDCBP;


            FactionWealth = Constants.Faction.StartingWealth;

            /// <summary>
            /// Ships and missiles are added to these two binding lists. this is for later to help the detected contact list.
            /// </summary>
            DetShipList = new BindingList<ShipTN>();
            DetMissileList = new BindingList<OrdnanceGroupTN>();
            DetPopList = new BindingList<Population>();

            GameState.Instance.Factions.Add(this);

            foreach (StarSystem system in GameState.Instance.StarSystems)
            {
                AddNewContactList(system);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Loads a missile from the specified series on Population pop into the ship.
        /// </summary>
        /// <param name="Series">Series of missile to search through</param>
        /// <param name="pop">Population stockpile.</param>
        /// <param name="SCValue">ShipClass Preferred Ordnance #</param>
        /// <param name="SOValue">Current Ship Ordnance #</param>
        public void LoadMissileFromPopulation(OrdnanceSeriesTN Series, Population pop, int SCValue, int SOValue)
        {
            for (int loop = (Series.missilesInSeries.Count - 1); loop >= 0; loop--)
            {
                if (pop.MissileStockpile.ContainsKey(Series.missilesInSeries[loop]))
                {
                    int SpaceAvailable = CurrentMagazineCapacityMax - CurrentMagazineCapacity;
                    int MissileReq = ((SCValue - SOValue) * (int)Math.Ceiling(Series.missilesInSeries[loop].size));


                    if (MissileReq <= SpaceAvailable)
                    {
                        /// <summary>
                        /// Unload missiles from Stockpile. MissilesAvailable will be less than or equal to MissileReq.
                        /// MissilesAvailable is the number of missiles.
                        /// AvailableSizeTotal is the total size of the available missiles.
                        /// missileSpaceReq is the number of missiles that will fit in the remaining space available.
                        /// </summary>
                        int MissilesAvailable = (int)Math.Floor(pop.LoadMissileToStockpile(Series.missilesInSeries[loop], (float)(MissileReq * -1.0f)));
                        int missileSpaceReq = (int)Math.Floor((double)SpaceAvailable / Math.Ceiling(Series.missilesInSeries[loop].size));
                        int load = 0;
                        if (missileSpaceReq >= MissilesAvailable)
                            load = MissilesAvailable;
                        else
                            load = missileSpaceReq;

                        /// <summary>
                        /// Now load them to shipOrdnance.
                        /// </summary>
                        if (ShipOrdnance.ContainsKey(Series.missilesInSeries[loop]) == true)
                        {
                            ShipOrdnance[Series.missilesInSeries[loop]] = ShipOrdnance[Series.missilesInSeries[loop]] + load;
                        }
                        else
                        {
                            ShipOrdnance.Add(Series.missilesInSeries[loop], load);
                        }

                        CurrentMagazineCapacity = CurrentMagazineCapacity + load;

                        MissilesAvailable = MissilesAvailable - load;

                        if (MissilesAvailable > 0)
                        {
                            /// <summary>
                            /// Magazines are all filled and cannot accomodate remaining missiles. put the extras back in the stockpile.
                            /// </summary>
                            pop.LoadMissileToStockpile(Series.missilesInSeries[loop], MissilesAvailable);
                            return;
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Does this ship have a missile of Series X?
        /// </summary>
        /// <param name="Series">Series to test against.</param>
        /// <returns>Number of missiles of that series.</returns>
        public int ContainsMissileOfSeries(OrdnanceSeriesTN Series)
        {
            if (ShipOrdnance.Count == 0)
            {
                return 0;
            }
            else
            {
                foreach (KeyValuePair<OrdnanceDefTN, int> SOPair in ShipOrdnance)
                {
                    if (SOPair.Key.ordSeries == Series)
                    {
                        return SOPair.Value;
                    }
                }

                return 0;
            }
        }
Ejemplo n.º 7
0
        /// <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();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// creates the series with the appropriate name. this is only called from two places, the okbutton, and keypress functions above.
        /// </summary>
        private void CreateSeries()
        {
            OrdnanceSeriesTN NewSeries = new OrdnanceSeriesTN(m_oNameSeriesPanel.RenameClassTextBox.Text);
            _CurrnetFaction.OrdnanceSeries.Add(NewSeries);

            m_oNameSeriesPanel.RenameClassTextBox.Text = "";

            m_oMissileDesignPanel.MSeriesComboBox.SelectedIndex = (_CurrnetFaction.OrdnanceSeries.Count - 1);
        }
Ejemplo n.º 9
0
        /// <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();
        }