コード例 #1
0
        public void CreateNewColony()
        {
            Entity            faction = FactionFactory.CreateFaction(_game, "Terran");
            StarSystemFactory sysfac  = new StarSystemFactory(_game);
            StarSystem        sol     = sysfac.CreateSol(_game);
            //Entity starSystem = Entity.Create(_game.GlobalManager);
            //Entity planet = Entity.Create(starSystem.Manager, new List<BaseDataBlob>());
            List <Entity> solBodies         = sol.SystemManager.GetAllEntitiesWithDataBlob <NameDB>(_smAuthToken);
            Entity        planet            = solBodies.Find(item => item.GetDataBlob <NameDB>().DefaultName == "Earth");
            Entity        species           = SpeciesFactory.CreateSpeciesHuman(faction, _game.GlobalManager);
            var           requiredDataBlobs = new List <Type>()
            {
                typeof(ColonyInfoDB),
                typeof(NameDB),
                typeof(InstallationsDB)
            };

            //Entity colony = ColonyFactory.CreateColony(faction, planet);
            ColonyFactory.CreateColony(faction, species, planet);
            Entity       colony       = faction.GetDataBlob <FactionInfoDB>().Colonies[0];
            ColonyInfoDB colonyInfoDB = colony.GetDataBlob <ColonyInfoDB>();

            //NameDB nameDB = colony.GetDataBlob<NameDB>();

            //Assert.IsTrue(HasAllRequiredDatablobs(colony, requiredDataBlobs), "Colony Entity doesn't contains all required datablobs");
            Assert.IsTrue(colonyInfoDB.PlanetEntity == planet, "ColonyInfoDB.PlanetEntity refs to wrong entity");
        }
コード例 #2
0
        public void CloneStress()
        {
            Entity humanFaction       = FactionFactory.CreateFaction(_game, "Humans");
            Entity harbingerShipClass = ShipFactory.CreateNewShipClass(_game, humanFaction, "Harbinger");

            for (int i = 0; i < 1000000; i++)
            {
                harbingerShipClass.Clone(_game.GlobalManager);
            }
        }
コード例 #3
0
ファイル: GameManager.cs プロジェクト: IAlpisI/DesingPatterns
 public GameManager(HttpClient client)
 {
     this.client      = client;
     lobby            = new Lobby(client);
     algorithmFactory = new AlgorithmFactory();
     player           = new Player();
     factory          = new FactionFactory();
     standart         = algorithmFactory.GetDefault("Standart");
     hopper           = algorithmFactory.GetDefault("Hopper");
     tower            = algorithmFactory.GetDefault("Tower");
     teleport         = algorithmFactory.GetDefault("Teleport");
 }
コード例 #4
0
ファイル: FactoryTests.cs プロジェクト: mqrause/Pulsar4x
        public void CreateNewFaction()
        {
            string factionName = "Terran";

            Entity faction = FactionFactory.CreateFaction(_game, factionName);
            NameDB nameDB  = faction.GetDataBlob <NameDB>();

            Assert.IsTrue(nameDB.GetName(faction) == factionName);

            Entity factioncopy = faction.Clone(faction.Manager);

            Assert.IsTrue(faction.GetValueCompareHash() == factioncopy.GetValueCompareHash(), "Hashes don't match");
        }
コード例 #5
0
        public void CreateScientist()
        {
            Entity faction = FactionFactory.CreateFaction(_game, "Terran");

            var requiredDataBlobs = new List <Type>()
            {
                typeof(CommanderDB),
                typeof(ScientistDB)
            };

            Entity scientist = CommanderFactory.CreateScientist(_game.GlobalManager, faction);

            //Assert.IsTrue(HasAllRequiredDatablobs(scientist, requiredDataBlobs), "Scientist Entity doesn't contains all required datablobs");
        }
