Esempio n. 1
0
        public void testArmor()
        {
            Faction newFaction = new Faction(0);
            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);

            StarSystem System1 = SystemGen.CreateSol();

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

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            ts2.ShipArmorDef = new ArmorDefTN("Duranium Armour");
            ts.ShipArmor = new ArmorTN(ts2.ShipArmorDef);

            ts2.ShipArmorDef.CalcArmor("Duranium Armor", 5, 38.0, 5);

            Console.WriteLine("ArmorPerHS: {0}", ts2.ShipArmorDef.armorPerHS);
            Console.WriteLine("Size: {0}", ts2.ShipArmorDef.size);
            Console.WriteLine("Cost: {0}", ts2.ShipArmorDef.cost);
            Console.WriteLine("Area: {0}", ts2.ShipArmorDef.area);
            Console.WriteLine("Depth: {0}", ts2.ShipArmorDef.depth);
            Console.WriteLine("Column Number: {0}", ts2.ShipArmorDef.cNum);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);


            ts.ShipArmor.SetDamage(ts2.ShipArmorDef.cNum, ts2.ShipArmorDef.depth, 4, 1);
            for (int loop = 0; loop < ts2.ShipArmorDef.cNum; loop++)
            {
                Console.WriteLine("Column Value: {0}", ts.ShipArmor.armorColumns[loop]);
            }
            Console.WriteLine("Damage Key: {0}, Column Value: {1}", ts.ShipArmor.armorDamage.Min().Key, ts.ShipArmor.armorDamage.Min().Value);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            ts.ShipArmor.RepairSingleBlock(ts2.ShipArmorDef.depth);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            ts.ShipArmor.SetDamage(ts2.ShipArmorDef.cNum, ts2.ShipArmorDef.depth, 4, 1);
            for (int loop = 0; loop < ts2.ShipArmorDef.cNum; loop++)
            {
                Console.WriteLine("Column Value: {0}", ts.ShipArmor.armorColumns[loop]);
            }
            Console.WriteLine("Damage Key: {0}, Column Value: {1}", ts.ShipArmor.armorDamage.Min().Key, ts.ShipArmor.armorDamage.Min().Value);

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            ts.ShipArmor.RepairAllArmor();

            Console.WriteLine("isDamaged: {0}", ts.ShipArmor.isDamaged);

            Console.WriteLine("Cost: {0}, Area: {1},Size: {2}", ts.ShipArmor.armorDef.cost, ts.ShipArmor.armorDef.area, ts.ShipArmor.armorDef.size);
        }
        /// <summary>
        /// Constructor for TGViewModel. Initialization is to faction 0 task group 0.
        /// Later functionality will handle updating faction and taskgroup indices.
        /// </summary>
        public TaskGroupViewModel()
        {
            _CurrentFaction = GameState.Instance.Factions[0];
            Factions = GameState.Instance.Factions;

            if (GameState.Instance.Factions[0].TaskGroups.Count != 0)
                _CurrentTaskGroup = GameState.Instance.Factions[0].TaskGroups[0];

            TaskGroups = GameState.Instance.Factions[0].TaskGroups;
        }
Esempio n. 3
0
        /// <summary>
        /// Initializer for detected ship event. FactionContact is the detector side of what is detected, while ShipTN itself stores the detectee side. 
        /// multiple of these can exist, but only 1 per faction hopefully.
        /// </summary>
        /// <param name="DetectedShip">Ship detected.</param>
        /// <param name="Thermal">Was the detection thermal based?</param>
        /// <param name="em">Detection via EM?</param>
        /// <param name="Active">Active detection?</param>
        /// <param name="tick">What tick did this detection event occur on?</param>
        public FactionContact(Faction CurrentFaction, ShipTN DetectedShip, bool Thermal, bool em, int EMSig, bool Active, uint tick)
        {
            ship = DetectedShip;
            missileGroup = null;
            pop = null;
            thermal = Thermal;
            EM = em;
            EMSignature = EMSig;
            active = Active;

            String Contact = "New contact detected:";

            if (thermal == true)
            {
                thermalTick = tick;
                Contact = String.Format("{0} Thermal Signature {1}", Contact, DetectedShip.CurrentThermalSignature);
            }

            if (EM == true)
            {
                EMTick = tick;
                Contact = String.Format("{0} EM Signature {1}", Contact, EMSignature);
            }

            if (active == true)
            {
                activeTick = tick;
                Contact = String.Format("{0} TCS {1}", Contact, DetectedShip.TotalCrossSection);
            }

            /// <summary>
            /// Print to the message log.
            /// </summary>
            MessageEntry NMsg = new MessageEntry(MessageEntry.MessageType.ContactNew, DetectedShip.ShipsTaskGroup.Contact.Position.System, DetectedShip.ShipsTaskGroup.Contact,
                                                 GameState.Instance.GameDateTime, GameState.Instance.LastTimestep, Contact);

            CurrentFaction.MessageLog.Add(NMsg);

            /// <summary>
            /// Inform SimEntity.
            /// </summary>
            GameState.SE.SetInterrupt(InterruptType.NewSensorContact);

        }
Esempio n. 4
0
        /// <summary>
        /// Is this installation buildable?
        /// </summary>
        /// <param name="Fact">Faction owner of this installation type.</param>
        /// <param name="Pop">Population on which this installation is to be built.</param>
        /// <returns>Whether or not the installation can be built by Faction Fact on Population Pop</returns>
        public bool IsBuildable(Faction Fact, Population Pop)
        {
            /// <summary>
            /// CI and CMCs are not buildable.
            /// </summary>
            if (CanBeBuilt == false)
            {
                return false;
            }

            /// <summary>
            /// Technology Check
            /// </summary>
            if (RequiredTechnology != Faction.FactionTechnology.Count)
            {
                if (Fact.FactionTechLevel[(int)RequiredTechnology] < RequiredTechLevel)
                {
                    return false;
                }
            }

            /// <summary>
            /// Required installation check.
            /// </summary>
            if (RequiredPrerequisitInstallation != InstallationType.InstallationCount)
            {
                if (Pop.Installations[(int)RequiredPrerequisitInstallation].Number < 1.0f)
                {
                    return false;
                }
            }

            return true;
        }
Esempio n. 5
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);
        }
Esempio n. 6
0
        public void CargoLoadUnloadTest()
        {
            Faction PlayerFaction1 = new Faction(0);

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

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


            PlayerFaction1.AddNewShipDesign("Blucher");

            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].AddCargoHold(PlayerFaction1.ComponentList.CargoHoldDef[1], 1);

            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[0], PlayerFaction1,0);

            System1.Stars[0].Planets[0].Populations[0].Installations[(int)Installation.InstallationType.Infrastructure].Number = 3.0f;
            System1.Stars[0].Planets[0].Populations[1].Installations[(int)Installation.InstallationType.Infrastructure].Number = 0.0f;

            Console.WriteLine("Infrastructure on P1 and P2:{0} {1}", System1.Stars[0].Planets[0].Populations[0].Installations[(int)Installation.InstallationType.Infrastructure].Number,
                System1.Stars[0].Planets[0].Populations[1].Installations[(int)Installation.InstallationType.Infrastructure].Number);

            PlayerFaction1.TaskGroups[0].LoadCargo(System1.Stars[0].Planets[0].Populations[0], Installation.InstallationType.Infrastructure, 1);

            Console.WriteLine("Infrastructure on cargo tg after load in tons:{0}", PlayerFaction1.TaskGroups[0].Ships[0].CargoList[Installation.InstallationType.Infrastructure].tons);

            PlayerFaction1.TaskGroups[0].UnloadCargo(System1.Stars[0].Planets[0].Populations[1], Installation.InstallationType.Infrastructure, 1);

            Console.WriteLine("Infrastructure on P1 and P2:{0} {1}", System1.Stars[0].Planets[0].Populations[0].Installations[(int)Installation.InstallationType.Infrastructure].Number,
    System1.Stars[0].Planets[0].Populations[1].Installations[(int)Installation.InstallationType.Infrastructure].Number);

            Console.WriteLine("CargoList dictionary count after unload:{0}", PlayerFaction1.TaskGroups[0].Ships[0].CargoList.Count);
        }
