示例#1
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            m_oSW.Start();

            int iNoOfSystemsToGenerate = 1000;

            int.TryParse(NoOfSystemsTextBox.Text, out iNoOfSystemsToGenerate);
            int iNoOfSystemsDiv4 = iNoOfSystemsToGenerate / 4;

            GenProgressBar.Minimum = 0;
            GenProgressBar.Maximum = iNoOfSystemsToGenerate;

            GameState.Instance.StarSystems.RaiseListChangedEvents = false;

            for (int i = 0; i < iNoOfSystemsToGenerate; ++i)
            {
                SystemGen.CreateSystem(GalaxyNameTextBox.Text + i.ToString());
                GenProgressBar.Value = i;
            }

            GameState.Instance.StarSystems.RaiseListChangedEvents = true;
            GameState.Instance.StarSystems.ResetBindings();

            m_oSW.Stop();
            Timelabel.Text = m_oSW.Elapsed.Hours.ToString() + ":" + m_oSW.Elapsed.Minutes.ToString() + ":" + m_oSW.Elapsed.Seconds.ToString() + ":" + m_oSW.Elapsed.Milliseconds.ToString();
        }
示例#2
0
 void GenSystemButton_Click(object sender, EventArgs e)
 {
     Dialogs.InputBasic InpuDialog = new Dialogs.InputBasic("Enter Seed", "Enter System Seed", "-1");
     InpuDialog.ShowDialog();
     if (InpuDialog.DialogResult == DialogResult.OK)
     {
         m_iNumberOfNewSystemsGened++;
         SystemGen.CreateSystem("Gened System " + m_iNumberOfNewSystemsGened.ToString(), InpuDialog.InputInt);
     }
     // cleanup input box:
     InpuDialog.Close();
 }
