コード例 #1
0
        public void throw_if_landing_area_boundaries_are_bigger_than_limits(int x, int width, int y, int height)
        {
            var    landingArea = new LandingArea(x, width, y, height);
            Action action      = () => new Platform(landingArea, PlatformWidth, PlatformHeight);

            action.Should().Throw <ArgumentException>();
        }
コード例 #2
0
 public void Create_LandingArea_With_LandPlatform_Out_Throw_ArgumentException()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var landingArea = new LandingArea(100, 100, new Coordinate(1, 3), 100, 100);
     });
 }
コード例 #3
0
 public void Create_LandingArea_With_0_Size()
 {
     Assert.Throws <ArgumentException>(() =>
     {
         var landingArea = new LandingArea(0, 0, new Coordinate(1, 3), 100, 100);
     });
 }
コード例 #4
0
 public void SetupLandingArea(LandingArea landingArea)
 {
     if (_landingArea == null)
     {
         _landingArea = landingArea;
     }
 }
コード例 #5
0
            protected override void Given()
            {
                const int areaDimensionX     = 100;
                const int areaDimensionY     = 100;
                const int platformDimensionX = 50;
                const int platformDimensionY = 50;

                _positionX = 20;
                _positionY = 40;

                var approachCheckResultMapper = new ApproachCheckResultMapper();
                var strategy          = new ZartisExerciseStrategy();
                var platformDimension = new Dimension(platformDimensionX, platformDimensionY);
                var platform          = new LandingPlatform(platformDimension, strategy);
                var areaDimension     = new Dimension(areaDimensionX, areaDimensionY);
                var area   = new LandingArea(areaDimension, platform, approachCheckResultMapper);
                var rocket = new Rocket(area);

                rocket.CheckApproach(_positionX, _positionY);

                _sut = new Rocket(area);

                _expectedResult = "ok for landing";
                _farPositionX   = _positionX + 2;
            }
コード例 #6
0
            protected override void Given()
            {
                const int areaDimensionX     = 100;
                const int areaDimensionY     = 100;
                const int platformDimensionX = 50;
                const int platformDimensionY = 50;

                var platformDimension = new Dimension(platformDimensionX, platformDimensionY);
                var areaDimension     = new Dimension(areaDimensionX, areaDimensionY);

                _rocketId = GuidGenerator.Create(1);
                _position = Mock.Of <IPosition>();

                _platformMock = new Mock <ILandingPlatform>();
                _platformMock
                .Setup(m => m.GetDimension())
                .Returns(platformDimension);
                _platformMock
                .Setup(m => m.CheckApproach(_rocketId, _position))
                .Returns(ApproachCheckResult);
                var platform = _platformMock.Object;

                _expectedResult = "ok";
                _approachCheckResultMapperMock = new Mock <IApproachCheckResultMapper>();
                _approachCheckResultMapperMock
                .Setup(m => m.Map(ApproachCheckResult))
                .Returns(_expectedResult);
                var approachCheckResultMapper = _approachCheckResultMapperMock.Object;

                _sut = new LandingArea(areaDimension, platform, approachCheckResultMapper);
            }
コード例 #7
0
            protected override void Given()
            {
                const int x = 5;
                const int y = 5;

                var positionOne =
                    new PositionBuilder()
                    .WithX(x)
                    .WithY(y)
                    .Build();

                _positionTwo =
                    new PositionBuilder()
                    .WithX(x + 2)
                    .WithY(y + 2)
                    .Build();

                var landingPlatform =
                    new LandingPlatformMockBuilder()
                    .WithIsPositionInsideOfPlatformMocked(IsPositionInsideOfThePlatform)
                    .WithIsAllowedPositionMocked(IsAllowedPosition)
                    .Build();

                _sut =
                    new LandingAreaBuilder()
                    .WithLandingPlatform(landingPlatform)
                    .Build();

                _sut.CheckPosition(positionOne);

                _expectedResult    = LandingAnswer;
                _expectedPositions = StoredPositions;
            }