Esempio n. 7
0
        public void TaskGroupFuelOrdersTest()
        {
            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);
            SystemBody pl3 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            System1.Stars[0].Planets.Add(pl1);
            System1.Stars[0].Planets.Add(pl2);
            System1.Stars[0].Planets.Add(pl3);

            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 = 0.0;
            System1.Stars[0].Planets[1].Position.Y = 3.0;

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


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

            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], 10);
            PlayerFaction1.ShipDesigns[0].AddEngineeringSpaces(PlayerFaction1.ComponentList.EngineeringSpaces[0], 2);
            PlayerFaction1.ShipDesigns[0].AddOtherComponent(PlayerFaction1.ComponentList.OtherComponents[0], 1);
            PlayerFaction1.ShipDesigns[0].IsTanker = true;

            PlayerFaction1.ShipDesigns[1].AddEngine(PlayerFaction1.ComponentList.Engines[0], 1);
            PlayerFaction1.ShipDesigns[1].AddCrewQuarters(PlayerFaction1.ComponentList.CrewQuarters[0], 2);
            PlayerFaction1.ShipDesigns[1].AddFuelStorage(PlayerFaction1.ComponentList.FuelStorage[0], 10);
            PlayerFaction1.ShipDesigns[1].AddEngineeringSpaces(PlayerFaction1.ComponentList.EngineeringSpaces[0], 2);
            PlayerFaction1.ShipDesigns[1].AddOtherComponent(PlayerFaction1.ComponentList.OtherComponents[0], 1);
            PlayerFaction1.ShipDesigns[1].IsTanker = true;

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

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

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

            PlayerFaction1.TaskGroups[0].Ships[0].Refuel(50000.0f);
            PlayerFaction1.TaskGroups[0].Ships[1].Refuel(50000.0f);
            PlayerFaction1.TaskGroups[1].Ships[0].Refuel(1000000.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].FuelStockpile = 10000000.0f;
            System1.Stars[0].Planets[1].Populations[0].FuelStockpile = 10.0f;

            PlayerFaction1.TaskGroups[1].IsOrbiting = false;
            PlayerFaction1.TaskGroups[1].Contact.Position.X = 3.0;
            PlayerFaction1.TaskGroups[1].Contact.Position.Y = 0.0;

            Order RefuelFromColony = new Order(Constants.ShipTN.OrderType.RefuelFromColony, -1, -1, -1, System1.Stars[0].Planets[0].Populations[0]);
            PlayerFaction1.TaskGroups[0].IssueOrder(RefuelFromColony);

            Order RefuelFromTargetFleet = new Order(Constants.ShipTN.OrderType.RefuelFromTargetFleet, -1, -1, -1, PlayerFaction1.TaskGroups[1]);
            PlayerFaction1.TaskGroups[0].IssueOrder(RefuelFromTargetFleet);

            Order RefuelTargetFleet = new Order(Constants.ShipTN.OrderType.RefuelTargetFleet, -1, -1, -1, PlayerFaction1.TaskGroups[2]);
            PlayerFaction1.TaskGroups[0].IssueOrder(RefuelTargetFleet);

            Order RefuelFromOwnTankers = new Order(Constants.ShipTN.OrderType.RefuelFromOwnTankers, -1, -1, -1, System1.Stars[0].Planets[1].Populations[0]);
            PlayerFaction1.TaskGroups[0].IssueOrder(RefuelFromOwnTankers);

            Order UnloadFuelToPop = new Order(Constants.ShipTN.OrderType.UnloadFuelToPlanet, -1, -1, -1, System1.Stars[0].Planets[1].Populations[0]);
            PlayerFaction1.TaskGroups[0].IssueOrder(UnloadFuelToPop);

            uint tickCount = 0;

            while (PlayerFaction1.TaskGroups[0].TaskGroupOrders.Count > 0)
            {
                Console.WriteLine("===================={0} {1} {2}====================", tickCount, PlayerFaction1.TaskGroups[0].TaskGroupOrders.Count, PlayerFaction1.TaskGroups[0].TimeRequirement);
                Console.WriteLine("X,Y: {0}/{1}", PlayerFaction1.TaskGroups[0].Contact.Position.X, PlayerFaction1.TaskGroups[0].Contact.Position.Y);
                Console.WriteLine("Fuel:s1:{0} s2:{1} s3:{2} s4:{3} P1:{4} P2:{5}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentFuel, PlayerFaction1.TaskGroups[0].Ships[1].CurrentFuel,
                    PlayerFaction1.TaskGroups[1].Ships[0].CurrentFuel, PlayerFaction1.TaskGroups[2].Ships[0].CurrentFuel, System1.Stars[0].Planets[0].Populations[0].FuelStockpile,
                    System1.Stars[0].Planets[1].Populations[0].FuelStockpile);

                PlayerFaction1.TaskGroups[0].FollowOrders(Constants.TimeInSeconds.Hour);
                tickCount = tickCount + Constants.TimeInSeconds.Hour;
            }

            Console.WriteLine("===================={0} {1} {2}====================", tickCount, PlayerFaction1.TaskGroups[0].TaskGroupOrders.Count, PlayerFaction1.TaskGroups[0].TimeRequirement);
            Console.WriteLine("X,Y: {0}/{1}", PlayerFaction1.TaskGroups[0].Contact.Position.X, PlayerFaction1.TaskGroups[0].Contact.Position.Y);
            Console.WriteLine("Fuel:s1:{0} s2:{1} s3:{2} s4:{3} P1:{4} P2:{5}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentFuel, PlayerFaction1.TaskGroups[0].Ships[1].CurrentFuel,
                PlayerFaction1.TaskGroups[1].Ships[0].CurrentFuel, PlayerFaction1.TaskGroups[2].Ships[0].CurrentFuel, System1.Stars[0].Planets[0].Populations[0].FuelStockpile,
                System1.Stars[0].Planets[1].Populations[0].FuelStockpile);

        }
Esempio n. 8
0
        public void TGPassivesTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);
            PassiveSensorDefTN ThPasDef1 = new PassiveSensorDefTN("Thermal Sensor TH1-5", 1.0f, 5, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN ThPasDef2 = new PassiveSensorDefTN("Thermal Sensor TH1-6", 1.0f, 6, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN ThPasDef3 = new PassiveSensorDefTN("Thermal Sensor TH1-8", 1.0f, 8, PassiveSensorType.Thermal, 1.0f, 1);
            PassiveSensorDefTN ThPasDef4 = new PassiveSensorDefTN("Thermal Sensor TH1-11", 1.0f, 11, PassiveSensorType.Thermal, 1.0f, 1);


            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.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);

            Faction FID = new Faction(0);
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);

            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);
            for (int loop = 0; loop < 4; loop++)
            {


                ShipClassTN test = new ShipClassTN("Ship", FID);
                test.AddCrewQuarters(CrewQ, 2);
                test.AddFuelStorage(FuelT, 2);
                test.AddEngineeringSpaces(EBay, 2);
                test.AddOtherComponent(Bridge, 1);

                switch (loop)
                {
                    case 0: test.AddPassiveSensor(ThPasDef2, 5);
                        break;
                    case 1: test.AddPassiveSensor(ThPasDef1, 4);
                        break;
                    case 2: test.AddPassiveSensor(ThPasDef3, 7);
                        break;
                    case 3: test.AddPassiveSensor(ThPasDef4, 6);
                        break;
                }

                TaskGroup1.AddShip(test, "Test Ship");
                Console.WriteLine("Best Thermal:{0},{1}", TaskGroup1.BestThermal.pSensorDef.rating, TaskGroup1.BestThermalCount);
            }
        }
Esempio n. 9
0
        public void TGOrdersTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.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);


            Faction FID = new Faction(0); 
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);


            Waypoint WP1 = new Waypoint("WP TG Orders", System, 0.1, 0.1, 0);

            planet.Position.X = 0.0;
            planet.Position.Y = 0.0;


            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);

            ShipClassTN test = new ShipClassTN("Ship", FID);
            test.AddCrewQuarters(CrewQ, 2);
            test.AddFuelStorage(FuelT, 2);
            test.AddEngineeringSpaces(EBay, 2);
            test.AddOtherComponent(Bridge, 1);
            test.AddEngine(EngDef, 1);

            TaskGroup1.AddShip(test, "Test Ship");

            TaskGroup1.Ships[0].Refuel(200000.0f);

            Order TGOrder = new Order(Constants.ShipTN.OrderType.MoveTo, -1, -1, 0, WP1);

            TaskGroup1.IssueOrder(TGOrder);

            Console.WriteLine("Fuel Remaining:{0}", TaskGroup1.Ships[0].CurrentFuel);

            while (TaskGroup1.TaskGroupOrders.Count != 0)
            {
                TaskGroup1.FollowOrders(5);
                Console.WriteLine("{0} {1} | {2} {3}", Distance.ToKm(TaskGroup1.Contact.Position.X), Distance.ToKm(TaskGroup1.Contact.Position.Y), TaskGroup1.Contact.Position.X, TaskGroup1.Contact.Position.Y);
            }

            Console.WriteLine("Fuel Remaining:{0}", TaskGroup1.Ships[0].CurrentFuel);
        }
Esempio n. 10
0
        public void ComponentLoadUnloadTest()
        {
            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");

            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].AddCargoHold(PlayerFaction1.ComponentList.CargoHoldDef[1], 1);
            PlayerFaction1.ShipDesigns[0].AddCargoHandlingSystem(PlayerFaction1.ComponentList.CargoHandleSystemDef[0], 1);

            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].AddComponentsToStockpile(PlayerFaction1.ComponentList.Engines[0], 500.0f);

            /// <summary>
            /// The 1st 0 after the ordertype is for the ComponentStockpile[0] and CargoComponentList[0] index respectively.
            /// </summary>
            Order Load = new Order(Constants.ShipTN.OrderType.LoadShipComponent, 0, 0, 0, System1.Stars[0].Planets[0].Populations[0]);
            Order Unload = new Order(Constants.ShipTN.OrderType.UnloadShipComponent, 0, 0, 0, System1.Stars[0].Planets[1].Populations[0]);

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


            Console.WriteLine("Engine Components on on P1 and P2:{0} {1}", System1.Stars[0].Planets[0].Populations[0].ComponentStockpileCount[0],
                System1.Stars[0].Planets[1].Populations[0].ComponentStockpileCount.Count);


            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);
            }

            Console.WriteLine("Engine Components on on P1 and P2:{0} {1}", System1.Stars[0].Planets[0].Populations[0].ComponentStockpileCount[0],
                System1.Stars[0].Planets[1].Populations[0].ComponentStockpileCount[0]);

            Console.WriteLine("CargoList count on Ships[0] after unload :{0}", PlayerFaction1.TaskGroups[0].Ships[0].CargoComponentList.Count);
        }