示例#3
0
        static void Main()
        {
#if LOG4NET_ENABLED
            XmlConfigurator.Configure(); // Enables Log4net based on App.config file.
            logger.Info("Program Started");
#endif

            // gen star system:
            Entities.StarSystem sol = SystemGen.CreateSol();
            SystemGen.CreateStressTest();
            SystemGen.CreateSystem("Test");
            SystemGen.CreateSystem("Foo");
            SystemGen.CreateSystem("Bar");



            /// <summary>
            /// Alpha Build related area:
            /// </summary>


            // gen Faction and a pop:
            Entities.Faction oNewFaction = new Entities.Faction(0);

            /// <summary>
            /// This following section should probably be moved to the Faction constructor at some point.
            /// </summary>
            oNewFaction.Populations.Add(new Entities.Population(sol.Stars.FirstOrDefault().Planets.FirstOrDefault(), oNewFaction));
            oNewFaction.Populations[0].Planet.HomeworldMineralGeneration();
            oNewFaction.Populations[0].ConventionalStart();
            /// <summary>
            /// Add Contact lists.
            /// </summary>
            foreach (Entities.StarSystem CurSystem in GameState.Instance.StarSystems)
            {
                oNewFaction.AddNewContactList(CurSystem);
            }
            Entities.SystemBody P1 = new Entities.SystemBody(sol.Stars[0], Entities.SystemBody.PlanetType.Comet);  ///< @tdo WTF??? Alpha Build Related Area fat fingering ^
            P1.Position.X = 10.0;
            P1.Position.Y = 10.0;

            oNewFaction.Capitol = oNewFaction.Populations[0].Planet;
            oNewFaction.Capitol.GeoSurveyList.Add(oNewFaction, true);
            oNewFaction.AddNewTaskGroup("Combat Taskgroup  HR", P1, sol);
            oNewFaction.FactionColor = System.Drawing.Color.Blue;

            Entities.Faction oNewFaction2 = new Entities.Faction(1);
            oNewFaction2.Name = "Terran Federation";
            oNewFaction2.Populations.Add(new Entities.Population(sol.Stars.FirstOrDefault().Planets.FirstOrDefault(), oNewFaction2));
            oNewFaction2.Populations[0].Planet.HomeworldMineralGeneration();
            oNewFaction2.Populations[0].ConventionalStart();

            /// <summary>
            /// Add Contact lists.
            /// </summary>
            foreach (Entities.StarSystem CurSystem in GameState.Instance.StarSystems)
            {
                oNewFaction2.AddNewContactList(CurSystem);
            }

            Entities.SystemBody P2 = new Entities.SystemBody(sol.Stars[0], Entities.SystemBody.PlanetType.Comet);  ///< wtf??? its a fatfinger to initialize the position of Combat Taskgroup TR
            P2.Position.X = -10.0;
            P2.Position.Y = -10.0;


            oNewFaction2.Capitol = oNewFaction2.Populations[0].Planet;
            oNewFaction2.Capitol.GeoSurveyList.Add(oNewFaction2, true);
            oNewFaction2.AddNewTaskGroup("Combat Taskgroup TR", P2, sol);
            oNewFaction2.FactionColor = System.Drawing.Color.Red;

            oNewFaction.AddNewShipDesign("Sword");
            ComponentDefListTN CL = oNewFaction.ComponentList;


            oNewFaction.ShipDesigns[0].AddEngine(CL.Engines[1], 8);
            oNewFaction.ShipDesigns[0].AddCrewQuarters(CL.CrewQuarters[0], 11);
            oNewFaction.ShipDesigns[0].AddFuelStorage(CL.FuelStorage[0], 10);
            oNewFaction.ShipDesigns[0].AddEngineeringSpaces(CL.EngineeringSpaces[0], 10);
            oNewFaction.ShipDesigns[0].AddOtherComponent(CL.OtherComponents[0], 1);
            oNewFaction.ShipDesigns[0].AddActiveSensor(CL.ActiveSensorDef[1], 1);
            oNewFaction.ShipDesigns[0].AddActiveSensor(CL.ActiveSensorDef[2], 1);
            oNewFaction.ShipDesigns[0].AddActiveSensor(CL.ActiveSensorDef[3], 1);
            oNewFaction.ShipDesigns[0].AddPassiveSensor(CL.PassiveSensorDef[2], 1);
            oNewFaction.ShipDesigns[0].AddPassiveSensor(CL.PassiveSensorDef[3], 1);
            oNewFaction.ShipDesigns[0].AddReactor(CL.ReactorDef[1], 10);
            oNewFaction.ShipDesigns[0].AddBeamFireControl(CL.BeamFireControlDef[1], 2);
            oNewFaction.ShipDesigns[0].AddShield(CL.ShieldDef[1], 20);
            oNewFaction.ShipDesigns[0].IsLocked = true;

            for (int loop = 1; loop < 8; loop++)
            {
                oNewFaction.ShipDesigns[0].AddBeamWeapon(CL.BeamWeaponDef[loop], 1);
            }
            oNewFaction.ShipDesigns[0].NewArmor("Composite", 8, 4);

            oNewFaction.AddNewShipDesign("Hammer");
            oNewFaction.ShipDesigns[1].AddEngine(CL.Engines[2], 2);
            oNewFaction.ShipDesigns[1].AddCrewQuarters(CL.CrewQuarters[0], 8);
            oNewFaction.ShipDesigns[1].AddFuelStorage(CL.FuelStorage[0], 10);
            oNewFaction.ShipDesigns[1].AddEngineeringSpaces(CL.EngineeringSpaces[0], 10);
            oNewFaction.ShipDesigns[1].AddOtherComponent(CL.OtherComponents[0], 1);
            oNewFaction.ShipDesigns[1].AddActiveSensor(CL.ActiveSensorDef[4], 1);
            oNewFaction.ShipDesigns[1].AddActiveSensor(CL.ActiveSensorDef[5], 1);
            oNewFaction.ShipDesigns[1].AddMFC(CL.MissileFireControlDef[1], 1);
            oNewFaction.ShipDesigns[1].AddMFC(CL.MissileFireControlDef[2], 1);
            oNewFaction.ShipDesigns[1].AddMagazine(CL.MagazineDef[1], 1);
            oNewFaction.ShipDesigns[1].AddLauncher(CL.MLauncherDef[1], 4);
            oNewFaction.ShipDesigns[1].AddLauncher(CL.MLauncherDef[2], 4);
            oNewFaction.ShipDesigns[1].NewArmor("Collapsium", 45, 5);
            oNewFaction.ShipDesigns[1].SetPreferredOrdnance(CL.MissileDef[0], 100);
            oNewFaction.ShipDesigns[1].SetPreferredOrdnance(CL.MissileDef[1], 200);
            oNewFaction.ShipDesigns[1].IsLocked = true;
            oNewFaction.ShipDesigns[1].BuildClassSummary();


            oNewFaction.TaskGroups.Last().AddShip(oNewFaction.ShipDesigns[0], "Warship");
            oNewFaction.TaskGroups.Last().AddShip(oNewFaction.ShipDesigns[0], "Backup Warship");
            oNewFaction.TaskGroups.Last().AddShip(oNewFaction.ShipDesigns[1], "Hammer");
            oNewFaction.TaskGroups.Last().Ships[0].Refuel(1000000.0f);
            oNewFaction.TaskGroups.Last().Ships[1].Refuel(1000000.0f);
            oNewFaction.TaskGroups.Last().Ships[2].Refuel(1000000.0f);

            foreach (KeyValuePair <OrdnanceDefTN, int> pair in oNewFaction.ShipDesigns[1].ShipClassOrdnance)
            {
                oNewFaction.TaskGroups.Last().Ships[2].ShipOrdnance.Add(pair.Key, pair.Value);
            }
            oNewFaction.TaskGroups.Last().Ships[2].CurrentMagazineCapacity = oNewFaction.ShipDesigns[1].PreferredOrdnanceSize;

            oNewFaction2.AddNewShipDesign("Mace");
            CL = oNewFaction2.ComponentList;


            oNewFaction2.ShipDesigns[0].AddEngine(CL.Engines[1], 8);
            oNewFaction2.ShipDesigns[0].AddCrewQuarters(CL.CrewQuarters[0], 11);
            oNewFaction2.ShipDesigns[0].AddFuelStorage(CL.FuelStorage[0], 10);
            oNewFaction2.ShipDesigns[0].AddEngineeringSpaces(CL.EngineeringSpaces[0], 10);
            oNewFaction2.ShipDesigns[0].AddOtherComponent(CL.OtherComponents[0], 1);
            oNewFaction2.ShipDesigns[0].AddActiveSensor(CL.ActiveSensorDef[1], 1);
            oNewFaction2.ShipDesigns[0].AddActiveSensor(CL.ActiveSensorDef[2], 1);
            oNewFaction2.ShipDesigns[0].AddActiveSensor(CL.ActiveSensorDef[3], 1);
            oNewFaction2.ShipDesigns[0].AddPassiveSensor(CL.PassiveSensorDef[2], 1);
            oNewFaction2.ShipDesigns[0].AddPassiveSensor(CL.PassiveSensorDef[3], 1);
            oNewFaction2.ShipDesigns[0].AddReactor(CL.ReactorDef[1], 10);
            oNewFaction2.ShipDesigns[0].AddBeamFireControl(CL.BeamFireControlDef[1], 2);
            oNewFaction2.ShipDesigns[0].AddShield(CL.ShieldDef[1], 20);
            oNewFaction2.ShipDesigns[0].IsLocked = true;

            for (int loop = 1; loop < 8; loop++)
            {
                oNewFaction2.ShipDesigns[0].AddBeamWeapon(CL.BeamWeaponDef[loop], 1);
            }
            oNewFaction2.ShipDesigns[0].NewArmor("Composite", 8, 4);

            oNewFaction2.AddNewShipDesign("Crusher");
            oNewFaction2.ShipDesigns[1].AddEngine(CL.Engines[2], 2);
            oNewFaction2.ShipDesigns[1].AddCrewQuarters(CL.CrewQuarters[0], 8);
            oNewFaction2.ShipDesigns[1].AddFuelStorage(CL.FuelStorage[0], 10);
            oNewFaction2.ShipDesigns[1].AddEngineeringSpaces(CL.EngineeringSpaces[0], 10);
            oNewFaction2.ShipDesigns[1].AddOtherComponent(CL.OtherComponents[0], 1);
            oNewFaction2.ShipDesigns[1].AddActiveSensor(CL.ActiveSensorDef[4], 1);
            oNewFaction2.ShipDesigns[1].AddActiveSensor(CL.ActiveSensorDef[5], 1);
            oNewFaction2.ShipDesigns[1].AddMFC(CL.MissileFireControlDef[1], 1);
            oNewFaction2.ShipDesigns[1].AddMFC(CL.MissileFireControlDef[2], 1);
            oNewFaction2.ShipDesigns[1].AddMagazine(CL.MagazineDef[1], 1);
            oNewFaction2.ShipDesigns[1].AddLauncher(CL.MLauncherDef[1], 4);
            oNewFaction2.ShipDesigns[1].AddLauncher(CL.MLauncherDef[2], 4);
            oNewFaction2.ShipDesigns[1].NewArmor("Collapsium", 45, 5);
            oNewFaction2.ShipDesigns[1].SetPreferredOrdnance(CL.MissileDef[0], 100);
            oNewFaction2.ShipDesigns[1].SetPreferredOrdnance(CL.MissileDef[1], 200);
            oNewFaction2.ShipDesigns[1].IsLocked = true;
            oNewFaction2.ShipDesigns[1].BuildClassSummary();

            oNewFaction2.TaskGroups.Last().AddShip(oNewFaction2.ShipDesigns[0], "Battleship");
            oNewFaction2.TaskGroups.Last().AddShip(oNewFaction2.ShipDesigns[0], "Backup Battleship");
            oNewFaction2.TaskGroups.Last().AddShip(oNewFaction.ShipDesigns[1], "Crusher");
            oNewFaction2.TaskGroups.Last().Ships[0].Refuel(1000000.0f);
            oNewFaction2.TaskGroups.Last().Ships[1].Refuel(1000000.0f);
            oNewFaction2.TaskGroups.Last().Ships[2].Refuel(1000000.0f);

            foreach (KeyValuePair <OrdnanceDefTN, int> pair in oNewFaction2.ShipDesigns[1].ShipClassOrdnance)
            {
                oNewFaction2.TaskGroups.Last().Ships[2].ShipOrdnance.Add(pair.Key, pair.Value);
            }
            oNewFaction2.TaskGroups.Last().Ships[2].CurrentMagazineCapacity = oNewFaction2.ShipDesigns[1].PreferredOrdnanceSize;

            oNewFaction.GiveAllTechs();
            oNewFaction2.GiveAllTechs();

            /// <summary>
            /// End Alpha.
            /// </summary>



            Application.EnableVisualStyles();

            //Initialize damage values.
            DamageValuesTN.init();


            // Init our UI Controller:
            Helpers.UIController.Instance.Initialise();
            //Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Forms.MainForm());

#if LOG4NET_ENABLED
            logger.Info("Program Ended");
#endif
        }
