예제 #1
0
            public void Consecutive_horizontal_cells_should_be_at_colOffset()
            {
                var gridBehaviourMock = Substitute.For <IGridSpawnBeaviour>();

                gridBehaviourMock.RowOffset.Returns(URandom.value * 100);
                gridBehaviourMock.ColOffset.Returns(URandom.value * 100);

                GridPattern pattern = Build_a.GridPattern
                                      .With_a_row_count_of(3)
                                      .Has_pattern(1, 1, 1,
                                                   1, 1, 1,
                                                   1, 1, 1);

                var gridSpawner    = new GridSpawnLocations(gridBehaviourMock);
                var spawnLocations = gridSpawner.GenerateSpawnLocationsFor(pattern);


                for (int r = 0; r < spawnLocations.GetLength(0); r++)
                {
                    var c0 = (Vector3)spawnLocations[r, 0];
                    var c1 = (Vector3)spawnLocations[r, 1];
                    var c2 = (Vector3)spawnLocations[r, 2];

                    Assert.AreEqual(gridBehaviourMock.ColOffset,
                                    Vector3.Distance(c0, c1));
                    Assert.AreEqual(gridBehaviourMock.ColOffset,
                                    Vector3.Distance(c1, c2));
                    Assert.AreEqual(gridBehaviourMock.ColOffset * 2,
                                    Vector3.Distance(c0, c2));
                }
            }
예제 #2
0
            public void Consecutive_vertical_cells_should_be_at_rowOffset()
            {
                var gridBehaviourMock = Substitute.For <IGridSpawnBeaviour>();

                gridBehaviourMock.RowOffset.Returns(URandom.value * 100);
                gridBehaviourMock.ColOffset.Returns(URandom.value * 100);

                GridPattern pattern = Build_a.GridPattern
                                      .With_a_row_count_of(3)
                                      .With_a_col_count_of(3)
                                      .Has_pattern(1, 1, 1,
                                                   1, 1, 1,
                                                   1, 1, 1);

                var gridSpawner    = new GridSpawnLocations(gridBehaviourMock);
                var spawnLocations = gridSpawner.GenerateSpawnLocationsFor(pattern);

                for (int c = 0; c < spawnLocations.GetLength(1); c++)
                {
                    var r0 = (Vector3)spawnLocations[0, c];
                    var r1 = (Vector3)spawnLocations[1, c];
                    var r2 = (Vector3)spawnLocations[2, c];

                    Assert.AreEqual(gridBehaviourMock.RowOffset,
                                    Vector3.Distance(r0, r1));
                    Assert.AreEqual(gridBehaviourMock.RowOffset,
                                    Vector3.Distance(r1, r2));
                    Assert.AreEqual(gridBehaviourMock.RowOffset * 2,
                                    Vector3.Distance(r0, r2));
                }
            }
예제 #3
0
            public void Should_have_same_size_as_of_number_of_true_cells()
            {
                var         gridBehaviourMock = Substitute.For <IGridSpawnBeaviour>();
                GridPattern pattern           = Build_a.GridPattern
                                                .With_a_row_count_of(3)
                                                .Has_pattern(0, 0, 1,
                                                             1, 0, 0,
                                                             1, 1, 0);

                var gridSpawner    = new GridSpawnLocations(gridBehaviourMock);
                var spawnLocations = gridSpawner.GenerateSpawnLocationsFor(pattern);

                var nonNullPositions = 0;

                for (int r = 0; r < spawnLocations.GetLength(0); r++)
                {
                    for (int c = 0; c < spawnLocations.GetLength(1); c++)
                    {
                        if (spawnLocations[r, c] != null)
                        {
                            nonNullPositions++;
                        }
                    }
                }

                Assert.IsNotNull(spawnLocations);
                Assert.AreEqual(nonNullPositions, pattern.GetNumberOfCellsWhichHaveCarInIt());
            }
예제 #4
0
        private void Awake()
        {
            gridSpawn         = new GridSpawnLocations(this);
            carsWaitingToMove = new List <ACarType>();
            carsWhichCanMove  = new Dictionary <string, ACarType>();

            minimumYPositionClosestCarHasToMoveBeforeSpawningNew = transform.position.y - rowOffset * 4;
        }
예제 #5
0
 private void Awake()
 {
     gridSpawn = new GridSpawnLocations(this);
     enemyCarsPool.InitializePools();
 }