Esempio n. 11
0
        public void testShip()
        {
            Faction newFaction = new Faction(0);

            /// <summary>
            /// These would go into a faction component list I think
            /// </summary>
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 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);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.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);

            ShipClassTN TestClass = new ShipClassTN("Test Ship Class", newFaction);

            TestClass.AddCrewQuarters(CrewQ, 2);
            TestClass.AddFuelStorage(FuelT, 2);
            TestClass.AddEngineeringSpaces(EBay, 2);
            TestClass.AddOtherComponent(Bridge, 1);

            TestClass.AddEngine(EngDef, 1);

            TestClass.AddPassiveSensor(ThPasDef, 1);
            TestClass.AddPassiveSensor(EMPasDef, 1);

            TestClass.AddActiveSensor(ActDef, 1);

            Console.WriteLine("Size: {0}, Crew: {1}, Cost: {2}, HTK: {3}, Tonnage: {4}", TestClass.SizeHS, TestClass.TotalRequiredCrew, TestClass.BuildPointCost, TestClass.TotalHTK, TestClass.SizeTons);

            Console.WriteLine("HS Accomodations/Required: {0}/{1}, Total Fuel Capacity: {2}, Total MSP: {3}, Engineering percentage: {4}, Has Bridge: {5}, Total Required Crew: {6}", TestClass.AccomHSAvailable, TestClass.AccomHSRequirement,
            TestClass.TotalFuelCapacity, TestClass.TotalMSPCapacity, (TestClass.EngineeringHS / TestClass.SizeHS), TestClass.HasBridge, TestClass.TotalRequiredCrew);

            Console.WriteLine("Armor Size: {0}, Cost: {1}", TestClass.ShipArmorDef.size, TestClass.ShipArmorDef.cost);

            Console.WriteLine("Ship Engine Power: {0}, Ship Thermal Signature: {1}, Ship Fuel Use Per Hour: {2}", TestClass.MaxEnginePower, TestClass.MaxThermalSignature, TestClass.MaxFuelUsePerHour);

            Console.WriteLine("Best TH: {0}, BestEM: {1}, Max EM Signature: {2}, Total Cross Section: {3}", TestClass.BestThermalRating, TestClass.BestEMRating, TestClass.MaxEMSignature, TestClass.TotalCrossSection);

            TestClass.AddCrewQuarters(CrewQ, -1);

            Console.WriteLine("Size: {0}, Crew: {1}, Cost: {2}, HTK: {3}, Tonnage: {4}", TestClass.SizeHS, TestClass.TotalRequiredCrew, TestClass.BuildPointCost, TestClass.TotalHTK, TestClass.SizeTons);

            Console.WriteLine("HS Accomodations/Required: {0}/{1}, Total Fuel Capacity: {2}, Total MSP: {3}, Engineering percentage: {4}, Has Bridge: {5}, Total Required Crew: {6}", TestClass.AccomHSAvailable, TestClass.AccomHSRequirement,
            TestClass.TotalFuelCapacity, TestClass.TotalMSPCapacity, (TestClass.EngineeringHS / TestClass.SizeHS), TestClass.HasBridge, TestClass.TotalRequiredCrew);

            Console.WriteLine("Armor Size: {0}, Cost: {1}", TestClass.ShipArmorDef.size, TestClass.ShipArmorDef.cost);

            Console.WriteLine("Ship Engine Power: {0}, Ship Thermal Signature: {1}, Ship Fuel Use Per Hour: {2}", TestClass.MaxEnginePower, TestClass.MaxThermalSignature, TestClass.MaxFuelUsePerHour);

            Console.WriteLine("Best TH: {0}, BestEM: {1}, Max EM Signature: {2}, Total Cross Section: {3}", TestClass.BestThermalRating, TestClass.BestEMRating, TestClass.MaxEMSignature, TestClass.TotalCrossSection);

            TestClass.AddCrewQuarters(CrewQ, -1);

            Console.WriteLine("Size: {0}, Crew: {1}, Cost: {2}, HTK: {3}, Tonnage: {4}", TestClass.SizeHS, TestClass.TotalRequiredCrew, TestClass.BuildPointCost, TestClass.TotalHTK, TestClass.SizeTons);

            Console.WriteLine("HS Accomodations/Required: {0}/{1}, Total Fuel Capacity: {2}, Total MSP: {3}, Engineering percentage: {4}, Has Bridge: {5}, Total Required Crew: {6}", TestClass.AccomHSAvailable, TestClass.AccomHSRequirement,
            TestClass.TotalFuelCapacity, TestClass.TotalMSPCapacity, (TestClass.EngineeringHS / TestClass.SizeHS), TestClass.HasBridge, TestClass.TotalRequiredCrew);

            Console.WriteLine("Armor Size: {0}, Cost: {1}", TestClass.ShipArmorDef.size, TestClass.ShipArmorDef.cost);

            Console.WriteLine("Ship Engine Power: {0}, Ship Thermal Signature: {1}, Ship Fuel Use Per Hour: {2}", TestClass.MaxEnginePower, TestClass.MaxThermalSignature, TestClass.MaxFuelUsePerHour);

            Console.WriteLine("Best TH: {0}, BestEM: {1}, Max EM Signature: {2}, Total Cross Section: {3}", TestClass.BestThermalRating, TestClass.BestEMRating, TestClass.MaxEMSignature, TestClass.TotalCrossSection);


            TestClass.AddCrewQuarters(CrewQ, 2);

            StarSystem System1 = SystemGen.CreateSol();

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

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);


            ShipTN testShip = new ShipTN(TestClass, 0, 0, newTG, newFaction, "Test Ship");

            testShip.CrewQuarters[0].isDestroyed = true;

            for (int loop = 0; loop < testShip.CrewQuarters.Count; loop++)
            {
                Console.WriteLine("Crew Quarters {0} isDestroyed:{1}", loop + 1, testShip.CrewQuarters[loop].isDestroyed);
            }

            testShip.CrewQuarters[0].isDestroyed = false;

            Console.WriteLine("Engine Power/Fuel Usage/Thermal Signature/Speed: {0}/{1}/{2}/{3}", testShip.CurrentEnginePower, testShip.CurrentFuelUsePerHour, testShip.CurrentThermalSignature,
                testShip.CurrentSpeed);

            testShip.SetSpeed(1000);

            Console.WriteLine("Engine Power/Fuel Usage/Thermal Signature/Speed: {0}/{1}/{2}/{3}", testShip.CurrentEnginePower, testShip.CurrentFuelUsePerHour, testShip.CurrentThermalSignature,
                testShip.CurrentSpeed);

            Console.WriteLine("Current Crew/Fuel/MSP: {0}/{1}/{2}", testShip.CurrentCrew, testShip.CurrentFuel, testShip.CurrentMSP);

            int CrewSource = 100000;
            float FuelSource = 100000.0f;
            int MSPSource = 100000;

            CrewSource = testShip.Recrew(CrewSource);
            FuelSource = testShip.Refuel(FuelSource);
            MSPSource = testShip.Resupply(MSPSource);

            Console.WriteLine("Current Crew/Fuel/MSP: {0}/{1}/{2} Source: {3}/{4}/{5}", testShip.CurrentCrew, testShip.CurrentFuel, testShip.CurrentMSP, CrewSource, FuelSource, MSPSource);

            Console.WriteLine("Current EM Signature: {0}", testShip.CurrentEMSignature);


            bool isActive = true;
            testShip.SetSensor(testShip.ShipASensor[0], isActive);

            Console.WriteLine("Current EM Signature: {0}", testShip.CurrentEMSignature);

            isActive = false;
            testShip.SetSpeed(1500);
            testShip.SetSensor(testShip.ShipASensor[0], isActive);

            Console.WriteLine("Engine Power/Fuel Usage/Thermal Signature/Speed: {0}/{1}/{2}/{3}", testShip.CurrentEnginePower, testShip.CurrentFuelUsePerHour, testShip.CurrentThermalSignature,
                testShip.CurrentSpeed);
            Console.WriteLine("Current EM Signature: {0}", testShip.CurrentEMSignature);


        }
Esempio n. 12
0
            /// <summary>
            /// Modrate should be updated whenever tonnage is added or when tech is advanced.
            /// </summary>
            /// <param name="CurrentFaction"></param>
            public void UpdateModRate(Faction CurrentFaction)
            {
#warning Modrate needs to be updated on tech advancement. also, does the governor have an effect on mod rate?
                int BuildTech = CurrentFaction.FactionTechLevel[(int)Faction.FactionTechnology.ShipProdRate];
                if (BuildTech > Constants.ShipyardInfo.MaxShipProductionRate)
                    BuildTech = Constants.ShipyardInfo.MaxShipProductionRate;

                float TechAdjustment = (float)Constants.ShipyardInfo.ShipProductionRate[BuildTech] / (float)Constants.ShipyardInfo.ShipProductionRate[0];

                ModRate = (int)Math.Round((Constants.ShipyardInfo.BaseModRate + ((((float)Tonnage - (float)Constants.ShipyardInfo.BaseShipyardTonnage) / (float)Constants.ShipyardInfo.BaseShipyardTonnage) *
                                          Constants.ShipyardInfo.ModRateTonnageMultiplier)) * TechAdjustment);
            }