コード例 #6
0
        public void CreateClassAndShip()
        {
            Entity     faction    = FactionFactory.CreateFaction(_game, "Terran");
            StarSystem starSystem = new StarSystem(_game, "Sol", -1);

            string shipClassName = "M6 Corvette";       //X Universe ;3
            string shipName      = "USC Winterblossom"; //Still X Universe

            var requiredDataBlobs = new List <Type>()
            {
                typeof(ShipInfoDB),
                typeof(ArmorDB),
                typeof(BeamWeaponsDB),
                typeof(BuildCostDB),
                typeof(CargoStorageDB),
                typeof(CrewDB),
                typeof(DamageDB),
                typeof(HangerDB),
                typeof(IndustryDB),
                typeof(MaintenanceDB),
                typeof(MissileWeaponsDB),
                typeof(PowerDB),
                typeof(PropulsionDB),
                typeof(SensorProfileDB),
                typeof(SensorsDB),
                typeof(ShieldsDB),
                typeof(TractorDB),
                typeof(TroopTransportDB),
                typeof(NameDB)
            };

            Entity     shipClass       = ShipFactory.CreateNewShipClass(_game, faction, shipClassName);
            ShipInfoDB shipClassInfo   = shipClass.GetDataBlob <ShipInfoDB>();
            NameDB     shipClassNameDB = shipClass.GetDataBlob <NameDB>();

            //Assert.IsTrue(HasAllRequiredDatablobs(shipClass, requiredDataBlobs), "ShipClass Entity doesn't contains all required datablobs");
            Assert.IsTrue(shipClassInfo.ShipClassDefinition == Guid.Empty, "Ship Class ShipInfoDB must have empty ShipClassDefinition Guid");
            Assert.IsTrue(shipClassNameDB.GetName(faction) == shipClassName);

            /////Ship/////
            Vector4    pos        = new Vector4(0, 0, 0, 0);
            Entity     ship       = ShipFactory.CreateShip(shipClass, starSystem.SystemManager, faction, pos, starSystem, shipName);
            ShipInfoDB shipInfo   = ship.GetDataBlob <ShipInfoDB>();
            NameDB     shipNameDB = ship.GetDataBlob <NameDB>();

            //Assert.IsTrue(HasAllRequiredDatablobs(ship, requiredDataBlobs), "Ship Entity doesn't contains all required datablobs");
            Assert.IsTrue(shipInfo.ShipClassDefinition == shipClass.Guid, "ShipClassDefinition guid must be same as ship class entity guid");
            Assert.IsTrue(shipNameDB.GetName(faction) == shipName);
        }
コード例 #7
0
ファイル: ShipTests.cs プロジェクト: UberWaffe/Pulsar4x
        public void Init()
        {
            _game = new Game(new NewGameSettings {
                GameName = "Unit Test Game", StartDateTime = DateTime.Now, MaxSystems = 1
            });

            _faction = FactionFactory.CreateFaction(_game, "Terran");
            _faction.GetDataBlob <FactionTechDB>().ResearchedTechs.Add(new Guid("b8ef73c7-2ef0-445e-8461-1e0508958a0e"), 3);
            _faction.GetDataBlob <FactionTechDB>().ResearchedTechs.Add(new Guid("08fa4c4b-0ddb-4b3a-9190-724d715694de"), 3);
            _faction.GetDataBlob <FactionTechDB>().ResearchedTechs.Add(new Guid("8557acb9-c764-44e7-8ee4-db2c2cebf0bc"), 5);
            _faction.GetDataBlob <FactionTechDB>().ResearchedTechs.Add(new Guid("35608fe6-0d65-4a5f-b452-78a3e5e6ce2c"), 1);
            _faction.GetDataBlob <FactionTechDB>().ResearchedTechs.Add(new Guid("c827d369-3f16-43ef-b112-7d5bcafb74c7"), 1); //Nuclear Thermal Engine Technology
            _faction.GetDataBlob <FactionTechDB>().ResearchedTechs.Add(new Guid("db6818f3-99e9-46c1-b903-f3af978c38b2"), 1);
            _starSystem = new StarSystem(_game, "Sol", -1);
            /////Ship Class/////
        }
コード例 #8
0
ファイル: CharacterFactory.cs プロジェクト: Ceappie/SoftUni-1
    public static Character CreateCharacter(string factionType, string characterType, string characterName)
    {
        var faction = FactionFactory.CreateFaction(factionType);

        var character = characterType;

        var name = characterName;

        if (characterType == "Warrior")
        {
            return(new Warrior(name, faction));
        }
        else if (characterType == "Cleric")
        {
            return(new Cleric(name, faction));
        }
        throw new ArgumentException($"Invalid character \"{characterType}\"!");
    }