示例#4
0
        public void TestSetup()
        {
            _gameState             = GameState.Instance;
            _gameState.Name        = "Test Game";
            _gameState.Species     = new BindingList <Species>();
            _gameState.Factions    = new BindingList <Faction>();
            _gameState.StarSystems = new BindingList <StarSystem>();
            _gameState.Stars       = new BindingList <Star>();
            _gameState.Planets     = new BindingList <SystemBody>();

            var species = new Species {
                Id = Guid.NewGuid(), Name = "Test Humans"
            };

            _gameState.Species.Add(species);
            var theme = new FactionTheme {
                Id = Guid.NewGuid(), Name = "Test Theme"
            };

            _gameState.Factions.Add(new Faction(0)
            {
                Id = Guid.NewGuid(), Name = "Test Faction", Species = species, Title = "Mighty Humans", FactionTheme = theme
            });

            var ss = SystemGen.CreateSystem("Test Sol");

            GameState.Instance.StarSystemCurrentIndex++;
            ss.Stars.ToList().ForEach(x => _gameState.Stars.Add(x));
            ss.Stars.ToList().SelectMany(x => x.Planets).ToList().ForEach(p => _gameState.Planets.Add(p));

            UriBuilder uri = new UriBuilder(System.Reflection.Assembly.GetExecutingAssembly().CodeBase);

            _appPath    = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path));
            _saveFolder = Path.Combine(_appPath, "Test");

            _nameThemes = new List <CommanderNameTheme>();
            var ct1 = new CommanderNameTheme()
            {
                Id          = Guid.NewGuid(),
                Name        = "Test Theme 1",
                NameEntries =
                {
                    new NameEntry()
                    {
                        IsFemale = false, Name = "Bob", NamePosition = NamePosition.FirstName
                    },
                    new NameEntry()
                    {
                        IsFemale = false, Name = "Smith", NamePosition = NamePosition.LastName
                    }
                }
            };

            _nameThemes.Add(ct1);
            var ct2 = new CommanderNameTheme()
            {
                Id          = Guid.NewGuid(),
                Name        = "Test Theme 2",
                NameEntries =
                {
                    new NameEntry()
                    {
                        IsFemale = true, Name = "Sarah", NamePosition = NamePosition.FirstName
                    },
                    new NameEntry()
                    {
                        IsFemale = false, Name = "Connor", NamePosition = NamePosition.LastName
                    }
                }
            };

            _nameThemes.Add(ct2);
        }