Esempio n. 13
0
            /// <summary>
            /// How many BP will this shipyard produce for building new ships?
            /// </summary>
            /// <param name="CurrentFaction">Current faction that owns this shipyard</param>
            /// <param name="CurrentPopulation">Current population this shipyard at.</param>
            /// <returns>The build rate for this shipyard.</returns>
            public int CalcShipBuildRate(Faction CurrentFaction, Population CurrentPopulation)
            {
#warning Does not take into effect governor bonus
                int BuildTech = CurrentFaction.FactionTechLevel[(int)Faction.FactionTechnology.ShipProdRate];
                if (BuildTech > Constants.ShipyardInfo.MaxShipProductionRate)
                    BuildTech = Constants.ShipyardInfo.MaxShipProductionRate;
                return Constants.ShipyardInfo.ShipProductionRate[BuildTech];
            }
Esempio n. 14
0
 /// <summary>
 /// Add tonnage and then update the mod rate.
 /// </summary>
 public void AddTonnage(Faction CurrentFaction, int TonsToAdd)
 {
     Tonnage = Tonnage + TonsToAdd;
     UpdateModRate(CurrentFaction);
 }
Esempio n. 15
0
            /// <summary>
            /// Set the activity that this shipyard complex will undertake.
            /// </summary>
            /// <param name="NewActivity">New Activity to perform.</param>
            /// <param name="RetoolTarget">Retool target if any</param>
            /// <param name="CapLimit">Capacity Expansion Limit if any.</param>
            public void SetShipyardActivity(Faction CurrentFaction, Constants.ShipyardInfo.ShipyardActivity NewActivity, ShipClassTN RetoolTarget = null, int CapLimit = -1)
            {
                decimal[] mCost = new decimal[(int)Constants.Minerals.MinerialNames.MinerialCount];
                float DaysInYear = (float)Constants.TimeInSeconds.RealYear / (float)Constants.TimeInSeconds.Day;

                /// <summary>
                /// These are declared here since each switch case is considered to be on the same level of scope and just putting them in the first case doesn't seem quite right.
                /// </summary>
                float YearsOfProduction = 0.0f;
                int TimeToBuild = 0;
                DateTime EstTime;
                TimeSpan TS;

                /// <summary>
                /// If an order for adding a set amount of tons is canceled while in progress, credit the tons that were built to the shipyard.
                /// </summary>
                if(CurrentActivity.Progress != 0.0m && CurrentActivity.Activity != Constants.ShipyardInfo.ShipyardActivity.NoActivity)
                {
                    int TonsToAdd = 0;
                    switch (CurrentActivity.Activity)
                    {
                        case Constants.ShipyardInfo.ShipyardActivity.Add500Tons:
                            TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 500.0f);
                            break;
                        case Constants.ShipyardInfo.ShipyardActivity.Add1000Tons:
                            TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 1000.0f);
                            break;
                        case Constants.ShipyardInfo.ShipyardActivity.Add2000Tons:
                            TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 2000.0f);
                            break;
                        case Constants.ShipyardInfo.ShipyardActivity.Add5000Tons:
                            TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 5000.0f);
                            break;
                        case Constants.ShipyardInfo.ShipyardActivity.Add10000Tons:
                            TonsToAdd = (int)Math.Round((float)CurrentActivity.Progress * 10000.0f);
                            break;
                    }

                    if (TonsToAdd != 0)
                    {
                        AddTonnage(CurrentFaction, Tonnage);
                    }
                }

                switch (NewActivity)
                {
                    case Constants.ShipyardInfo.ShipyardActivity.AddSlipway:
                        decimal TotalSlipwayCost = 0.0m;
                        for (int MineralIterator = 0; MineralIterator < Constants.Minerals.NO_OF_MINERIALS; MineralIterator++)
                        {
                            if (Constants.ShipyardInfo.MineralCostOfExpansion[MineralIterator] != 0)
                            {
                                int Adjustment = 1;
                                if (ShipyardType == Constants.ShipyardInfo.SYType.Naval)
                                    Adjustment = 10;

                                /// <summary>
                                /// Formula for tonnage expansion. This also appears in the constants file for now.
                                /// </summary>
                                decimal value = Constants.ShipyardInfo.MineralCostOfExpansion[MineralIterator] * (Tonnage / Constants.ShipyardInfo.TonnageDenominator) * Slipways * Adjustment;
                                mCost[MineralIterator] = value;
                                TotalSlipwayCost = TotalSlipwayCost + value;
                            }
                        }

                        YearsOfProduction = (float)TotalSlipwayCost / CalcAnnualSYProduction();
                        EstTime = GameState.Instance.GameDateTime;
                        if (YearsOfProduction < Constants.Colony.TimerYearMax)
                        {
                            TimeToBuild = (int)Math.Floor(YearsOfProduction * DaysInYear);
                            TS = new TimeSpan(TimeToBuild, 0, 0, 0);
                            EstTime = EstTime.Add(TS);
                        }

                        CurrentActivity = new ShipyardActivity(NewActivity, TotalSlipwayCost, mCost, EstTime);
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.Add500Tons:
                        SetExpansion(NewActivity, 500, mCost, DaysInYear);
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.Add1000Tons:
                        SetExpansion(NewActivity, 1000, mCost, DaysInYear);
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.Add2000Tons:
                        SetExpansion(NewActivity, 2000, mCost, DaysInYear);
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.Add5000Tons:
                        SetExpansion(NewActivity, 5000, mCost, DaysInYear);
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.Add10000Tons:
                        SetExpansion(NewActivity, 10000, mCost, DaysInYear);
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.Retool:
                        /// <summary>
                        /// One free retool. Hypothetically this shipyard was built with this shipclass in mind.
                        /// </summary>
                        if (AssignedClass == null && RetoolTarget != null)
                        {
                            AssignedClass = RetoolTarget;
                            if (AssignedClass.IsLocked == false)
                                AssignedClass.IsLocked = true;
                        }
                        /// <summary>
                        /// Lengthy retool process as the shipyard converts to build the new vessel.
                        /// </summary>
                        else if(AssignedClass != null && RetoolTarget != null)
                        {
                            /// <summary>
                            /// Caclulate the cost of this retool:
                            /// </summary>
                            decimal CostToRetool = 0.5m * RetoolTarget.BuildPointCost + ((0.25m * RetoolTarget.BuildPointCost) * Slipways);
                            mCost[(int)Constants.Minerals.MinerialNames.Duranium] = CostToRetool / 2.0m;
                            mCost[(int)Constants.Minerals.MinerialNames.Neutronium] = CostToRetool / 2.0m;

                            /// <summary>
                            /// How long will this retool take?
                            /// </summary>
                            YearsOfProduction = (float)CostToRetool / CalcAnnualSYProduction();
                            EstTime = GameState.Instance.GameDateTime;
                            if (YearsOfProduction < Constants.Colony.TimerYearMax)
                            {
                                TimeToBuild = (int)Math.Floor(YearsOfProduction * DaysInYear);
                                TS = new TimeSpan(TimeToBuild, 0, 0, 0);
                                EstTime = EstTime.Add(TS);
                            }
                            CurrentActivity = new ShipyardActivity(NewActivity, CostToRetool, mCost, EstTime, RetoolTarget);

                            if (RetoolTarget.IsLocked == false)
                                RetoolTarget.IsLocked = true;
                        }
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.CapExpansion:
                        CurrentActivity = new ShipyardActivity(NewActivity);
                        break;
                    case Constants.ShipyardInfo.ShipyardActivity.CapExpansionUntilX:
                        if (CapLimit > Tonnage)
                        {
                            SetExpansion(NewActivity, (CapLimit - Tonnage), mCost, DaysInYear);
                            CurrentActivity.CapExpansionLimit = CapLimit;
                        }
                        break;
                }
            }
Esempio n. 16
0
            /// <summary>
            /// Constructor for shipyard information
            /// </summary>
            /// <param name="Type"></param>
            public ShipyardInformation(Faction CurrentFaction, Constants.ShipyardInfo.SYType Type, int Number)
            {
                switch (Type)
                {
                    case Constants.ShipyardInfo.SYType.Commercial:
                        Name = "Commercial Yard #" + Number.ToString();
                        Tonnage = Constants.ShipyardInfo.BaseShipyardTonnage * Constants.ShipyardInfo.NavalToCommercialRatio;
                        break;
                    case Constants.ShipyardInfo.SYType.Naval:
                        Name = "Naval Yard #" + Number.ToString();
                        Tonnage = Constants.ShipyardInfo.BaseShipyardTonnage;
                        break;
                    default:
                        Name = "Unknown Shipyard Type #" + Number.ToString();
                        break;
                }
                
                ShipyardType = Type;
                AssignedClass = null;

                BuildingShips = new BindingList<ShipyardTask>();
                CurrentActivity = new ShipyardActivity();

                Tonnage = Constants.ShipyardInfo.BaseShipyardTonnage;
                Slipways = 1;
                AssignedClass = null;

                UpdateModRate(CurrentFaction);
            }
Esempio n. 17
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]);
            }

        }
