Esempio n. 1
0
        public static void StartGame(GameState providedGameState = default)
        {
            var effectiveGameState = providedGameState;

            if (effectiveGameState == default)
            {
                effectiveGameState = new GameState();
                effectiveGameState.ConsumptionRates = consumptionRates;
                effectiveGameState.Ship             = ShipGenerator.GenerateShip(ShipGenerator.ShipTypes[0]);
                //{
                //    ConsumptionRates = consumptionRates,
                //    Ship = ShipGenerator.GenerateShip(ShipGenerator.ShipTypes[0]),
                //    Options = new GameStateOptions()
                //    {
                //        AreAnimationsEnabled = true,
                //        BackgroundVolume = 0.125f
                //    }
                //};

                effectiveGameState.Planets.AddRange(PlanetGenerator.GeneratePlanets(4));
                effectiveGameState.CurrentScene = SceneNames.Far;
            }

            GameState = effectiveGameState;
            ChangeScene(effectiveGameState.CurrentScene);
        }
        public void GenerateShip_WithSmallerPanelThanShip_ThrowsInvalidArgumentException()
        {
            ShipGenerator generator = new ShipGenerator();
            var           panelSize = 3;

            Action a = () => generator.GenerateShip(new ShipType("Battleship", "B", 5), panelSize);

            a.Should().Throw <ArgumentException>();
        }
        public void GenerateShip_WithNormalSizePanel_ReturnsValidShip()
        {
            ShipGenerator generator = new ShipGenerator();

            var panelSize = 10;
            var ship      = generator.GenerateShip(new ShipType("Battleship", "B", 5), panelSize);

            ship.HeadPoint.X.Should().BeLessThan(panelSize);
            ship.HeadPoint.Y.Should().BeLessThan(panelSize);
            ship.TailPoint.Y.Should().BeLessThan(panelSize);
            ship.TailPoint.Y.Should().BeLessThan(panelSize);
        }