コード例 #9
0
        public void CreateNewFaction()
        {
            string factionName = "Terran";

            var requiredDataBlobs = new List <Type>()
            {
                typeof(FactionInfoDB),
                typeof(FactionAbilitiesDB),
                typeof(NameDB),
                typeof(FactionTechDB)
            };

            Entity faction = FactionFactory.CreateFaction(_game, factionName);
            NameDB nameDB  = faction.GetDataBlob <NameDB>();
            //FactionDB factionDB = faction.GetDataBlob<FactionDB>();
            Entity factioncopy = faction.Clone(faction.Manager);

            //Assert.IsTrue(HasAllRequiredDatablobs(faction, requiredDataBlobs));
            Assert.IsTrue(nameDB.GetName(faction) == factionName);
        }
コード例 #10
0
ファイル: TestingUtilities.cs プロジェクト: mqrause/Pulsar4x
        internal TestGame(int numSystems = 10)
        {
            GameSettings = new  NewGameSettings {
                GameName = "Unit Test Game", MaxSystems = numSystems, CreatePlayerFaction = false
            };

            Game = new Game(GameSettings);

            // add a faction:
            HumanFaction = FactionFactory.CreateFaction(Game, "New Terran Utopian Empire");

            // add a species:
            HumanSpecies = SpeciesFactory.CreateSpeciesHuman(HumanFaction, Game.GlobalManager);

            // add another faction:
            GreyAlienFaction = FactionFactory.CreateFaction(Game, "The Grey Empire");
            // Add another species:
            GreyAlienSpecies = SpeciesFactory.CreateSpeciesHuman(GreyAlienFaction, Game.GlobalManager);

            // Greys Name the Humans.
            HumanSpecies.GetDataBlob <NameDB>().SetName(GreyAlienFaction.Guid, "Stupid Terrans");
            // Humans name the Greys.
            GreyAlienSpecies.GetDataBlob <NameDB>().SetName(HumanFaction.Guid, "Space bugs");


            StarSystemFactory starfac = new StarSystemFactory(Game);

            Sol         = starfac.CreateSol(Game);
            Earth       = NameLookup.GetFirstEntityWithName(Sol, "Earth"); //Sol.Entities[3]; //should be fourth entity created
            EarthColony = ColonyFactory.CreateColony(HumanFaction, HumanSpecies, Earth);

            DefaultEngineDesign = DefaultStartFactory.DefaultThrusterDesign(Game, HumanFaction);
            DefaultWeaponDesign = DefaultStartFactory.DefaultSimpleLaser(Game, HumanFaction);
            DefaultShipDesign   = DefaultStartFactory.DefaultShipDesign(Game, HumanFaction);

            Vector3 position = Earth.GetDataBlob <PositionDB>().AbsolutePosition_AU;

            DefaultShip = ShipFactory.CreateShip(DefaultShipDesign, HumanFaction, position, Earth, Sol, "Serial Peacemaker");
            Sol.SetDataBlob(DefaultShip.ID, new TransitableDB());
        }
コード例 #11
0
ファイル: TestingUtilities.cs プロジェクト: mqrause/Pulsar4x
        internal static Game CreateTestUniverse(int numSystems, DateTime testTime, bool generateDefaultHumans = false)
        {
            var gamesettings = new NewGameSettings {
                GameName = "Unit Test Game", StartDateTime = testTime, MaxSystems = numSystems, DefaultSolStart = generateDefaultHumans, CreatePlayerFaction = false
            };

            var game = new Game(gamesettings);

            var smAuthToken = new AuthenticationToken(game.SpaceMaster);

            // Systems are currently generated in the Game Constructor.
            // Later, Systems will be initialized in the game constructor, but not actually generated until player discovery.
            //game.GenerateSystems(smAuthToken, numSystems);

            // add a faction:
            Entity humanFaction = FactionFactory.CreateFaction(game, "New Terran Utopian Empire");

            // add a species:
            Entity humanSpecies = SpeciesFactory.CreateSpeciesHuman(humanFaction, game.GlobalManager);

            // add another faction:
            Entity greyAlienFaction = FactionFactory.CreateFaction(game, "The Grey Empire");
            // Add another species:
            Entity greyAlienSpecies = SpeciesFactory.CreateSpeciesHuman(greyAlienFaction, game.GlobalManager);

            // Greys Name the Humans.
            humanSpecies.GetDataBlob <NameDB>().SetName(greyAlienFaction.Guid, "Stupid Terrans");
            // Humans name the Greys.
            greyAlienSpecies.GetDataBlob <NameDB>().SetName(humanFaction.Guid, "Space bugs");
            //TODO Expand the "Test Universe" to cover more datablobs and entities. And ships. Etc.

            if (generateDefaultHumans)
            {
                DefaultStartFactory.DefaultHumans(game, "Humans");
            }

            return(game);
        }