Esempio n. 18
0
        public void testEngine()
        {

            Faction newFaction = new Faction(0);

            StarSystem System1 = SystemGen.CreateSol();

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

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);

            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            ts2.ShipEngineDef = new EngineDefTN("3137.6 EP Inertial Fusion Drive", 32, 2.65f, 0.6f, 0.75f, 2, 37, -1.0f);
            ts2.ShipEngineCount = 1;

            EngineTN temp = new EngineTN(ts2.ShipEngineDef);

            ts.ShipEngine = new BindingList<EngineTN>();
            ts.ShipEngine.Add(temp);

            EngineDefTN tst = ts.ShipEngine[0].engineDef;

            Console.WriteLine("Name: {0}", tst.Name);
            Console.WriteLine("EngineBase: {0}, PowerMod: {1}, FuelConMod: {2}, ThermalReduction: {3}, Size: {4},HyperMod: {5}",
                              tst.engineBase, tst.powerMod, tst.fuelConsumptionMod, tst.thermalReduction, tst.size, tst.hyperDriveMod);
            Console.WriteLine("EnginePower: {0}, FuelUsePerHour: {1}", tst.enginePower, tst.fuelUsePerHour);
            Console.WriteLine("EngineSize: {0}, EngineHTK: {1}", tst.size, tst.htk);
            Console.WriteLine("ThermalSignature: {0}, ExpRisk: {1}", tst.thermalSignature, tst.expRisk);
            Console.WriteLine("IsMilitary: {0}", tst.isMilitary);
            Console.WriteLine("Crew: {0}", tst.crew);
            Console.WriteLine("Cost: {0}", tst.cost);
        }
Esempio n. 19
0
        public void testASensor()
        {

            Faction newFaction = new Faction(0);

            StarSystem System1 = SystemGen.CreateSol();

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

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);

            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            ActiveSensorDefTN ASensorDefTest = new ActiveSensorDefTN("Active Search Sensor MR705-R185", 6.0f, 36, 24, 185, false, 1.0f, 1);

            ts2.ShipASensorDef = new BindingList<ActiveSensorDefTN>();
            ts2.ShipASensorCount = new BindingList<ushort>();
            ts2.ShipASensorDef.Add(ASensorDefTest);
            ts2.ShipASensorCount.Add(1);

            ActiveSensorTN ASensorTest = new ActiveSensorTN(ts2.ShipASensorDef[0]);

            ts.ShipASensor = new BindingList<ActiveSensorTN>();
            ts.ShipASensor.Add(ASensorTest);


            ActiveSensorDefTN tst3 = ts.ShipASensor[0].aSensorDef;

            Console.WriteLine("Name: {0}", tst3.Name);
            Console.WriteLine("Size: {0}, HTK: {1}, Hardening: {2}", tst3.size, tst3.htk, tst3.hardening);
            Console.WriteLine("GPS: {0}, Range: {1}", tst3.gps, tst3.maxRange);
            Console.WriteLine("IsMilitary: {0}", tst3.isMilitary);
            Console.WriteLine("Crew: {0}", tst3.crew);
            Console.WriteLine("Cost: {0}", tst3.cost);

            for (ushort loop = 80; loop < 120; loop++)
            {
                Console.WriteLine("Resolution:{0} Detection Range in KM:{1}", loop, tst3.GetActiveDetectionRange(loop, -1));
            }
        }
Esempio n. 20
0
        public void ShipDamageModel()
        {
            DamageValuesTN.init();

            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");

            PlayerFaction1.ShipDesigns[0].AddEngine(PlayerFaction1.ComponentList.Engines[0], 5);
            PlayerFaction1.ShipDesigns[0].AddCrewQuarters(PlayerFaction1.ComponentList.CrewQuarters[0], 5);
            PlayerFaction1.ShipDesigns[0].AddFuelStorage(PlayerFaction1.ComponentList.FuelStorage[0], 5);
            PlayerFaction1.ShipDesigns[0].AddEngineeringSpaces(PlayerFaction1.ComponentList.EngineeringSpaces[0], 5);
            PlayerFaction1.ShipDesigns[0].AddOtherComponent(PlayerFaction1.ComponentList.OtherComponents[0], 5);
            PlayerFaction1.ShipDesigns[0].AddActiveSensor(PlayerFaction1.ComponentList.ActiveSensorDef[0], 5);
            PlayerFaction1.ShipDesigns[0].AddBeamFireControl(PlayerFaction1.ComponentList.BeamFireControlDef[0], 5);
            PlayerFaction1.ShipDesigns[0].AddBeamWeapon(PlayerFaction1.ComponentList.BeamWeaponDef[0], 5);

            PlayerFaction1.ShipDesigns[0].NewArmor("Conventional", 2, 5);

            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);

            ushort Columns = PlayerFaction1.TaskGroups[0].Ships[0].ShipArmor.armorDef.cNum;
            Random Gen = new Random();
            ushort HitLocation = (ushort)Gen.Next(0, Columns);

            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Missile, 4, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);
            HitLocation = (ushort)Gen.Next(0, Columns);
            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Missile, 4, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);
            HitLocation = (ushort)Gen.Next(0, Columns);
            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Missile, 4, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);

            Console.WriteLine("Damage Template:");
            for (int loop = 0; loop < DamageValuesTN.MissileTable[3].damageTemplate.Count; loop++)
            {
                Console.WriteLine("{0} ", DamageValuesTN.MissileTable[3].damageTemplate[loop]);
            }

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

            foreach (KeyValuePair<ushort, ushort> pair in PlayerFaction1.TaskGroups[0].Ships[0].ShipArmor.armorDamage)
            {
                Console.WriteLine("{0} {1} ", pair.Key, pair.Value);
            }

            int DAC = 1;
            for (int loop = 0; loop < PlayerFaction1.TaskGroups[0].Ships[0].ShipClass.ListOfComponentDefs.Count; loop++)
            {
                Console.WriteLine("{0} {1}-{2} {3}", PlayerFaction1.TaskGroups[0].Ships[0].ShipClass.ListOfComponentDefs[loop], DAC,
                    PlayerFaction1.TaskGroups[0].Ships[0].ShipClass.DamageAllocationChart[PlayerFaction1.TaskGroups[0].Ships[0].ShipClass.ListOfComponentDefs[loop]],
                    PlayerFaction1.TaskGroups[0].Ships[0].ComponentDefIndex[loop]);

                DAC = PlayerFaction1.TaskGroups[0].Ships[0].ShipClass.DamageAllocationChart[PlayerFaction1.TaskGroups[0].Ships[0].ShipClass.ListOfComponentDefs[loop]] + 1;
            }

            for (int loop2 = 0; loop2 < PlayerFaction1.TaskGroups[0].Ships[0].ShipComponents.Count; loop2++)
            {
                Console.WriteLine("{0} {1} {2}", loop2, PlayerFaction1.TaskGroups[0].Ships[0].ShipComponents[loop2], PlayerFaction1.TaskGroups[0].Ships[0].ShipComponents[loop2].componentIndex);
            }

            Console.WriteLine("{0} {1} {2} {3} {4} {5}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxEnginePower, PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxThermalSignature,
    PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxFuelUsePerHour, PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxSpeed, PlayerFaction1.TaskGroups[0].Ships[0].CurrentSpeed,
    PlayerFaction1.TaskGroups[0].Ships[0].ShipEngine[2].isDestroyed);

            int test = PlayerFaction1.TaskGroups[0].Ships[0].DestroyComponent(ComponentTypeTN.Engine, 0, 5, 2, Gen);

            Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", test, PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxEnginePower, PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxThermalSignature,
                PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxFuelUsePerHour, PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxSpeed, PlayerFaction1.TaskGroups[0].Ships[0].CurrentSpeed,
                PlayerFaction1.TaskGroups[0].Ships[0].ShipEngine[2].isDestroyed);

            PlayerFaction1.TaskGroups[0].Ships[0].RepairComponent(ComponentTypeTN.Engine, 22);

            Console.WriteLine("{0} {1} {2} {3} {4} {5}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxEnginePower, PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxThermalSignature,
    PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxFuelUsePerHour, PlayerFaction1.TaskGroups[0].Ships[0].CurrentMaxSpeed, PlayerFaction1.TaskGroups[0].Ships[0].CurrentSpeed,
    PlayerFaction1.TaskGroups[0].Ships[0].ShipEngine[2].isDestroyed);
        }
