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

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

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

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

            FactionID = ID;

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

            MessageLog = new BindingList<MessageEntry>();

            MissileGroups = new BindingList<OrdnanceGroupTN>();

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

            BaseTracking = Constants.GameSettings.FactionBaseTrackingSpeed;

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

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

            MissileRemoveList = new BindingList<OrdnanceGroupTN>();

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

            FactionTechLevel = new BindingList<SByte>();

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

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

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

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


            FactionWealth = Constants.Faction.StartingWealth;

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

            GameState.Instance.Factions.Add(this);

            foreach (StarSystem system in GameState.Instance.StarSystems)
            {
                AddNewContactList(system);
            }
        }
Exemplo n.º 3
0
        public Population(SystemBody a_oPlanet, Faction a_oFaction, String a_oName = "Earth", Species a_oSpecies = null)
        {
            Id = Guid.NewGuid();
            // initialise minerials:
            m_aiMinerials = new float[Constants.Minerals.NO_OF_MINERIALS];
            for (int i = 0; i < Constants.Minerals.NO_OF_MINERIALS; ++i)
            {
                m_aiMinerials[i] = 0;
            }

            m_aoInstallations = new Installation[Installation.NO_OF_INSTALLATIONS];
            for (int i = 0; i < Installation.NO_OF_INSTALLATIONS; ++i)
            {
                m_aoInstallations[i] = new Installation((Installation.InstallationType)i);
            }

            CivilianPopulation         = 0;
            PopulationGrowthRate       = 0.1f;
            FuelStockpile              = 0;
            MaintenanceSupplies        = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing       = 1.0f;
            ModifierPoliticalStability = 1.0f;
            ModifierProduction         = 1.0f;
            ModifierWealthAndTrade     = 1.0f;

            Name = a_oName;  // just a default Value!

            Faction = a_oFaction;
            Planet  = a_oPlanet;


            if (a_oSpecies == null)
            {
                Species = Faction.Species;
            }
            else
            {
                Species = a_oSpecies;
            }
            Planet.Populations.Add(this); // add us to the list of pops on the planet!
            Planet.Position.System.Populations.Add(this);
            Contact = new SystemContact(Faction, this);

            GovernorPresent = false;
            AdminRating     = 0;

            ComponentStockpile       = new BindingList <ComponentDefTN>();
            ComponentStockpileCount  = new BindingList <float>();
            ComponentStockpileLookup = new Dictionary <Guid, int>();
            MissileStockpile         = new Dictionary <OrdnanceDefTN, float>();

            OrbitalTerraformModules = 0.0f;

            PoliticalPopStatus = PoliticalStatus.Imperial;

            for (int InstallationIterator = 0; InstallationIterator < (int)Installation.InstallationType.InstallationCount; InstallationIterator++)
            {
                Installations[InstallationIterator].Number = 0.0f;
            }

            FuelStockpile              = 0.0f;
            MaintenanceSupplies        = 0.0f;
            EMSignature                = 0;
            ThermalSignature           = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing       = 1.0f;
            ModifierProduction         = 1.0f;
            ModifierWealthAndTrade     = 1.0f;
            ModifierPoliticalStability = 1.0f;

            ConstructionBuildQueue = new BindingList <ConstructionBuildQueueItem>();
            MissileBuildQueue      = new BindingList <MissileBuildQueueItem>();
            FighterBuildQueue      = new BindingList <FighterBuildQueueItem>();

            IsRefining = false;

            ShipyardTasks = new Dictionary <Installation.ShipyardInformation.ShipyardTask, Installation.ShipyardInformation>();

            SSEntity = StarSystemEntityType.Population;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Constructor for population.
        /// </summary>
        /// <param name="a_oPlanet">Planet this population is on</param>
        /// <param name="a_oFaction">Faction this population belongs to</param>
        /// <param name="CurrentTimeSlice">Tick this population was created</param>
        /// <param name="a_oName">Name of the population</param>
        /// <param name="a_oSpecies">Species that will reside on this population.</param>
        public Population(SystemBody a_oPlanet, Faction a_oFaction, int CurrentTimeSlice, String a_oName = "Earth", Species a_oSpecies = null)
        {
            Id = Guid.NewGuid();
            // initialise minerials:
            m_aiMinerials = new float[Constants.Minerals.NO_OF_MINERIALS];
            for (int i = 0; i < Constants.Minerals.NO_OF_MINERIALS; ++i)
            {
                m_aiMinerials[i] = 0;
            }

            m_aoInstallations = new Installation[Installation.NO_OF_INSTALLATIONS];
            for (int i = 0; i < Installation.NO_OF_INSTALLATIONS; ++i)
            {
                m_aoInstallations[i] = new Installation((Installation.InstallationType)i);
            }

            CivilianPopulation = 0;
            PopulationGrowthRate = 0.1f;
            FuelStockpile = 0;
            MaintenanceSupplies = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing = 1.0f;
            ModifierPoliticalStability = 1.0f;
            ModifierProduction = 1.0f;
            ModifierWealthAndTrade = 1.0f;

            Name = a_oName;  // just a default Value!

            Faction = a_oFaction;
            Planet = a_oPlanet;


            if (a_oSpecies == null)
            {
                Species = Faction.Species;
            }
            else
            {
                Species = a_oSpecies;
            }

            SSEntity = StarSystemEntityType.Population;

            Planet.Populations.Add(this); // add us to the list of pops on the planet!
            Planet.Position.System.Populations.Add(this);
            Contact = new SystemContact(Faction, this);
            Contact.Position.System = Planet.Position.System;
            Contact.Position.X = Planet.Position.X;
            Contact.Position.Y = Planet.Position.Y;
            Planet.Position.System.SystemContactList.Add(Contact);

            GovernorPresent = false;
            AdminRating = 0;

            ComponentStockpile = new BindingList<ComponentDefTN>();
            ComponentStockpileCount = new BindingList<float>();
            ComponentStockpileLookup = new Dictionary<Guid, int>();
            MissileStockpile = new Dictionary<OrdnanceDefTN, float>();

            _OrbitalTerraformModules = 0.0f;

            PoliticalPopStatus = PoliticalStatus.Imperial;

            for (int InstallationIterator = 0; InstallationIterator < (int)Installation.InstallationType.InstallationCount; InstallationIterator++)
            {
                Installations[InstallationIterator].Number = 0.0f;
            }

            FuelStockpile = 0.0f;
            MaintenanceSupplies = 0.0f;
            EMSignature = 0;
            ThermalSignature = 0;
            ModifierEconomicProduction = 1.0f;
            ModifierManfacturing = 1.0f;
            ModifierProduction = 1.0f;
            ModifierWealthAndTrade = 1.0f;
            ModifierPoliticalStability = 1.0f;

            ConstructionBuildQueue = new BindingList<ConstructionBuildQueueItem>();
            MissileBuildQueue = new BindingList<MissileBuildQueueItem>();
            FighterBuildQueue = new BindingList<FighterBuildQueueItem>();

            IsRefining = false;

            ShipyardTasks = new Dictionary<Installation.ShipyardInformation.ShipyardTask, Installation.ShipyardInformation>();

            ThermalDetection = new BindingList<int>();
            EMDetection = new BindingList<int>();
            ActiveDetection = new BindingList<int>();

            for (int loop = 0; loop < Constants.Faction.FactionMax; loop++)
            {
                ThermalDetection.Add(CurrentTimeSlice);
                EMDetection.Add(CurrentTimeSlice);
                ActiveDetection.Add(CurrentTimeSlice);
            }

            ShipsTargetting = new BindingList<ShipTN>();
            MissilesInFlight = new BindingList<OrdnanceGroupTN>();

            _SensorUpdateAck = 0;

            /// <summary>
            /// Terraforming Section:
            /// </summary>
            _GasAddSubtract = false;
            _GasAmt = 0.0f;
            _GasToAdd = null;
        }