示例#1
0
        private void CreateTestUniverse()
        {
            _game = new Game(new NewGameSettings {
                GameName = "Pathfinding Test Game", StartDateTime = DateTime.Now, MaxSystems = 10
            });
            _pathfindingManager = new PathfindingManager(_game);

            _testPlayer = _game.AddPlayer("TestPlayer");
            _authToken  = new AuthenticationToken(_testPlayer.ID);

            _humanFaction = DefaultStartFactory.DefaultHumans(_game, _testPlayer, "TestHumanFaction");

            List <StarSystem> systems = _game.GetSystems(new AuthenticationToken(_game.SpaceMaster.ID));
            var factionInfoDB         = _humanFaction.GetDataBlob <FactionInfoDB>();

            List <StarSystem> testPlayerSystems = _game.GetSystems(_authToken);

            StarSystem starSystem;
            StarSystem sol = testPlayerSystems[0];
            Random     RNG = new Random();

            do
            {
                starSystem = systems[RNG.Next(systems.Count - 1)];
            } while (starSystem == sol);

            factionInfoDB.KnownSystems.Add(starSystem.Guid);
        }
示例#2
0
        public void Init()
        {
            NewGameSettings settings = new NewGameSettings();

            settings.MaxSystems = 5;

            _game = new Game(settings);
            StaticDataManager.LoadData("Pulsar4x", _game);
            _player  = _game.AddPlayer("Test Player");
            _faction = DefaultStartFactory.DefaultHumans(_game, _player, "Test Faction");

            _starSystem = _game.Systems.First <KeyValuePair <Guid, StarSystem> >().Value;
            _planets    = _starSystem.SystemManager.GetAllEntitiesWithDataBlob <SystemBodyInfoDB>();

            _earth = _planets.Where <Entity>(planet => planet.GetDataBlob <NameDB>().GetName(_faction) == "Earth").First <Entity>();

            _ship             = _starSystem.SystemManager.GetAllEntitiesWithDataBlob <ShipInfoDB>().First <Entity>();
            _shipPropulsionDB = _ship.GetDataBlob <PropulsionDB>();
            _target           = _ship.Clone(_starSystem.SystemManager);

            _systems = new List <StarSystem>();

            foreach (KeyValuePair <Guid, StarSystem> kvp in _game.Systems)
            {
                _systems.Add(kvp.Value);
            }
        }
        public void StarSystemImportExport()
        {
            _game        = TestingUtilities.CreateTestUniverse(10);
            _smAuthToken = new AuthenticationToken(_game.SpaceMaster);

            Assert.NotNull(_game);

            // Choose a procedural system.
            List <StarSystem> systems = _game.GetSystems(_smAuthToken);
            var        rand           = new Random();
            int        systemIndex    = rand.Next(systems.Count - 1);
            StarSystem system         = systems[systemIndex];

            ImportExportSystem(system);

            //Now do the same thing, but with Sol.
            DefaultStartFactory.DefaultHumans(_game, "Humans");

            systems = _game.GetSystems(_smAuthToken);
            system  = systems[systems.Count - 1];
            ImportExportSystem(system);
        }
示例#4
0
        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);
        }