Esempio n. 21
0
        public void TGActiveSortThermalSortTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.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);

            Faction FID = new Faction(0);
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);

            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);

            for (int loop = 0; loop < 5; loop++)
            {
                ShipClassTN test = new ShipClassTN("Ship", FID);
                test.AddCrewQuarters(CrewQ, 2);
                test.AddFuelStorage(FuelT, 2);
                test.AddEngineeringSpaces(EBay, 2);
                test.AddOtherComponent(Bridge, 1);

                int add = 0;
                switch (loop)
                {
                    case 0: add = 2; break;
                    case 1: add = 4; break;
                    case 2: add = 1; break;
                    case 3: add = 5; break;
                    case 4: add = 3; break;
                }
                test.AddEngine(EngDef, (byte)add);

                Console.WriteLine("Speed:{0}", test.MaxSpeed);

                TaskGroup1.AddShip(test,"Test Ship");
                Console.WriteLine("{0} {1}", TaskGroup1, TaskGroup1.Ships[loop].ShipsTaskGroup);
            }

            LinkedListNode<int> AS = TaskGroup1.ActiveSortList.First;
            LinkedListNode<int> ES = TaskGroup1.EMSortList.First;
            LinkedListNode<int> TS = TaskGroup1.ThermalSortList.First;
            for (int loop = 0; loop < 5; loop++)
            {
                Console.Write("AL:{0}, EL:{1}, TL:{2} || Ship{3} AL:{4}, EL:{5} TL:{6} |||", AS.Value, ES.Value, TS.Value, loop, TaskGroup1.Ships[loop].ActiveList.Value,
                                                                                             TaskGroup1.Ships[loop].EMList.Value, TaskGroup1.Ships[loop].ThermalList.Value);


                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", TaskGroup1.Ships[loop].CurrentSpeed, TaskGroup1.Ships[loop].CurrentEnginePower, TaskGroup1.Ships[loop].CurrentThermalSignature, TaskGroup1.Ships[loop].ShipClass.MaxEnginePower,
                    TaskGroup1.Ships[loop].ShipClass.MaxThermalSignature, TaskGroup1.Ships[loop].CurrentFuelUsePerHour, TaskGroup1.Ships[loop].ShipClass.MaxFuelUsePerHour);

                AS = AS.Next;
                ES = ES.Next;
                TS = TS.Next;
            }

            TaskGroup1.Ships[4].CurrentThermalSignature = 500;
            TaskGroup1.SortShipBySignature(TaskGroup1.Ships[4].ThermalList, TaskGroup1.ThermalSortList, 0);

            Console.WriteLine("------------------------");

            AS = TaskGroup1.ActiveSortList.First;
            ES = TaskGroup1.EMSortList.First;
            TS = TaskGroup1.ThermalSortList.First;
            for (int loop = 0; loop < 5; loop++)
            {
                Console.Write("AL:{0}, EL:{1}, TL:{2} || Ship{3} AL:{4}, EL:{5} TL:{6} |||", AS.Value, ES.Value, TS.Value, loop, TaskGroup1.Ships[loop].ActiveList.Value,
                                                                                             TaskGroup1.Ships[loop].EMList.Value, TaskGroup1.Ships[loop].ThermalList.Value);


                Console.WriteLine("{0} {1} {2} {3} {4} {5} {6}", TaskGroup1.Ships[loop].CurrentSpeed, TaskGroup1.Ships[loop].CurrentEnginePower, TaskGroup1.Ships[loop].CurrentThermalSignature, TaskGroup1.Ships[loop].ShipClass.MaxEnginePower,
                    TaskGroup1.Ships[loop].ShipClass.MaxThermalSignature, TaskGroup1.Ships[loop].CurrentFuelUsePerHour, TaskGroup1.Ships[loop].ShipClass.MaxFuelUsePerHour);

                AS = AS.Next;
                ES = ES.Next;
                TS = TS.Next;
            }
        }
Esempio n. 22
0
        /// <summary>
        /// create factions fills in the factions, tgs, and ships. The design for ships should be modified here.
        /// </summary>
        /// <param name="P">Factions</param>
        /// <param name="Sol">Starting starsystem</param>
        /// <param name="factionCount"># of factions</param>
        /// <param name="TGCount"># of tgs</param>
        /// <param name="ShipCount"># of ships</param>
        /// <param name="RNG">"global" rng since it has to be done that way.</param>
        void createFactions(BindingList<Faction> P, StarSystem Sol, int factionCount, int TGCount, int ShipCount, Random RNG)
        {
            for (int loop = 0; loop < factionCount; loop++)
            {
                Faction P1 = new Faction(loop);
                P1.AddNewContactList(Sol);
                P1.AddNewShipDesign("Blucher");

                P1.ShipDesigns[0].AddEngine(P1.ComponentList.Engines[0], 3);
                P1.ShipDesigns[0].AddCrewQuarters(P1.ComponentList.CrewQuarters[0], 1);
                P1.ShipDesigns[0].AddFuelStorage(P1.ComponentList.FuelStorage[0], 1);
                P1.ShipDesigns[0].AddEngineeringSpaces(P1.ComponentList.EngineeringSpaces[0], 1);
                P1.ShipDesigns[0].AddOtherComponent(P1.ComponentList.OtherComponents[0], 1);
                P1.ShipDesigns[0].AddActiveSensor(P1.ComponentList.ActiveSensorDef[0], 1);
                P1.ShipDesigns[0].AddBeamFireControl(P1.ComponentList.BeamFireControlDef[0], 1);
                P1.ShipDesigns[0].AddBeamWeapon(P1.ComponentList.BeamWeaponDef[0], 2);
                P1.ShipDesigns[0].AddReactor(P1.ComponentList.ReactorDef[0], 2);
                P1.ShipDesigns[0].NewArmor("Duranium", 5, 4);


                for (int loop2 = 0; loop2 < TGCount; loop2++)
                {
                    int randx = RNG.Next(0, 100000);
                    int randy = RNG.Next(0, 100000);

                    float wx = ((float)randx / 50000.0f) - 1.0f;
                    float wy = ((float)randy / 50000.0f) - 1.0f;

                    SystemBody Start = new SystemBody(Sol.Stars[0], SystemBody.PlanetType.Terrestrial);
                    Start.Position.X = wx;
                    Start.Position.Y = wy;

                    string ID1 = loop.ToString();

                    string TGName = "P" + ID1 + "TG 01";

                    P1.AddNewTaskGroup(TGName, Start, Sol);

                    for (int loop3 = 0; loop3 < ShipCount; loop3++)
                    {
                        P1.TaskGroups[loop2].AddShip(P1.ShipDesigns[0], "Test Ship");
                        P1.TaskGroups[loop2].Ships[loop3].Refuel(200000.0f);
                        P1.TaskGroups[loop2].SetActiveSensor(loop3, 0, true);
                    }

                }
                P.Add(P1);
            }
        }
Esempio n. 23
0
        public void TGActiveTest()
        {
            EngineDefTN EngDef = new EngineDefTN("25 EP Nuclear Thermal Engine", 5, 1.0f, 1.0f, 1.0f, 1, 5, -1.0f);
            ActiveSensorDefTN ActDef1 = new ActiveSensorDefTN("Search 5M - 5000", 1.0f, 10, 5, 100, false, 1.0f, 1);
            ActiveSensorDefTN ActDef2 = new ActiveSensorDefTN("Search 500k - 1", 1.0f, 10, 5, 1, false, 1.0f, 1);
            ActiveSensorDefTN ActDef3 = new ActiveSensorDefTN("Search 2.2M - 1000", 1.0f, 10, 5, 20, false, 1.0f, 1);
            ActiveSensorDefTN ActDef4 = new ActiveSensorDefTN("Search 7M - 10000", 1.0f, 10, 5, 200, false, 1.0f, 1);

            GeneralComponentDefTN CrewQ = new GeneralComponentDefTN("Crew Quarters", 1.0f, 0, 10.0m, ComponentTypeTN.Crew);
            GeneralComponentDefTN FuelT = new GeneralComponentDefTN("Fuel Storage", 1.0f, 0, 10.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);


            Faction FID = new Faction(0);
            StarSystem System = SystemGen.CreateSol();
            SystemBody planet = new SystemBody(System.Stars[0], SystemBody.PlanetType.Terrestrial);;
            System.Stars[0].Planets.Add(planet);

            TaskGroupTN TaskGroup1 = new TaskGroupTN("Taskforce 001", FID, planet, System);
            for (int loop = 0; loop < 4; loop++)
            {


                ShipClassTN test = new ShipClassTN("Ship", FID);
                test.AddCrewQuarters(CrewQ, 2);
                test.AddFuelStorage(FuelT, 2);
                test.AddEngineeringSpaces(EBay, 2);
                Console.WriteLine("Bridge isn't present: {0} {1}", test.OtherComponents.IndexOf(Bridge), test.HasBridge);
                test.AddOtherComponent(Bridge, 1);
                Console.WriteLine("Bridge is present: {0} {1}", test.OtherComponents.IndexOf(Bridge), test.HasBridge);

                switch (loop)
                {
                    case 0: test.AddActiveSensor(ActDef2, 2);
                        break;
                    case 1: test.AddActiveSensor(ActDef1, 2);
                        break;
                    case 2: test.AddActiveSensor(ActDef3, 2);
                        break;
                    case 3: test.AddActiveSensor(ActDef4, 2);
                        break;
                }

                TaskGroup1.AddShip(test, "Test Ship");

                TaskGroup1.SetActiveSensor(loop, 0, true);
                TaskGroup1.SetActiveSensor(loop, 1, true);
            }

            LinkedListNode<int> EM = TaskGroup1.EMSortList.First;
            for (int loop = 0; loop < 4; loop++)
            {
                Console.WriteLine("{0} {1}", TaskGroup1.Ships[loop].CurrentEMSignature, EM.Value);
                EM = EM.Next;
            }

            for (int loop = 0; loop < Constants.ShipTN.ResolutionMax; loop++)
            {
                Console.WriteLine("{0} | {1}", TaskGroup1.TaskGroupLookUpST[loop], loop);
            }

            TaskGroup1.SetActiveSensor(2, 0, false);
            TaskGroup1.SetActiveSensor(2, 1, false);

            Console.WriteLine("--------------------------------------------");

            EM = TaskGroup1.EMSortList.First;
            for (int loop = 0; loop < 4; loop++)
            {
                Console.WriteLine("{0} {1}", TaskGroup1.Ships[loop].CurrentEMSignature, EM.Value);
                EM = EM.Next;
            }

            for (int loop = 0; loop < Constants.ShipTN.ResolutionMax; loop++)
            {
                Console.WriteLine("{0} | {1}", TaskGroup1.TaskGroupLookUpST[loop], loop);
            }
        }
