public EconomicsViewModel()
        {
            Factions = GameState.Instance.Factions;

            if (Factions == null)
            {
                return;
            }

            CurrentFaction = Factions.FirstOrDefault();

            if (Populations != null)
            {
                CurrentPopulation = Populations.FirstOrDefault();
            }
        }
Exemple #2
0
        /// <summary>
        /// Tree view input handling
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PopulationTreeView_Input(object sender, EventArgs e)
        {
            if (m_oSummaryPanel.PopulationTreeView.SelectedNode != null)
            {
                if (TreeViewDictionary.ContainsKey(m_oSummaryPanel.PopulationTreeView.SelectedNode.Name) == true)
                {
                    m_oCurrnetPopulation = TreeViewDictionary[m_oSummaryPanel.PopulationTreeView.SelectedNode.Name];

                    if (m_oCurrnetPopulation.Installations[(int)Installation.InstallationType.NavalShipyardComplex].Number >= 1.0f)
                    {
                        CurrentSYInfo = m_oCurrnetPopulation.Installations[(int)Installation.InstallationType.NavalShipyardComplex].SYInfo[0];
                    }
                    else if (m_oCurrnetPopulation.Installations[(int)Installation.InstallationType.CommercialShipyard].Number >= 1.0f)
                    {
                        CurrentSYInfo = m_oCurrnetPopulation.Installations[(int)Installation.InstallationType.CommercialShipyard].SYInfo[0];
                    }
                    else
                    {
                        CurrentSYInfo = null;
                    }

                    RefreshPanels();
                }
            }
        }
Exemple #3
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);
        }
Exemple #4
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]);
            }

        }
Exemple #5
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);
        }
        /// <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;
        }
 /// <summary>
 /// Now I want a list of the ships of a specific class that are in orbit. these will potentially be targets for repair, refit, or scrap operations.
 /// </summary>
 /// <param name="CurrentFaction">Economics handler selected faction.</param>
 /// <param name="CurrentPopulation">Population from the economics handler.</param>
 /// <param name="CurrentShipClass">Shipclass selected via the RepairRefitScrapClassComboBox</param>
 /// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param>
 private static void GetShipsOfClassInOrbit(Faction CurrentFaction, Population CurrentPopulation, ShipClassTN CurrentShipClass, ref BindingList<ShipTN> ShipsOfClassInOrbit)
 {
     ShipsOfClassInOrbit.Clear();
     foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
     {
         if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
         {
             foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships)
             {
                 if (CurrentShip.ShipClass == CurrentShipClass)
                     ShipsOfClassInOrbit.Add(CurrentShip);
             }
         }
     }
 }
        /// <summary>
        /// Build the list of shipyard tasks at this population.
        /// </summary>
        /// <param name="m_oSummaryPanel"></param>
        /// <param name="CurrentFaction"></param>
        /// <param name="CurrentPopulation"></param>
        public static void RefreshShipyardTasksTab(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation)
        {

            List<Installation.ShipyardInformation.ShipyardTask> SortedList = CurrentPopulation.ShipyardTasks.Keys.ToList().OrderBy(o => o.Priority).ToList();

            int row = 0;
            foreach (Installation.ShipyardInformation.ShipyardTask Task in SortedList)
            {
                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Visible = true;

                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[0].Value = CurrentPopulation.ShipyardTasks[Task].Name;

                String Entry = "N/A";

                switch (Task.CurrentTask)
                {
                    case Constants.ShipyardInfo.Task.Construction:
                        Entry = String.Format("Build {0}", Task.ConstructRefitTarget);
                        break;
                    case Constants.ShipyardInfo.Task.Repair:
                        Entry = String.Format("Repair {0}", Task.CurrentShip);
                        break;
                    case Constants.ShipyardInfo.Task.Refit:
                        Entry = String.Format("Refit {0} to {1}", Task.CurrentShip, Task.ConstructRefitTarget);
                        break;
                    case Constants.ShipyardInfo.Task.Scrap:
                        Entry = String.Format("Scrap {0}", Task.CurrentShip);
                        break;
                }

                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[1].Value = Entry;

                switch (Task.CurrentTask)
                {
                    case Constants.ShipyardInfo.Task.Construction:
                        Entry = String.Format("{0}", Task.Title);
                        break;
                    case Constants.ShipyardInfo.Task.Repair:
                        Entry = String.Format("{0}", Task.CurrentShip);
                        break;
                    case Constants.ShipyardInfo.Task.Refit:
                        Entry = String.Format("{0}", Task.CurrentShip);
                        break;
                    case Constants.ShipyardInfo.Task.Scrap:
                        Entry = String.Format("{0}", Task.CurrentShip);
                        break;
                }

                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[2].Value = Entry;

                String ProgString = String.Format("{0:N2}", (Task.Progress * 100.0m));

                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[3].Value = ProgString;
                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[4].Value = Task.AssignedTaskGroup;
                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[5].Value = Task.CompletionDate.ToShortDateString();
                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[6].Value = Task.ABR;

                if (Task.IsPaused() == true)
                    m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[7].Value = "Paused";
                else
                    m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Cells[7].Value = Task.Priority;


                row++;

                if (row == MaxShipyardTaskRows)
                {
                    using (DataGridViewRow NewRow = new DataGridViewRow())
                    {
                        // setup row height. note that by default they are 22 pixels in height!
                        NewRow.Height = 18;
                        NewRow.Visible = false;
                        m_oSummaryPanel.ShipyardTaskDataGrid.Rows.Add(NewRow);
                    }
                    MaxShipyardTaskRows++;
                }
            }

            /// <summary>
            /// Any rows that aren't being used should be set to invisible. They will still have data from previous ship tasks that I don't care to clear out since the user can't see the rows anyway.
            /// </summary>
            for (int rowIterator = row; row < MaxShipyardTaskRows; row++)
            {
                m_oSummaryPanel.ShipyardTaskDataGrid.Rows[row].Visible = false;
            }
        }
 /// <summary>
 /// Initialize the Shipyard tab
 /// </summary>
 /// <param name="m_oSummaryPanel">The summary panel from the economics handler.</param>
 public static void BuildShipyardTab(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, BindingList<ShipClassTN> RetoolTargets)
 {
     MaxShipyardRows = 38;
     MaxShipyardTaskRows = 38;
     //m_oSummaryPanel.
     //Populate the datagrid
     //build the SYC Groupbox
     //build the create task groupbox
     //listen to the buttons
     BuildShipyardDataGrid(m_oSummaryPanel);
     BuildSYCGroupBox(m_oSummaryPanel, CurrentFaction, CurrentPopulation, RetoolTargets);
     BuildSYTaskGroupBox(m_oSummaryPanel, CurrentFaction, CurrentPopulation);
 }
 /// <summary>
 /// This function produces a list of ships that have taken Armor or component damage. repair will need this.
 /// </summary>
 /// <param name="CurrentPopulation">Population selected by the economics handler.</param>
 /// <param name="DamagedShipsInOrbit">list of damaged ships this function will produce.</param>
 private static void GetDamagedShipList(Faction CurrentFaction, Population CurrentPopulation, ref BindingList<ShipTN> DamagedShipList)
 {
     DamagedShipList.Clear();
     foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
     {
         if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
         {
             foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships)
             {
                 /// <summary>
                 /// Either a component is destroyed or the ship has taken armour damage.
                 /// </summary>
                 if (CurrentShip.DestroyedComponents.Count != 0 || CurrentShip.ShipArmor.isDamaged == true)
                     DamagedShipList.Add(CurrentShip);
             }
         }
     }
 }
