Ejemplo n.º 1
0
        public void GalaxyBoundsShouldDeserialize(int size)
        {
            var original = new GalaxyBounds(size);

            var restored = SerializeAndDeserialize(original);

            Assert.Equal(original, restored);
        }
Ejemplo n.º 2
0
        private static Game CreateGame()
        {
            var game = new Game()
            {
                Rules = new GameRules(),

                Players = new EntityStore <Player>
                {
                    new Player()
                    {
                        Id   = 1,
                        Name = "Player One",
                    },
                },

                Galaxy = new Galaxy()
                {
                    Bounds = new GalaxyBounds(800),

                    Planets = new EntityStore <Planet>
                    {
                        new Planet()
                        {
                            Id       = 1,
                            Name     = "Planet One",
                            Position = new Position(100, 100),
                            Details  = new PlanetDetails()
                            {
                                Environment = new Environment(10, 50, 20),
                                Minerals    = new Minerals(20, 30, 50),
                            },
                            Settlement = new Settlement()
                            {
                                OwnerId       = 1,
                                Population    = new Population(10_000),
                                Installations = new Installations
                                {
                                    Scanner = 100,
                                },
                            },
                        },
                    },
                },
Ejemplo n.º 3
0
        public void PlanetsHaveValidPositions(int size, int planets, int padding)
        {
            var generator = new GalaxyGenerator();

            var settings = new GalaxyGeneratorSettings()
            {
                GalaxySize  = size,
                PlanetCount = planets,
                Padding     = padding,
            };

            var galaxy = generator.Generate(settings);
            var bounds = new GalaxyBounds(size);
            var min    = bounds.Min + padding;
            var max    = bounds.Max - padding;

            Assert.All(galaxy.Planets, planet => Assert.True(PointInRange(planet.Position)));

            bool CoordInRange(int coord) => coord >= min && coord <= max;
            bool PointInRange(Position position) => CoordInRange(position.X) && CoordInRange(position.Y);;
        }