Esempio n. 24
0
        public void testPSensor()
        {

            Faction newFaction = new Faction(0);

            StarSystem System1 = SystemGen.CreateSol();

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

            TaskGroupTN newTG = new TaskGroupTN("TG", newFaction, System1.Stars[0].Planets[0], System1);

            ShipClassTN ts2 = new ShipClassTN("Test", newFaction);
            ShipTN ts = new ShipTN(ts2, 0, 0, newTG, newFaction, "Test Ship");

            PassiveSensorDefTN PSensorDefTest = new PassiveSensorDefTN("Thermal Sensor TH19-342", 19.0f, 18, PassiveSensorType.Thermal, 1.0f, 1);

            ts2.ShipPSensorDef = new BindingList<PassiveSensorDefTN>();
            ts2.ShipPSensorCount = new BindingList<ushort>();
            ts2.ShipPSensorDef.Add(PSensorDefTest);
            ts2.ShipPSensorCount.Add(1);

            PassiveSensorTN PSensorTest = new PassiveSensorTN(ts2.ShipPSensorDef[0]);

            ts.ShipPSensor = new BindingList<PassiveSensorTN>();
            ts.ShipPSensor.Add(PSensorTest);


            PassiveSensorDefTN tst3 = ts.ShipPSensor[0].pSensorDef;

            Console.WriteLine("Name: {0}", tst3.Name);
            Console.WriteLine("Size: {0}, HTK: {1}, Hardening: {2}", tst3.size, tst3.htk, tst3.hardening);
            Console.WriteLine("Rating: {0}, Range: {1}", tst3.rating, tst3.range);
            Console.WriteLine("IsMilitary: {0}", tst3.isMilitary);
            Console.WriteLine("Crew: {0}", tst3.crew);
            Console.WriteLine("Cost: {0}", tst3.cost);

            for (ushort loop = 80; loop < 120; loop++)
            {
                Console.WriteLine("Signature:{0} Detection Range in KM:{1}", loop, tst3.GetPassiveDetectionRange(loop));
            }
        }
Esempio n. 25
0
        public void FactionSystemTest()
        {
            Faction PlayerFaction1 = new Faction(0);
            Faction PlayerFaction2 = new Faction(1);

            StarSystem System1 = SystemGen.CreateSol();
            StarSystem System2 = SystemGen.CreateSystem("Alpha Centauri");

            SystemBody Start1 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            Start1.Position.X = 1.0;
            Start1.Position.Y = 1.0;


            SystemBody Start2 = new SystemBody(System1.Stars[0], SystemBody.PlanetType.Terrestrial);
            Start2.Position.X = 1.0005;
            Start2.Position.Y = 1.0005;



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

            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].AddActiveSensor(PlayerFaction1.ComponentList.ActiveSensorDef[0], 1);
            PlayerFaction1.ShipDesigns[0].AddPassiveSensor(PlayerFaction1.ComponentList.PassiveSensorDef[0], 1);
            PlayerFaction1.ShipDesigns[0].AddPassiveSensor(PlayerFaction1.ComponentList.PassiveSensorDef[1], 1);

            PlayerFaction2.ShipDesigns[0].AddEngine(PlayerFaction2.ComponentList.Engines[0], 1);
            PlayerFaction2.ShipDesigns[0].AddCrewQuarters(PlayerFaction2.ComponentList.CrewQuarters[0], 2);
            PlayerFaction2.ShipDesigns[0].AddFuelStorage(PlayerFaction2.ComponentList.FuelStorage[0], 2);
            PlayerFaction2.ShipDesigns[0].AddEngineeringSpaces(PlayerFaction2.ComponentList.EngineeringSpaces[0], 2);
            PlayerFaction2.ShipDesigns[0].AddOtherComponent(PlayerFaction2.ComponentList.OtherComponents[0], 1);
            PlayerFaction2.ShipDesigns[0].AddActiveSensor(PlayerFaction2.ComponentList.ActiveSensorDef[0], 1);
            PlayerFaction2.ShipDesigns[0].AddPassiveSensor(PlayerFaction2.ComponentList.PassiveSensorDef[0], 1);
            PlayerFaction2.ShipDesigns[0].AddPassiveSensor(PlayerFaction2.ComponentList.PassiveSensorDef[1], 1);

            PlayerFaction1.AddNewTaskGroup("P1 TG 01", Start1, System1);
            PlayerFaction2.AddNewTaskGroup("P2 TG 01", Start2, 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);


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

            PlayerFaction1.AddNewContactList(System2);
            PlayerFaction2.AddNewContactList(System2);

            PlayerFaction1.TaskGroups[0].SetActiveSensor(0, 0, true);
            PlayerFaction2.TaskGroups[0].SetActiveSensor(0, 0, true);

            GameState.Instance.CurrentSecond = 5;

            Console.WriteLine("Time: 0 {0} {1}", PlayerFaction1.TaskGroups[0].Contact.Position.System.Name, PlayerFaction2.TaskGroups[0].Contact.Position.System.Name);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ThermalDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ThermalDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].EMDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].EMDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ActiveDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ActiveDetection[0]);

            PlayerFaction1.SensorSweep();
            PlayerFaction2.SensorSweep();

            Console.WriteLine("Time: 5 {0} {1}", PlayerFaction1.TaskGroups[0].Contact.Position.System.Name, PlayerFaction2.TaskGroups[0].Contact.Position.System.Name);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ThermalDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ThermalDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].EMDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].EMDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ActiveDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ActiveDetection[0]);

            PlayerFaction1.TaskGroups[0].SetActiveSensor(0, 0, false);
            PlayerFaction2.TaskGroups[0].SetActiveSensor(0, 0, false);

            GameState.Instance.CurrentSecond = 10;

            PlayerFaction1.SensorSweep();
            PlayerFaction2.SensorSweep();

            Console.WriteLine("Time: 10 {0} {1}", PlayerFaction1.TaskGroups[0].Contact.Position.System.Name, PlayerFaction2.TaskGroups[0].Contact.Position.System.Name);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ThermalDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ThermalDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].EMDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].EMDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ActiveDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ActiveDetection[0]);

            PlayerFaction1.TaskGroups[0].SetActiveSensor(0, 0, true);
            PlayerFaction2.TaskGroups[0].SetActiveSensor(0, 0, true);

            //this isn't needed, but also shouldn't crash now that its fixed. to test uncomment this out and run nunit or whatever tester.
            //SystemGen.GenerateJumpPoint(System1);
            //SystemGen.GenerateJumpPoint(System2);

            JumpPoint JP1 = new JumpPoint(System1.Stars[0], 0.1, 0.2);
            System1.JumpPoints.Add(JP1);
            JumpPoint JP2 = new JumpPoint(System2.Stars[0], 0.2, 0.1);
            System2.JumpPoints.Add(JP2);

            System1.JumpPoints[0].Connect = System2.JumpPoints[0];
            System2.JumpPoints[0].Connect = System1.JumpPoints[0];

            SystemPosition newPos = System1.JumpPoints[0].Connect.Position;

            PlayerFaction1.TaskGroups[0].Position.System.SystemContactList.Remove(PlayerFaction1.TaskGroups[0].Contact);
            newPos.System.SystemContactList.Add(PlayerFaction1.TaskGroups[0].Contact);

            PlayerFaction1.TaskGroups[0].Position = newPos;
            PlayerFaction1.TaskGroups[0].Contact.UpdateLocationAfterTransit();

            PlayerFaction2.TaskGroups[0].Position.System.SystemContactList.Remove(PlayerFaction2.TaskGroups[0].Contact);
            newPos.System.SystemContactList.Add(PlayerFaction2.TaskGroups[0].Contact);

            PlayerFaction2.TaskGroups[0].Position = newPos;
            PlayerFaction2.TaskGroups[0].Contact.UpdateLocationAfterTransit();

            GameState.Instance.CurrentSecond = 15;

            PlayerFaction1.SensorSweep();
            PlayerFaction2.SensorSweep();

            Console.WriteLine("Time: 15 {0} {1}", PlayerFaction1.TaskGroups[0].Contact.Position.System.Name, PlayerFaction2.TaskGroups[0].Contact.Position.System.Name);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ThermalDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ThermalDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].EMDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].EMDetection[0]);
            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].ActiveDetection[1], PlayerFaction2.TaskGroups[0].Ships[0].ActiveDetection[0]);
        }