Exemple #11
0
        /// <summary>
        /// Constructor for Population related orders
        /// </summary>
        /// <param name="TypeOrder">Type</param>
        /// <param name="SecondaryOrder">Any secondary order specification such as installation type.</param>
        /// <param name="TertiaryOrder"> Any Tertiary order such as limits.</param>
        /// <param name="Delay">Delay in seconds before performing this order.</param>
        /// <param name="PopOrder">The Population in question.</param>
        public Order(Constants.ShipTN.OrderType TypeOrder, int SecondaryOrder, int TertiaryOrder, int Delay, Population PopOrder)
        {
            TypeOf = TypeOrder;
            Target = PopOrder;
            Secondary = SecondaryOrder;
            Tertiary = TertiaryOrder;
            Pop = PopOrder;
            OrderDelay = Delay;


            OrderTimeRequirement = -1;

            Name = TypeOrder.ToString() + " " + PopOrder.Name.ToString();
        }
Exemple #12
0
        /// <summary>
        /// Unloads ordnance to a population.
        /// </summary>
        /// <param name="pop">planetary stockpile to put missiles in.</param>
        public void UnloadOrdnance(Population pop)
        {
            foreach (KeyValuePair<OrdnanceDefTN, int> SOPair in ShipOrdnance)
            {
                pop.LoadMissileToStockpile(SOPair.Key, SOPair.Value);
            }

            ShipOrdnance.Clear();
        }
Exemple #13
0
        /// <summary>
        /// Loads a missile from the specified series on Population pop into the ship.
        /// </summary>
        /// <param name="Series">Series of missile to search through</param>
        /// <param name="pop">Population stockpile.</param>
        /// <param name="SCValue">ShipClass Preferred Ordnance #</param>
        /// <param name="SOValue">Current Ship Ordnance #</param>
        public void LoadMissileFromPopulation(OrdnanceSeriesTN Series, Population pop, int SCValue, int SOValue)
        {
            for (int loop = (Series.missilesInSeries.Count - 1); loop >= 0; loop--)
            {
                if (pop.MissileStockpile.ContainsKey(Series.missilesInSeries[loop]))
                {
                    int SpaceAvailable = CurrentMagazineCapacityMax - CurrentMagazineCapacity;
                    int MissileReq = ((SCValue - SOValue) * (int)Math.Ceiling(Series.missilesInSeries[loop].size));


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

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

                        CurrentMagazineCapacity = CurrentMagazineCapacity + load;

                        MissilesAvailable = MissilesAvailable - load;

                        if (MissilesAvailable > 0)
                        {
                            /// <summary>
                            /// Magazines are all filled and cannot accomodate remaining missiles. put the extras back in the stockpile.
                            /// </summary>
                            pop.LoadMissileToStockpile(Series.missilesInSeries[loop], MissilesAvailable);
                            return;
                        }
                    }
                }
            }
        }