示例#5
0
文件: JumpPoint.cs 项目: txe/Pulsar4x
        /// <summary>
        /// Handles connecting unconnected jump points.
        /// This function only handles the connection of JumpPoints to new JumpPoints/Systems
        /// </summary>
        public void CreateConnection()
        {
            int        systemIndex     = -1;
            StarSystem connectedSystem = null;

            if (Constants.GameSettings.JumpPointLocalGroupConnectionChance >= GameState.RNG.Next(101))
            {
                do
                {
                    // We will connect to an 'existing system'
                    // Note, existing system doesn't necessarily exist.
                    systemIndex = Position.System.SystemIndex + GameState.RNG.Next(-Constants.GameSettings.JumpPointLocalGroupSize / 2, (Constants.GameSettings.JumpPointLocalGroupSize / 2) + 1);
                    if (systemIndex < 0)
                    {
                        // Sorry, we gotta keep you positive.
                        systemIndex = Math.Abs(systemIndex);
                    }
                }
                // Prevent linking to self.
                while (systemIndex == Position.System.SystemIndex);
            }
            else
            {
                // Generating a 'new system'
                // Note, new system isn't necessarily non-existant.
                systemIndex = GameState.Instance.StarSystemCurrentIndex;
            }


            if (systemIndex >= GameState.Instance.StarSystemCurrentIndex)
            {
                if (systemIndex == GameState.Instance.StarSystemCurrentIndex)
                {
                    // We're connecting to the next system on the list.
                    // This system will be generated, so increase our current index.
                    // This can happen with either 'existing system' or 'new system'
                    // however, it is intended for 'new system' generation.
                    GameState.Instance.StarSystemCurrentIndex++;
                }

                while (systemIndex > GameState.Instance.StarSystems.Count)
                {
                    // We're connecting to an 'existing system' that doesn't exist.
                    // If systemIndex 15 was selected above, and we've only got 10 systems, fill in the gap with new systems.
                    SystemGen.CreateSystem("Unexplored System S-" + GameState.Instance.StarSystems.Count);

                    // Note, we didn't set our StarSystemCurrentIndex. This is intentional.
                    // When we make another connection, and we RNG a 'new system' connection, we may have just made the 'new system' here.
                    // Since we want 'existing system' to make 2 links once all JP's are explored, we ensure
                    // the 'new system' connection will actually connect to the 'existing system'.
                }
            }

            if (systemIndex == GameState.Instance.StarSystems.Count)
            {
                // Generate a new system.

                connectedSystem = SystemGen.CreateSystem("Unexplored System S-" + GameState.Instance.StarSystems.Count);
            }
            else
            {
                // Select an existing system.
                connectedSystem = GameState.Instance.StarSystems[systemIndex];
            }

            // Choose a random jump point in the new system.
            JumpPoint connectedJP = null;

            List <JumpPoint> systemJumpPoints = new List <JumpPoint>();

            systemJumpPoints.AddRange(connectedSystem.JumpPoints); // Deep copy so we don't ruin the connectedSystem.JumpPoints list.

            while (systemJumpPoints.Count > 0)
            {
                // Select a random jump point.
                int i = GameState.RNG.Next(systemJumpPoints.Count);
                if (systemJumpPoints[i].Connect == null)
                {
                    // If selected JP doesn't have a connection, we use it.
                    connectedJP = systemJumpPoints[i];
                    break;
                }

                // If selected JP has a connection, remove it from the list, and select another.
                systemJumpPoints.RemoveAt(i);
            }

            if (connectedJP == null)
            {
                // All JP's are already connected, create a new one.
                Star parentStar = connectedSystem.Stars[GameState.RNG.Next(connectedSystem.Stars.Count)];
                connectedJP = SystemGen.GenerateJumpPoint(connectedSystem);
            }

            // Connect us to them.
            Connect = connectedJP;
            Name    = Name + "(" + Connect.Position.System.Name + ")";

            // Connect them to us.
            Connect.Connect = this;
            Connect.Name    = Connect.Name + "(" + Position.System.Name + ")";
        }