Esempio n. 26
0
        /// <summary>
        /// This function calculates whether a given BFC can intercept a missile
        /// </summary>
        /// <param name="RNG">RNG to use, should be the global one in _SE_</param>
        /// <param name="IncrementDistance">Range to the target missile</param>
        /// <param name="Ordnance">Ordnance we want to shoot at.</param>
        /// <param name="ShipFaction">Faction of the ship this BFC is on.</param>
        /// <param name="Contact">Contact of the taskgroup this BFC is in.</param>
        /// <param name="ShipOn">Ship this BFC is on.</param>
        /// <param name="WeaponsFired">Whether or not a weapon was fired. this is for the recharge list further up</param>
        /// <returns>whether the missile was intercepted.</returns>
        public bool InterceptTarget(Random RNG, int IncrementDistance, OrdnanceTN Ordnance, Faction ShipFaction, SystemContact Contact, ShipTN ShipOn, out bool WeaponsFired)
        {
            WeaponsFired = false;

            float ShipSpeed = ShipOn.CurrentSpeed;

            float track = (float)ShipFaction.BaseTracking;
            if (ShipSpeed > track)
                track = ShipSpeed;
            if (m_oBeamFireControlDef.tracking < track)
                track = m_oBeamFireControlDef.tracking;

            /// <summary>
            /// Throwaway target for point defense purposes.
            /// </summary>
            TargetTN OverrideTarget = new TargetTN(Ordnance.missileGroup);

            float Acc = GetFiringAccuracy(IncrementDistance, (int)track, OverrideTarget);
            int toHit = (int)Math.Floor(Acc * 100.0f);
            int range = (IncrementDistance + 1) * 10000;
            String Range = range.ToString("#,###0");

            foreach (BeamTN LinkedWeapon in m_lLinkedWeapons)
            {
                /// <summary>
                /// Certain weapons will have already fired one or more of their shots, but may still have more available.
                /// </summary>
                bool AcceptPartialFire = (LinkedWeapon.beamDef.componentType == ComponentTypeTN.Rail || LinkedWeapon.beamDef.componentType == ComponentTypeTN.AdvRail ||
                        LinkedWeapon.beamDef.componentType == ComponentTypeTN.Gauss) && (LinkedWeapon.shotsExpended < LinkedWeapon.beamDef.shotCount);

                if (LinkedWeapon.readyToFire() == true || AcceptPartialFire == true)
                {
                    if (LinkedWeapon.beamDef.componentType == ComponentTypeTN.Rail || LinkedWeapon.beamDef.componentType == ComponentTypeTN.AdvRail ||
                        LinkedWeapon.beamDef.componentType == ComponentTypeTN.Gauss)
                    {

                        WeaponsFired = LinkedWeapon.Fire();

                        /// <summary>
                        /// multi-hit weapons will be a little wierd as far as PD goes.
                        /// </summary>
                        if (WeaponsFired == false && AcceptPartialFire == true)
                            WeaponsFired = true;


                        int expended = LinkedWeapon.shotsExpended;
                        int ShotCount = LinkedWeapon.beamDef.shotCount;

                        for (int BeamShotIterator = expended; BeamShotIterator < ShotCount; BeamShotIterator++)
                        {
                            ushort Hit = (ushort)RNG.Next(1, 100);
                            LinkedWeapon.shotsExpended++;

                            if (toHit >= Hit)
                            {
                                String Entry = String.Format("{0} Fired at {1} km and hit.", LinkedWeapon.Name, Range);
                                MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                                   GameState.Instance.LastTimestep, Entry);
                                ShipFaction.MessageLog.Add(Msg);
                                return true;
                            }
                            else
                            {
                                String Entry = String.Format("{0} Fired at {1} km and missed.", LinkedWeapon.Name, Range);
                                MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                                   GameState.Instance.LastTimestep, Entry);
                                ShipFaction.MessageLog.Add(Msg);
                            }
                        }

                    }
                    else
                    {
                        ushort Hit = (ushort)RNG.Next(1, 100);

                        WeaponsFired = LinkedWeapon.Fire();

                        if (toHit >= Hit)
                        {
                            String Entry = String.Format("{0} Fired at {1} km and hit.", LinkedWeapon.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                            return true;
                        }
                        else
                        {
                            String Entry = String.Format("{0} Fired at {1} km and missed.", LinkedWeapon.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                        }
                    }
                }
            }

            foreach (TurretTN LinkedTurret in m_lLinkedTurrets)
            {
                /// <summary>
                /// Double, triple, and quad turrets have multiple shots.
                /// </summary>
                bool AcceptPartialFire = (LinkedTurret.shotsExpended < LinkedTurret.turretDef.totalShotCount);
                if (LinkedTurret.readyToFire() == true || AcceptPartialFire == true)
                {
                    WeaponsFired = LinkedTurret.Fire();

                    /// <summary>
                    /// multi-hit weapons will be a little wierd as far as PD goes.
                    /// </summary>
                    if (WeaponsFired == false && AcceptPartialFire == true)
                        WeaponsFired = true;

                    int expended = LinkedTurret.shotsExpended;
                    int ShotCount = LinkedTurret.turretDef.totalShotCount;

                    for (int TurretShotIterator = expended; TurretShotIterator < ShotCount; TurretShotIterator++)
                    {
                        ushort Hit = (ushort)RNG.Next(1, 100);
                        LinkedTurret.shotsExpended++;

                        if (toHit >= Hit)
                        {
                            String Entry = String.Format("{0} Fired at {1} km and hit.", LinkedTurret.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                            return true;
                        }
                        else
                        {
                            String Entry = String.Format("{0} Fired at {1} km and missed.", LinkedTurret.Name, Range);
                            MessageEntry Msg = new MessageEntry(MessageEntry.MessageType.FiringHit, Contact.Position.System, Contact, GameState.Instance.GameDateTime,
                                                               GameState.Instance.LastTimestep, Entry);
                            ShipFaction.MessageLog.Add(Msg);
                        }
                    }
                }
            }

            return false;
        }
Esempio n. 27
0
        public void ColonyOrdersTest()
        {
            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");

            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].AddColonyBay(PlayerFaction1.ComponentList.ColonyBayDef[0], 1);
            PlayerFaction1.ShipDesigns[0].AddCargoHandlingSystem(PlayerFaction1.ComponentList.CargoHandleSystemDef[0], 1);

            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].CivilianPopulation = 5.0f;
            System1.Stars[0].Planets[1].Populations[0].CivilianPopulation = 1.0f;

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

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

            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);
            }

            Console.WriteLine("Population on P1 and P2:{0} {1}", System1.Stars[0].Planets[0].Populations[0].CivilianPopulation,
    System1.Stars[0].Planets[1].Populations[0].CivilianPopulation);
        }
Esempio n. 28
0
        public void MesonMicrowaveShieldTest()
        {
            DamageValuesTN.init();

            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");

            PlayerFaction1.ShipDesigns[0].AddEngine(PlayerFaction1.ComponentList.Engines[0], 5);
            PlayerFaction1.ShipDesigns[0].AddCrewQuarters(PlayerFaction1.ComponentList.CrewQuarters[0], 5);
            PlayerFaction1.ShipDesigns[0].AddFuelStorage(PlayerFaction1.ComponentList.FuelStorage[0], 5);
            PlayerFaction1.ShipDesigns[0].AddEngineeringSpaces(PlayerFaction1.ComponentList.EngineeringSpaces[0], 5);
            PlayerFaction1.ShipDesigns[0].AddOtherComponent(PlayerFaction1.ComponentList.OtherComponents[0], 5);
            PlayerFaction1.ShipDesigns[0].AddActiveSensor(PlayerFaction1.ComponentList.ActiveSensorDef[0], 1);
            PlayerFaction1.ShipDesigns[0].AddShield(PlayerFaction1.ComponentList.ShieldDef[0], 10);

            PlayerFaction1.ShipDesigns[0].NewArmor("Conventional", 2, 5);

            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);

            PlayerFaction1.TaskGroups[0].Ships[0].SetShields(true);

            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax);

            PlayerFaction1.TaskGroups[0].Ships[0].RechargeShields(300);

            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax);

            ushort Columns = PlayerFaction1.TaskGroups[0].Ships[0].ShipArmor.armorDef.cNum;
            Random Gen = new Random();
            ushort HitLocation = (ushort)Gen.Next(0, Columns);

            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Microwave, 1, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);

            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax);

            HitLocation = (ushort)Gen.Next(0, Columns);

            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Microwave, 1, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);

            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax);

            HitLocation = (ushort)Gen.Next(0, Columns);

            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Microwave, 1, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);

            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax);

            HitLocation = (ushort)Gen.Next(0, Columns);

            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Microwave, 1, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);

            Console.WriteLine("{0} {1} {2}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax,
                                             PlayerFaction1.TaskGroups[0].Ships[0].DestroyedComponents.Count);

            PlayerFaction1.TaskGroups[0].Ships[0].RechargeShields(300);

            Console.WriteLine("{0} {1}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax);

            HitLocation = (ushort)Gen.Next(0, Columns);

            PlayerFaction1.TaskGroups[0].Ships[0].OnDamaged(DamageTypeTN.Meson, 1, HitLocation, PlayerFaction1.TaskGroups[0].Ships[0]);

            Console.WriteLine("{0} {1} {2}", PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPool, PlayerFaction1.TaskGroups[0].Ships[0].CurrentShieldPoolMax,
                                 PlayerFaction1.TaskGroups[0].Ships[0].DestroyedComponents.Count);
        }
Esempio n. 29
0
        /// <summary>
        /// Constructor for the MV, Factions should already be set, and setting the current faction and component  should have those set when
        /// the panel is created.
        /// </summary>
        public ComponentsViewModel()
        {
            Factions = GameState.Instance.Factions;
            RPTechs = GameState.Instance.CompResearchTechs;

            if (Factions == null)
            {
                return;
            }

            _CurrnetFaction = Factions[0];
            _CurrnetComponent = Components.ActiveMFC;

        }
Esempio n. 30
0
        /// <summary>
        /// list of legal orders a taskgroup or unit can use againsed this entity ie when this entity is the target.
        /// </summary>
        /// <param name="faction"></param>
        /// <returns></returns>
        public virtual List<Constants.ShipTN.OrderType> LegalOrders(Faction faction)
        {
            List<Constants.ShipTN.OrderType> legalOrders = new List<Constants.ShipTN.OrderType>();
            legalOrders.AddRange(_legalOrders);

            return legalOrders;
        }