Exemple #14
0
        /// <summary>
        /// Loads ordnance to this ship from a population.
        /// </summary>
        /// <param name="pop">planetary stockpile to take missiles from</param>
        public void LoadOrdnance(Population pop)
        {
            if (ShipClass.PreferredOrdnanceSize == 0 || CurrentMagazineCapacity == ShipClass.PreferredOrdnanceSize)
            {
                return;
            }
            else
            {
                foreach (KeyValuePair<OrdnanceDefTN, int> SCPair in ShipClass.ShipClassOrdnance)
                {
                    OrdnanceSeriesTN Series = SCPair.Key.ordSeries;

                    if (ContainsMissileOfSeries(Series) == 0)
                    {
                        LoadMissileFromPopulation(Series, pop, SCPair.Value, 0);
                    }
                    else
                    {
                        foreach (KeyValuePair<OrdnanceDefTN, int> SOPair in ShipOrdnance)
                        {
                            if (SOPair.Key.ordSeries == Series)
                            {
                                if (SOPair.Value == SCPair.Value)
                                {
                                    /// <summary>
                                    /// This missile is loaded properly.
                                    /// </summary>
                                    break;
                                }
                                else
                                {
                                    /// <summary>
                                    /// need to load from the population.
                                    /// </summary>
                                    LoadMissileFromPopulation(Series, pop, SCPair.Value, SOPair.Value);

                                } //end else
                            } // end if SOPair.Key.ordSeries
                        } // end foreach
                    }


                }
            }
        }
        /// <summary>
        /// Every task will cost resources, and this program will populate the required resources listbox.
        /// </summary>
        /// <param name="m_oSummaryPanel">Panel the economics handler will pass to us</param>
        /// <param name="CurrentFaction">Current Faction</param>
        /// <param name="CurrentPopulation">Currently selected population</param>
        /// <param name="SYInfo">Current Shipyard</param>
        /// <param name="Retool">Retool target if any</param>
        /// <param name="CapLimit">Cap expansion limit if any</param>
        public static void BuildSYCRequiredMinerals(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, Installation.ShipyardInformation SYInfo,
                                                    BindingList<ShipClassTN> PotentialRetoolTargets)
        {
            if (m_oSummaryPanel.SYCTaskTypeComboBox.SelectedIndex != -1  && SYInfo != null)
            {
                m_oSummaryPanel.SYCRequiredMaterialsListBox.Items.Clear();
                Constants.ShipyardInfo.ShipyardActivity Activity = (Constants.ShipyardInfo.ShipyardActivity)m_oSummaryPanel.SYCTaskTypeComboBox.SelectedIndex;

                if (Activity != Constants.ShipyardInfo.ShipyardActivity.CapExpansion && Activity != Constants.ShipyardInfo.ShipyardActivity.NoActivity)
                {
                    Installation.ShipyardInformation CostPrototyper = new Installation.ShipyardInformation(CurrentFaction, SYInfo.ShipyardType, 1);
                    CostPrototyper.Tonnage = SYInfo.Tonnage;
                    CostPrototyper.Slipways = SYInfo.Slipways;
                    CostPrototyper.ModRate = SYInfo.ModRate;
                    CostPrototyper.AssignedClass = SYInfo.AssignedClass;
                    ShipClassTN RetoolTarget = null;
                    if (PotentialRetoolTargets.Count != 0 && m_oSummaryPanel.NewShipClassComboBox.SelectedIndex != -1)
                    {
                        RetoolTarget = PotentialRetoolTargets[m_oSummaryPanel.NewShipClassComboBox.SelectedIndex];
                    }
                    int NewCapLimit = -1;
                    bool r = Int32.TryParse(m_oSummaryPanel.ExpandCapUntilXTextBox.Text, out NewCapLimit);

                    CostPrototyper.SetShipyardActivity(CurrentFaction, Activity, RetoolTarget, NewCapLimit);

                    for (int MineralIterator = 0; MineralIterator < Constants.Minerals.NO_OF_MINERIALS; MineralIterator++)
                    {

                        if (CostPrototyper.CurrentActivity.minerialsCost[MineralIterator] != 0.0m)
                        {
                            string FormattedMineralTotal = CostPrototyper.CurrentActivity.minerialsCost[MineralIterator].ToString("#,##0");

                            String CostString = String.Format("{0} {1} ({2})", (Constants.Minerals.MinerialNames)MineralIterator, FormattedMineralTotal, CurrentPopulation.Minerials[MineralIterator]);
                            m_oSummaryPanel.SYCRequiredMaterialsListBox.Items.Add(CostString);
                        }
                    }

                    m_oSummaryPanel.SYCBuildCostTextBox.Text = CostPrototyper.CurrentActivity.CostOfActivity.ToString();

                    float YearsOfProduction = (float)CostPrototyper.CurrentActivity.CostOfActivity / CostPrototyper.CalcAnnualSYProduction();
                    if (YearsOfProduction < Constants.Colony.TimerYearMax)
                    {
                        m_oSummaryPanel.SYCCompletionDateTextBox.Text = CostPrototyper.CurrentActivity.CompletionDate.ToShortDateString();
                    }
                    else
                    {
                        m_oSummaryPanel.SYCCompletionDateTextBox.Text = "N/A";
                    }

                    if ((Activity == Constants.ShipyardInfo.ShipyardActivity.Retool && RetoolTarget == null) ||
                        (Activity == Constants.ShipyardInfo.ShipyardActivity.CapExpansionUntilX && (r == false || (NewCapLimit <= SYInfo.Tonnage))))
                    {
                        m_oSummaryPanel.SYCCompletionDateTextBox.Text = "N/A";
                        m_oSummaryPanel.SYCRequiredMaterialsListBox.Items.Clear();
                    }

                    /// <summary>
                    /// This retool is free. or not necessary.
                    /// </summary>
                    if (Activity == Constants.ShipyardInfo.ShipyardActivity.Retool && ((RetoolTarget != null && SYInfo.AssignedClass == null) || RetoolTarget == SYInfo.AssignedClass))
                    {
                        m_oSummaryPanel.SYCBuildCostTextBox.Text = "N/A";
                        m_oSummaryPanel.SYCCompletionDateTextBox.Text = "N/A";
                        m_oSummaryPanel.SYCRequiredMaterialsListBox.Items.Clear();
                    }
                }
                else
                {
                    m_oSummaryPanel.SYCBuildCostTextBox.Text = "N/A";
                    m_oSummaryPanel.SYCCompletionDateTextBox.Text = "N/A";
                    m_oSummaryPanel.SYCRequiredMaterialsListBox.Items.Clear();
                }
            }
        }
        /// <summary>
        /// Refresh the shipyard tab.
        /// </summary>
        /// <param name="m_oSummaryPanel">The summary panel from the economics handler.</param>
        /// <param name="EligibleClassList">List of shipclasses that this shipyard can produce.</param>
        /// <param name="DamagedShipList">List of damaged ships in orbit.</param>
        /// <param name="ClassesInOrbit">List of shipclasses in orbit around CurrentPopulation.</param>
        /// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param>
        public static void RefreshShipyardTab(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, Installation.ShipyardInformation SYInfo,
                                              BindingList<ShipClassTN> RetoolTargets, ref BindingList<ShipClassTN> EligibleClassList, ref BindingList<ShipTN> DamagedShipList, 
                                              ref BindingList<ShipClassTN> ClassesInOrbit, ref BindingList<ShipTN> ShipsOfClassInOrbit)
        {
            /// <summary>
            /// Yeah, just going to constantly declare new variables to pass these along...
            /// </summary>
            ShipsOfClassInOrbit = new BindingList<ShipTN>();
            EligibleClassList = new BindingList<ShipClassTN>();
            DamagedShipList = new BindingList<ShipTN>();
            ClassesInOrbit = new BindingList<ShipClassTN>();

            if (CurrentFaction != null && CurrentPopulation != null && SYInfo != null)
            {
                RefreshShipyardDataGrid(m_oSummaryPanel, CurrentFaction, CurrentPopulation);
                RefreshSYCGroupBox(m_oSummaryPanel, CurrentFaction, CurrentPopulation, SYInfo, RetoolTargets);
                BuildSYCRequiredMinerals(m_oSummaryPanel, CurrentFaction, CurrentPopulation, SYInfo, RetoolTargets);
                RefreshSYTaskGroupBox(m_oSummaryPanel, CurrentFaction, CurrentPopulation, SYInfo, ref EligibleClassList, ref DamagedShipList, ref ClassesInOrbit,
                                                 ref ShipsOfClassInOrbit);
                BuildSYTRequiredMinerals(m_oSummaryPanel, CurrentFaction, CurrentPopulation, SYInfo, EligibleClassList, DamagedShipList, ClassesInOrbit,
                                                 ShipsOfClassInOrbit);

                String Entry = String.Format("Shipyard Complex Activity({0})", SYInfo.Name);
                m_oSummaryPanel.ShipyardTaskGroupBox.Text = Entry;

                Entry = String.Format("Create Task({0})", SYInfo.Name);
                m_oSummaryPanel.ShipyardCreateTaskGroupBox.Text = Entry;

                RefreshShipyardTasksTab(m_oSummaryPanel, CurrentFaction, CurrentPopulation);
            }
        }
        /// <summary>
        /// Build the Shipyard task required minerals box.
        /// </summary>
        /// <param name="m_oSummaryPanel">Panel from the economics handler</param>
        /// <param name="CurrentFaction">Currently selected faction.</param>
        /// <param name="CurrentPopulation">Currently selected population</param>
        /// <param name="SYInfo">Currently selected shipyard on currently selected population belonging to currently selected faction</param>
        /// <param name="EligibleClassList">List of shipclasses that this shipyard can produce.</param>
        /// <param name="DamagedShipList">List of damaged ships in orbit.</param>
        /// <param name="ClassesInOrbit">List of shipclasses in orbit around CurrentPopulation.</param>
        /// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param> 
        public static void BuildSYTRequiredMinerals(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, Installation.ShipyardInformation SYInfo,
                                                    BindingList<ShipClassTN> EligibleClassList, BindingList<ShipTN> DamagedShipList, BindingList<ShipClassTN> ClassesInOrbit,
                                                    BindingList<ShipTN> ShipsOfClassInOrbit)
        {
            if (m_oSummaryPanel.SYTaskTypeComboBox.SelectedIndex != -1 && m_oSummaryPanel.SYTaskGroupComboBox.SelectedIndex != -1 && SYInfo != null &&
                (m_oSummaryPanel.SYNewClassComboBox.SelectedIndex != -1 || m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex != -1))
            {
                m_oSummaryPanel.ShipRequiredMaterialsListBox.Items.Clear();

                Installation.ShipyardInformation CostPrototyper = new Installation.ShipyardInformation(CurrentFaction, SYInfo.ShipyardType,1);
                CostPrototyper.Tonnage = SYInfo.Tonnage;
                CostPrototyper.Slipways = SYInfo.Slipways;
                CostPrototyper.ModRate = SYInfo.ModRate;
                CostPrototyper.AssignedClass = SYInfo.AssignedClass;

                ShipTN CurrentShip = null;
                ShipClassTN ConstructRefit = null;
                TaskGroupTN TargetTG = null;
                int TGIndex = -1;

                /// <summary>
                /// I'm not storing a faction only list of taskgroups in orbit anywhere, so lets calculate that here.
                /// </summary>
                foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
                {
                    if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
                    {
                        if (TGIndex == m_oSummaryPanel.SYTaskGroupComboBox.SelectedIndex)
                        {
                            TargetTG = CurrentTaskGroup;
                            break;
                        }
                        TGIndex++;
                    }
                }

                /// <summary>
                /// No TG was found so create one, the shipyard will want a tg in any event.
                /// </summary>
                if (TGIndex == -1)
                {
                    CurrentFaction.AddNewTaskGroup("Shipyard TG", CurrentPopulation.Planet, CurrentPopulation.Planet.Position.System);

                    /// <summary>
                    /// Run this loop again as a different faction could have a taskgroup in orbit.
                    /// </summary>
                    foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
                    {
                        if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
                        {
                            TGIndex++;
                            if (TGIndex == m_oSummaryPanel.SYTaskGroupComboBox.SelectedIndex)
                            {
                                TargetTG = CurrentTaskGroup;
                                break;
                            }
                        }
                    }
                }

                Constants.ShipyardInfo.Task SYITask = (Constants.ShipyardInfo.Task)m_oSummaryPanel.SYTaskTypeComboBox.SelectedIndex;


                int BaseBuildRate = SYInfo.CalcShipBuildRate(CurrentFaction, CurrentPopulation);

                if ((int)SYITask != -1)
                {
                    switch (SYITask)
                    {
                        case Constants.ShipyardInfo.Task.Construction:
                            int newShipIndex = m_oSummaryPanel.SYNewClassComboBox.SelectedIndex;
                            if (newShipIndex != -1 && EligibleClassList.Count > newShipIndex)
                            {
                                ConstructRefit = EligibleClassList[newShipIndex];
                            }
                            break;
                        case Constants.ShipyardInfo.Task.Repair:
                            int CurrentShipIndex = m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex;
                            if (CurrentShipIndex != -1 && DamagedShipList.Count > CurrentShipIndex)
                            {
                                CurrentShip = DamagedShipList[CurrentShipIndex];
                            }
                            break;
                        case Constants.ShipyardInfo.Task.Refit:
                            newShipIndex = m_oSummaryPanel.SYNewClassComboBox.SelectedIndex;
                            if (newShipIndex != -1 && EligibleClassList.Count > newShipIndex)
                            {
                                ConstructRefit = EligibleClassList[newShipIndex];
                            }

                            CurrentShipIndex = m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex;
                            if (CurrentShipIndex != -1 && ShipsOfClassInOrbit.Count > CurrentShipIndex)
                            {
                                CurrentShip = ShipsOfClassInOrbit[CurrentShipIndex];
                            }
                            break;
                        case Constants.ShipyardInfo.Task.Scrap:
                            CurrentShipIndex = m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex;
                            if (CurrentShipIndex != -1 && ShipsOfClassInOrbit.Count > CurrentShipIndex)
                            {
                                CurrentShip = ShipsOfClassInOrbit[CurrentShipIndex];
                            }
                            break;
                    }

                    /// <summary>
                    /// Faction swapping can cause some problems.
                    /// </summary>
                    if (CurrentShip == null && ConstructRefit == null)
                        return;

                    Installation.ShipyardInformation.ShipyardTask NewTask = new Installation.ShipyardInformation.ShipyardTask(CurrentShip, SYITask, TargetTG, BaseBuildRate, m_oSummaryPanel.SYShipNameTextBox.Text, ConstructRefit);
                    CostPrototyper.BuildingShips.Add(NewTask);

                    m_oSummaryPanel.SYTaskCostTextBox.Text = CostPrototyper.BuildingShips[0].Cost.ToString();
                    m_oSummaryPanel.SYTaskCompletionDateTextBox.Text = CostPrototyper.BuildingShips[0].CompletionDate.ToShortDateString();

                    for (int MineralIterator = 0; MineralIterator < Constants.Minerals.NO_OF_MINERIALS; MineralIterator++)
                    {

                        if (CostPrototyper.BuildingShips[0].minerialsCost[MineralIterator] != 0.0m)
                        {
                            string FormattedMineralTotal = CostPrototyper.BuildingShips[0].minerialsCost[MineralIterator].ToString("#,##0");

                            String CostString = String.Format("{0} {1} ({2})", (Constants.Minerals.MinerialNames)MineralIterator, FormattedMineralTotal, CurrentPopulation.Minerials[MineralIterator]);
                            m_oSummaryPanel.ShipRequiredMaterialsListBox.Items.Add(CostString);
                        }
                    }
                }
            }
            else
            {
                /// <summary>
                /// There is no cost to calculate so print this instead.
                /// </summary>
                m_oSummaryPanel.SYTaskCostTextBox.Text = "N/A";
                m_oSummaryPanel.SYTaskCompletionDateTextBox.Text = "N/A";
                m_oSummaryPanel.ShipRequiredMaterialsListBox.Items.Clear();
            }
        }
        /// <summary>
        /// Need an updater function for this groupbox since the retool list can and will change.
        /// </summary>
        /// <param name="m_oSummaryPanel">Panel from economics</param>
        /// <param name="CurrentFaction">Current Faction</param>
        /// <param name="CurrentPopulation">Current Population</param>
        /// <param name="SYInfo">Shipyard information for the selected shipyard.</param>
        /// <param name="RetoolList">List of ships that this shipyard can be retooled to.</param>
        private static void RefreshSYCGroupBox(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, 
                                               Installation.ShipyardInformation SYInfo, BindingList<ShipClassTN> RetoolList)
        {
#warning this doesn't update when a new shipclass is added on its own. the econ page is "shared" by all factions so an event may not be possible there.
            if (RetoolList != null && CurrentFaction != null && SYInfo != null)
            {

                m_oSummaryPanel.NewShipClassComboBox.Items.Clear();
                RetoolList.Clear();
                foreach (ShipClassTN Ship in CurrentFaction.ShipDesigns)
                {
                    /// <summary>
                    /// Ships that are too big may not be in the retool list, and military ships may not be built at commercial yards.
                    /// Naval yards may build all classes of ships, but cap expansion for naval yards is very expensive.
                    /// </summary>
                    if (Ship.SizeTons <= SYInfo.Tonnage && !(Ship.IsMilitary == true && SYInfo.ShipyardType == Constants.ShipyardInfo.SYType.Commercial))
                    {
                        RetoolList.Add(Ship);
                    }
                }

                foreach (ShipClassTN Ship in RetoolList)
                {
                    m_oSummaryPanel.NewShipClassComboBox.Items.Add(Ship);
                }
                if (RetoolList.Count != 0)
                    m_oSummaryPanel.NewShipClassComboBox.SelectedIndex = 0;
            }
        }
 /// <summary>
 /// Get a list of the shipclasses in orbit. this wll be needed to help prune repair/refit/scrap operation options.
 /// </summary>
 /// <param name="CurrentFaction">Current faction from the economics handler</param>
 /// <param name="CurrentPopulation">Current Population from the economics handler.</param>  
 /// <param name="ClassesInOrbit">List of shipclasses in orbit around CurrentPopulation.</param>        
 private static void GetShipClassesInOrbit(Faction CurrentFaction, Population CurrentPopulation, ref BindingList<ShipClassTN> ClassesInOrbit)
 {
     ClassesInOrbit.Clear();
     foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
     {
         if (CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
         {
             foreach (ShipTN CurrentShip in CurrentTaskGroup.Ships)
             {
                 if (ClassesInOrbit.Contains(CurrentShip.ShipClass) == false)
                     ClassesInOrbit.Add(CurrentShip.ShipClass);
             }
         }
     }
 }
        /// <summary>
        /// This builds the Shipyard complex groupbox, which controls how the shipyards themselves are modified. Shipyard tasks(such as ship building) are handled elsewhere.
        /// </summary>
        /// <param name="m_oSummaryPanel">The summary panel from the economics handler.</param>
        private static void BuildSYCGroupBox(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, BindingList<ShipClassTN> RetoolList)
        {
            m_oSummaryPanel.SYCTaskTypeComboBox.Items.Clear();
            m_oSummaryPanel.SYCTaskTypeComboBox.DataSource = Constants.ShipyardInfo.ShipyardTasks;
            m_oSummaryPanel.SYCTaskTypeComboBox.SelectedIndex = 0;

#warning this doesn't update when a new shipclass is added on its own. the econ page is "shared" by all factions so an event may not be possible there.
            m_oSummaryPanel.NewShipClassComboBox.Items.Clear();
            foreach (ShipClassTN Ship in RetoolList)
            {
                m_oSummaryPanel.NewShipClassComboBox.Items.Add(Ship);
            }
            if (RetoolList.Count != 0)
                m_oSummaryPanel.NewShipClassComboBox.SelectedIndex = 0;
        }
 /// <summary>
 /// assignment of a population as the target
 /// </summary>
 /// <param name="PopTarget">Population to be targetted</param>
 public void assignTarget(Population PopTarget)
 {
     TargetTN NewPopTarget = new TargetTN(PopTarget);
     m_oTarget = NewPopTarget;
 }
 /// <summary>
 /// This builds the Shipyard tasks groupbox, which controls the building/repairing/refitting/scrapping of ships. said ships must be in orbit and taskgroups connected to them may not
 /// move while this process is underway.
 /// </summary>
 /// <param name="m_oSummaryPanel">The summary panel from the economics handler.</param>
 private static void BuildSYTaskGroupBox(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation)
 {
     m_oSummaryPanel.SYTaskTypeComboBox.Items.Clear();
     m_oSummaryPanel.SYTaskTypeComboBox.DataSource = Constants.ShipyardInfo.ShipyardTaskType;
     m_oSummaryPanel.SYTaskTypeComboBox.SelectedIndex = 0;
 }
Exemple #23
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];
            }
        /// <summary>
        /// Refreshing the shipyard task groupbox will be necessary on player input.
        /// </summary>
        /// <param name="m_oSummaryPanel">The economics handler panel.</param>
        /// <param name="CurrentFaction">Selected faction from the economics handler.</param>
        /// <param name="CurrentPopulation">Selected population from the economics handler.</param>
        /// <param name="SYInfo">Shipyard information from the economics handler.</param>
        /// <param name="EligibleClassList">List of shipclasses that this shipyard can produce.</param>
        /// <param name="DamagedShipList">List of damaged ships in orbit.</param>
        /// <param name="ClassesInOrbit">List of shipclasses in orbit around CurrentPopulation.</param>
        /// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param>
        public static void RefreshSYTaskGroupBox(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, Installation.ShipyardInformation SYInfo,
                                                 ref BindingList<ShipClassTN> EligibleClassList, ref BindingList<ShipTN> DamagedShipList, ref BindingList<ShipClassTN> ClassesInOrbit,
                                                 ref BindingList<ShipTN>ShipsOfClassInOrbit)
        {
            if(m_oSummaryPanel.SYTaskTypeComboBox.SelectedIndex != -1)
            {
                Constants.ShipyardInfo.Task CurrentSYTask = (Constants.ShipyardInfo.Task)m_oSummaryPanel.SYTaskTypeComboBox.SelectedIndex;

                switch (CurrentSYTask)
                {
                    case Constants.ShipyardInfo.Task.Construction:                        
                        /// <summary>
                        /// Fill the taskgroups in orbit combo box.
                        /// </summary>
                        m_oSummaryPanel.SYTaskGroupComboBox.Items.Clear();
                        foreach (TaskGroupTN CurrentTaskGroup in CurrentPopulation.Planet.TaskGroupsInOrbit)
                        {
                            if(CurrentTaskGroup.TaskGroupFaction == CurrentFaction)
                                m_oSummaryPanel.SYTaskGroupComboBox.Items.Add(CurrentTaskGroup);
                        }
#warning later on look for Shipyard TG? and should shipyard TG be "special"?
                        if (m_oSummaryPanel.SYTaskGroupComboBox.Items.Count != 0)
                            m_oSummaryPanel.SYTaskGroupComboBox.SelectedIndex = 0;

                        if (SYInfo.AssignedClass != null)
                        {
                            m_oSummaryPanel.SYNewClassComboBox.Items.Clear();

                            GetEligibleClassList(CurrentFaction, SYInfo, ref EligibleClassList);

                            foreach (ShipClassTN CurrentClass in EligibleClassList)
                            {
                                m_oSummaryPanel.SYNewClassComboBox.Items.Add(CurrentClass);
                            }
                            if (m_oSummaryPanel.SYNewClassComboBox.Items.Count != 0)
                                m_oSummaryPanel.SYNewClassComboBox.SelectedIndex = 0;

                            int index = CurrentFaction.ShipDesigns.IndexOf(EligibleClassList[0]);
                            String Entry = String.Format("{0} {1}", CurrentFaction.ShipDesigns[index].Name,
                                                         (CurrentFaction.ShipDesigns[index].ShipsInClass.Count + CurrentFaction.ShipDesigns[index].ShipsUnderConstruction + 1));
                            m_oSummaryPanel.SYShipNameTextBox.Text = Entry;
                        }
                        break;
                    case Constants.ShipyardInfo.Task.Repair:
                        m_oSummaryPanel.RepairRefitScrapLabel.Text = "Repair";
                        GetDamagedShipList(CurrentFaction, CurrentPopulation, ref DamagedShipList);
                        m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Clear();
                        foreach (ShipTN CurrentShip in DamagedShipList)
                        {
                            m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Add(CurrentShip);
                        }
                        if (m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Count != 0)
                            m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex = 0;
                        break;
                    case Constants.ShipyardInfo.Task.Refit:
                        m_oSummaryPanel.RepairRefitScrapLabel.Text = "Refit";
                        GetShipClassesInOrbit(CurrentFaction, CurrentPopulation, ref ClassesInOrbit);
                        m_oSummaryPanel.RepairRefitScrapClassComboBox.Items.Clear();
                        foreach (ShipClassTN CurrentClass in ClassesInOrbit)
                        {
                            m_oSummaryPanel.RepairRefitScrapClassComboBox.Items.Add(CurrentClass);
                        }
                        ShipClassTN CurrentRRSClass = null;
                        if (m_oSummaryPanel.RepairRefitScrapClassComboBox.Items.Count != 0)
                        {
                            m_oSummaryPanel.RepairRefitScrapClassComboBox.SelectedIndex = 0;
                            CurrentRRSClass = ClassesInOrbit[m_oSummaryPanel.RepairRefitScrapClassComboBox.SelectedIndex];
                        }

                        if (CurrentRRSClass != null)
                        {
                            GetShipsOfClassInOrbit(CurrentFaction, CurrentPopulation, CurrentRRSClass, ref ShipsOfClassInOrbit);
                            m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Clear();
                            foreach (ShipTN CurrentShip in ShipsOfClassInOrbit)
                            {
                                m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Add(CurrentShip);
                            }
                            if (m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Count != 0)
                                m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex = 0;
                        }
                        break;
                    case Constants.ShipyardInfo.Task.Scrap:
                        m_oSummaryPanel.RepairRefitScrapLabel.Text = "Scrap";
                        GetShipClassesInOrbit(CurrentFaction, CurrentPopulation, ref ClassesInOrbit);
                        m_oSummaryPanel.RepairRefitScrapClassComboBox.Items.Clear();
                        foreach (ShipClassTN CurrentClass in ClassesInOrbit)
                        {
                            m_oSummaryPanel.RepairRefitScrapClassComboBox.Items.Add(CurrentClass);
                        }
                        CurrentRRSClass = null;
                        if (m_oSummaryPanel.RepairRefitScrapClassComboBox.Items.Count != 0)
                        {
                            m_oSummaryPanel.RepairRefitScrapClassComboBox.SelectedIndex = 0;
                            CurrentRRSClass = ClassesInOrbit[m_oSummaryPanel.RepairRefitScrapClassComboBox.SelectedIndex];
                        }

                        if(CurrentRRSClass != null)
                        {
                            GetShipsOfClassInOrbit(CurrentFaction, CurrentPopulation, CurrentRRSClass, ref ShipsOfClassInOrbit);
                            m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Clear();
                            foreach (ShipTN CurrentShip in ShipsOfClassInOrbit)
                            {
                                m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Add(CurrentShip);
                            }
                            if (m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Count != 0)
                                m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex = 0;
                        }
                        break;
                }
            }
        }