コード例 #8
0
        public void Setup()
        {
            var landingArea = new LandingArea(5, 10, 5, 10);

            platform      = new Platform(landingArea, PlatformWidth, PlatformHeight);
            rocketId      = Guid.NewGuid().ToString();
            otherRocketId = Guid.NewGuid().ToString();
        }
コード例 #9
0
        public void AskForPosition_Return_OkForLanding()
        {
            var landingArea = new LandingArea(100, 100, new Coordinate(5, 5), 10, 10);

            var result = landingArea.AskForPosition(5, 5);

            Assert.AreEqual(result, LandingCondition.OkForLanding);
        }
コード例 #10
0
        public void AskForPosition_Return_OutOfPlatform()
        {
            var landingArea = new LandingArea(100, 100, new Coordinate(5, 5), 10, 10);

            var result = landingArea.AskForPosition(15, 16);

            Assert.AreEqual(result, LandingCondition.OutOfPlatform);
        }
コード例 #11
0
    void TargetLandingArea()
    {
        landingArea = FindObjectOfType <LandingArea>();
        offsetXZ    = CalculateOffsetInXZPlane();

        Quaternion rotation = Quaternion.LookRotation(offsetXZ.normalized);

        transform.rotation = rotation; // Align Heli with Landing Area
    }
コード例 #12
0
        public void TwoRockets_AskForAdjacentPosition_Return_Crash()
        {
            var landingArea = new LandingArea(100, 100, new Coordinate(5, 5), 10, 10);

            var result  = landingArea.AskForPosition(7, 7);
            var result2 = landingArea.AskForPosition(8, 7);

            Assert.AreEqual(result2, LandingCondition.Clash);
        }
コード例 #13
0
        /// <summary>
        /// Positions the platform in landing area.
        /// </summary>
        /// <param name="landingArea">The landing area.</param>
        /// <param name="platform">The platform.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public void PositionatePlatformOnLandingArea(LandingArea landingArea, Platform platform)
        {
            var landingAreaPositions = registeredPositions.FirstOrDefault(x => x.OwnerId == landingArea.Id);
            var platformPositions    = registeredPositions.FirstOrDefault(x => x.OwnerId == platform.Id);

            platformPositions.Positions.ForEach(x =>
            {
                landingAreaPositions.Positions
                .FirstOrDefault(y => y.PositionX == x.PositionX && y.PositionY == x.PositionY).IsAvailable = false;
            });
        }
コード例 #14
0
ファイル: Helicopter.cs プロジェクト: TReinke001/ZombieRunner
 public void Helifly()
 {
     if (called == true)
     {
         landingArea        = FindObjectOfType <LandingArea>();
         transform.position = Vector3.MoveTowards(transform.position, destination, 30 * Time.deltaTime);
     }
     if (transform.position == destination)
     {
         called  = false;
         landing = true;
     }
 }
コード例 #15
0
            protected override void Given()
            {
                _position = new PositionBuilder().Build();

                var landingPlatform =
                    new LandingPlatformMockBuilder()
                    .WithIsPositionInsideOfPlatformMocked(IsPositionInsideOfThePlatform)
                    .Build();

                _sut =
                    new LandingAreaBuilder()
                    .WithLandingPlatform(landingPlatform)
                    .Build();

                _expectedResult    = LandingAnswer;
                _expectedPositions = StoredPositions;
            }
コード例 #16
0
        /// <summary>
        /// Creates the landing zone.
        /// </summary>
        public LandingArea CreateLandingZone(string description, double areaX, double areaY)
        {
            LandingArea landingArea = new LandingArea()
            {
                Id          = Guid.NewGuid(),
                Description = description,
                AreaX       = areaX,
                AreaY       = areaY,
                fieldsX     = Math.Sqrt(areaX),
                fieldsY     = Math.Sqrt(areaY)
            };

            var positionsList = _positionService.GetPositionsList(landingArea.AreaX, landingArea.AreaY);

            landingArea.AreaPositions = positionsList;
            landingAreaList.Add(landingArea);

            _positionService.AddPosition(landingArea.Id, positionsList);

            return(landingArea);
        }