コード例 #12
0
 public HomeController()
 {
     factionCollection        = FactionFactory.GetFactionCollection();
     weaponCategoryCollection = WeaponCategoryFactory.GetWeaponCategoryCollection();
     wargearInventory         = WargearFactory.GetWargearInventory();
 }
コード例 #13
0
        public void Init()
        {
            var gameSettings = new NewGameSettings();

            gameSettings.MaxSystems = 10;
            _game = new Game(gameSettings);
            StaticDataManager.LoadData("Pulsar4x", _game);
            _entityManager = new EntityManager(_game);
            _faction       = FactionFactory.CreateFaction(_game, "Terran"); // Terrian?


            /*_galaxyFactory = new GalaxyFactory();
             * _starSystemFactory = new StarSystemFactory(_galaxyFactory);
             *
             * _starSystem = _starSystemFactory.CreateSol(_game);*/// Seems unnecessary for now

            _gasDictionary = new Dictionary <string, AtmosphericGasSD>();

            foreach (WeightedValue <AtmosphericGasSD> atmos in _game.StaticData.AtmosphericGases)
            {
                _gasDictionary.Add(atmos.Value.ChemicalSymbol, atmos.Value);
            }


            // Create Earth
            _earthPlanet    = setEarthPlanet();
            _coldPlanet     = setEarthPlanet();
            _hotPlanet      = setEarthPlanet();
            _lowGravPlanet  = setEarthPlanet();
            _highGravPlanet = setEarthPlanet();


            _coldPlanet.GetDataBlob <SystemBodyInfoDB>().BaseTemperature = -20.0f;
            _hotPlanet.GetDataBlob <SystemBodyInfoDB>().BaseTemperature  = 120.0f;
            _lowGravPlanet.GetDataBlob <SystemBodyInfoDB>().Gravity      = 0.05;
            _highGravPlanet.GetDataBlob <SystemBodyInfoDB>().Gravity     = 5.0;

            _faction = FactionFactory.CreateFaction(_game, "Terran");

            _humanSpecies    = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager);
            _exampleSpecies  = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager);
            _lowGravSpecies  = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager);
            _highGravSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager);
            _lowTempSpecies  = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager);
            _highTempSpecies = SpeciesFactory.CreateSpeciesHuman(_faction, _entityManager);

            _humanSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange    = 20;
            _exampleSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange  = 20;
            _lowGravSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange  = 20;
            _highGravSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20;
            _lowTempSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange  = 20;
            _highTempSpecies.GetDataBlob <SpeciesDB>().TemperatureToleranceRange = 20;


            _lowGravSpecies.GetDataBlob <SpeciesDB>().BaseGravity = 0.4;
            _lowGravSpecies.GetDataBlob <SpeciesDB>().MaximumGravityConstraint = 0.5;
            _lowGravSpecies.GetDataBlob <SpeciesDB>().MinimumGravityConstraint = 0.01;


            _highGravSpecies.GetDataBlob <SpeciesDB>().BaseGravity = 4.0;
            _highGravSpecies.GetDataBlob <SpeciesDB>().MaximumGravityConstraint = 5.5;
            _highGravSpecies.GetDataBlob <SpeciesDB>().MinimumGravityConstraint = 4.5;

            _lowTempSpecies.GetDataBlob <SpeciesDB>().BaseTemperature = -50.0;
            _lowTempSpecies.GetDataBlob <SpeciesDB>().MaximumTemperatureConstraint = 0.0;
            _lowTempSpecies.GetDataBlob <SpeciesDB>().MinimumTemperatureConstraint = -100.0;

            _highTempSpecies.GetDataBlob <SpeciesDB>().BaseTemperature = 200.0;
            _highTempSpecies.GetDataBlob <SpeciesDB>().MaximumTemperatureConstraint = 300.0;
            _highTempSpecies.GetDataBlob <SpeciesDB>().MinimumTemperatureConstraint = 100.0;
        }