Exemple #25
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);
        }
        /// <summary>
        /// Update just the RRSShipComboBox since a full refresh will cause issues with constantly prompting more refreshes.
        /// </summary>
        /// <param name="m_oSummaryPanel">Current economics handler</param>
        /// <param name="CurrentFaction">Selected faction</param>
        /// <param name="CurrentPopulation">Selected population</param>
        /// <param name="ClassesInOrbit">List of shipclasses in orbit around CurrentPopulation.</param>
        /// <param name="ShipsOfClassInOrbit">List of ships in the selected shipclass in orbit around CurrentPopulation.</param>
        public static void RefreshRRSShipComboBox(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation, BindingList<ShipClassTN> ClassesInOrbit,
                                                  ref BindingList<ShipTN> ShipsOfClassInOrbit)
        {
            if (m_oSummaryPanel.RepairRefitScrapClassComboBox.SelectedIndex != -1)
            {
                ShipClassTN CurrentRRSClass = ClassesInOrbit[m_oSummaryPanel.RepairRefitScrapClassComboBox.SelectedIndex];

                GetShipsOfClassInOrbit(CurrentFaction, CurrentPopulation, CurrentRRSClass, ref ShipsOfClassInOrbit);

                m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Clear();
                foreach (ShipTN CurrentShip in ShipsOfClassInOrbit)
                {
                    m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Add(CurrentShip);
                    if (m_oSummaryPanel.RepairRefitScrapShipComboBox.Items.Count != 0)
                    {
                        m_oSummaryPanel.RepairRefitScrapShipComboBox.SelectedIndex = 0;
                    }
                }
            }
        }