コード例 #17
0
        /// <summary>
        /// Gets the board.
        /// </summary>
        /// <param name="landingArea">The landing area.</param>
        /// <returns></returns>
        public StringBuilder GetDrawLandingArea(LandingArea landingArea)
        {
            List <Position> positionList = landingArea.AreaPositions;
            StringBuilder   board        = new StringBuilder();
            double          counter      = landingArea.AreaX;

            for (int i = 1; i <= counter; i++)
            {
                var tempList = positionList.Where(p => p.PositionX == i);

                foreach (var item in tempList)
                {
                    var stringPositionX = item.PositionX.ToString().Length <= 1 ? $"0{item.PositionX}" : $"{item.PositionX}";
                    var stringPositionY = item.PositionY.ToString().Length <= 1 ? $"0{item.PositionY}" : $"{item.PositionY}";

                    board.Append($"|{stringPositionX},{stringPositionY}|");
                }
                board.Append(Environment.NewLine);
            }

            return(board);
        }
コード例 #18
0
        /// <summary>
        /// Creates the landing platform.
        /// </summary>
        /// <param name="landingArea">The landing area.</param>
        /// <param name="descripcion">The descripcion.</param>
        /// <param name="areaX">The area x.</param>
        /// <param name="areaY">The area y.</param>
        /// <param name="minRocketSpace">The minimum rocket space.</param>
        /// <returns></returns>
        public Platform CreateLandingPlatform(LandingArea landingArea, string descripcion, double areaX, double areaY, int minRocketSpace, double landingAreaX, double landingAreaY)
        {
            Platform platform = new Platform()
            {
                Id             = Guid.NewGuid(),
                LandingArea    = landingArea,
                Description    = descripcion,
                AreaX          = areaX,
                AreaY          = areaY,
                MinRocketSpace = minRocketSpace,
                LandingAreaX   = landingAreaX,
                LandingAreaY   = landingAreaY
            };

            _landingAreaService.AddPlatform(landingArea.Id, platform);

            var positionList = _positionService.GetPositionsList(platform.AreaX, platform.AreaY);

            _positionService.AddPosition(platform.Id, positionList);
            _positionService.PositionatePlatformOnLandingArea(landingArea, platform);

            return(platform);
        }
コード例 #19
0
 protected override void When()
 {
     _expectedException = Record.Exception(
         () => _sut     = new LandingArea(_areaDimension, _platform, _approachCheckResultMapper));
 }
コード例 #20
0
ファイル: Player.cs プロジェクト: jtownsend54/zombie-runner
    void CreateLandingArea()
    {
        LandingArea area = Instantiate(landingArea);

        area.transform.position = transform.position;
    }
コード例 #21
0
 public LandingResolver(LandingArea landingArea)
 {
     LandingArea      = landingArea ?? throw new ArgumentNullException(nameof(landingArea));
     LandingOperation = new LandingOperation(LandingArea);
 }
コード例 #22
0
        public LandingArea Build()
        {
            var landingArea = new LandingArea(_dimension, _landingPlatform);

            return(landingArea);
        }
コード例 #23
0
        public void Create_LandingArea()
        {
            var landingArea = new LandingArea(100, 100, new Coordinate(1, 1), 5, 5);

            Assert.AreEqual(landingArea.AreaDimension, 100 * 100);
        }
コード例 #24
0
 public LandingOperation(LandingArea landingArea)
 {
     LandingArea     = landingArea ?? throw new ArgumentNullException(nameof(landingArea));
     MatrixOperation = new MatrixOperation(LandingArea.Matrix);
     Coordinates     = new List <Coordinate>();
 }
コード例 #25
0
 protected override void When()
 {
     _sut = new LandingArea(_areaDimension, _platform, _approachCheckResultMapper);
 }
コード例 #26
0
 protected override void When()
 {
     _sut = new LandingArea(_dimension, _landingPlatform);
 }