Exemple #27
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);
        }
        /// <summary>
        /// Populate the rows of the Shipyard datagrid with the various shipyard complex data items.
        /// </summary>
        /// <param name="m_oSummaryPanel"></param>
        /// <param name="CurrentFaction">Faction Currently selected</param>
        /// <param name="CurrentPopulation">Population Currently selected</param>
        private static void RefreshShipyardDataGrid(Panels.Eco_Summary m_oSummaryPanel, Faction CurrentFaction, Population CurrentPopulation)
        {
            if (m_oSummaryPanel.ShipyardDataGrid.Rows.Count != 0)
            {

                int row = 0;

                /// <summary>
                /// Populate the Naval shipyard info.
                /// </summary>
                int NavalYards = (int)Math.Floor(CurrentPopulation.Installations[(int)Installation.InstallationType.NavalShipyardComplex].Number);
                for (int ShipyardIterator = 0; ShipyardIterator < NavalYards; ShipyardIterator++)
                {
                    m_oSummaryPanel.ShipyardDataGrid.Rows[row].Visible = true;
                    row++;

                    if (row == MaxShipyardRows)
                    {
                        using (DataGridViewRow NewRow = new DataGridViewRow())
                        {
                            // setup row height. note that by default they are 22 pixels in height!
                            NewRow.Height = 18;
                            NewRow.Visible = false;
                            m_oSummaryPanel.ShipyardDataGrid.Rows.Add(NewRow);
                        }
                        MaxShipyardRows++;
                    }

                    Installation.ShipyardInformation SYI = CurrentPopulation.Installations[(int)Installation.InstallationType.NavalShipyardComplex].SYInfo[ShipyardIterator];
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[0].Value = SYI.Name;
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[1].Value = "N";
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[2].Value = SYI.Slipways;
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[3].Value = SYI.Tonnage;

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[4].Value = (SYI.Slipways - SYI.BuildingShips.Count());

                    if (SYI.AssignedClass != null)
                    {
                        m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[5].Value = SYI.AssignedClass.Name;
                    }
                    else
                    {
                        m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[5].Value = "No Assigned Class";
                    }

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[6].Value = Constants.ShipyardInfo.ShipyardTasks[(int)SYI.CurrentActivity.Activity];


                    String ProgString = String.Format("{0:N2}", (SYI.CurrentActivity.Progress * 100.0m));

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[7].Value = ProgString;
                    if (SYI.CurrentActivity.Activity == Constants.ShipyardInfo.ShipyardActivity.NoActivity)
                    {
                        m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[8].Value = "N/A";
                    }
                    else
                    {
                        float YearsOfProduction = (float)SYI.CurrentActivity.CostOfActivity / SYI.CalcAnnualSYProduction();
                        if (YearsOfProduction < Constants.Colony.TimerYearMax)
                        {
                            m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[8].Value = SYI.CurrentActivity.CompletionDate;
                        }
                        else
                        {
                            m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[8].Value = "N/A";
                        }
                    }

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator].Cells[9].Value = SYI.ModRate;


                }

                /// <summary>
                /// Populate the commercial yard information.
                /// </summary>
                int CommercialYards = (int)Math.Floor(CurrentPopulation.Installations[(int)Installation.InstallationType.CommercialShipyard].Number);
                for (int ShipyardIterator = 0; ShipyardIterator < CommercialYards; ShipyardIterator++)
                {
                    m_oSummaryPanel.ShipyardDataGrid.Rows[row].Visible = true;
                    

                    if (row == MaxShipyardRows)
                    {
                        using (DataGridViewRow NewRow = new DataGridViewRow())
                        {
                            // setup row height. note that by default they are 22 pixels in height!
                            NewRow.Height = 18;
                            NewRow.Visible = false;
                            m_oSummaryPanel.ShipyardDataGrid.Rows.Add(NewRow);
                        }
                        MaxShipyardRows++;
                    }

                    Installation.ShipyardInformation SYI = CurrentPopulation.Installations[(int)Installation.InstallationType.CommercialShipyard].SYInfo[ShipyardIterator];
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[0].Value = SYI.Name;
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[1].Value = "C";
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[2].Value = SYI.Slipways;
                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[3].Value = SYI.Tonnage;

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[4].Value = (SYI.Slipways - SYI.BuildingShips.Count());

                    if (SYI.AssignedClass != null)
                    {
                        m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[5].Value = SYI.AssignedClass.Name;
                    }
                    else
                    {
                        m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[5].Value = "No Assigned Class";
                    }

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[6].Value = Constants.ShipyardInfo.ShipyardTasks[(int)SYI.CurrentActivity.Activity];

                    String ProgString = String.Format("{0:N2}",(SYI.CurrentActivity.Progress * 100.0m));

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[7].Value = ProgString;
                    if (SYI.CurrentActivity.Activity == Constants.ShipyardInfo.ShipyardActivity.NoActivity)
                    {
                        m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[8].Value = "N/A";
                    }
                    else
                    {
                        m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[8].Value = SYI.CurrentActivity.CompletionDate;
                    }

                    m_oSummaryPanel.ShipyardDataGrid.Rows[ShipyardIterator + row].Cells[9].Value = SYI.ModRate;

                    row++;
                }

                /// <summary>
                /// Do not display any rows after this.
                /// </summary>
                for (int rowIterator = row; rowIterator < MaxShipyardRows; rowIterator++)
                {
                    m_oSummaryPanel.ShipyardDataGrid.Rows[rowIterator].Visible = false;
                }
            }
        }
Exemple #29
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);

        }
Exemple #30
0
        /// <summary>
        /// Unloads the specified component to population pop.
        /// </summary>
        /// <param name="Pop">Population receiving shipment.</param>
        /// <param name="Component">Component to be unloaded. I'm not particularly happy with how this is being done right now.</param>
        /// <param name="Limit">Limit to unloading.</param>
        public void UnloadComponents(Population Pop, ComponentDefTN Component, int Limit)
        {
            int TotalMass = (int)(Component.size * Constants.ShipTN.TonsPerHS * (float)Limit);

            for (int loop = 0; loop < Ships.Count; loop++)
            {
                if (Ships[loop].CurrentCargoTonnage != 0 && Ships[loop].CargoComponentList.ContainsKey(Component) == true)
                {
                    CargoListEntryTN CLE = Ships[0].CargoComponentList[Component];

                    int ShipMassToUnload;
                    /// <summary>
                    /// Limit == 0 means unload all, else unload to limit if limit is lower than total tonnage.
                    /// </summary>
                    if (Limit == 0)
                    {
                        ShipMassToUnload = CLE.tons;
                    }
                    else
                    {
                        ShipMassToUnload = Math.Min(CLE.tons, TotalMass);
                        TotalMass = TotalMass - ShipMassToUnload;
                    }

                    if (ShipMassToUnload == CLE.tons)
                    {
                        Ships[0].CargoComponentList.Remove(Component);
                    }

                    CLE.tons = CLE.tons - ShipMassToUnload;
                    CurrentCargoTonnage = CurrentCargoTonnage - ShipMassToUnload;

                    float ComponentUnloadCount = (float)(ShipMassToUnload / (Component.size * Constants.ShipTN.TonsPerHS));

                    Pop.AddComponentsToStockpile(Component, ComponentUnloadCount);
                }
            }
        }