Exemplo n.º 1
0
 private void Start()
 {
     enemyHp = GetComponent <EnemyHp>();
     enemyHp.OnEnemyKilled += EnemyHp_OnEnemyKilled;
     rb     = GetComponent <Rigidbody2D>();
     sqspwn = GetComponent <SquareSpawner>();
 }
Exemplo n.º 2
0
        public void SpawnSquares_WhenNoEmptySpace_Throws()
        {
            //arrange
            var container = Substitute.For <IBoardContainer>();

            container.Height.Returns(3);
            container.Width.Returns(3);
            container.Squares.Returns(new ObservableCollection <SquareViewModel>()
            {
                new SquareViewModel {
                    X = 0, Y = 0
                },
                new SquareViewModel {
                    X = 1, Y = 0
                },
                new SquareViewModel {
                    X = 2, Y = 0
                },
                new SquareViewModel {
                    X = 0, Y = 1
                },
                new SquareViewModel {
                    X = 1, Y = 1
                },
                new SquareViewModel {
                    X = 2, Y = 1
                },
                new SquareViewModel {
                    X = 0, Y = 2
                },
                new SquareViewModel {
                    X = 1, Y = 2
                },
                new SquareViewModel {
                    X = 2, Y = 2
                }
            });

            var sut = new SquareSpawner(container);

            //act
            //assert
            Assert.Throws <BoardOutOfSpaceException>(() =>
            {
                sut.SpawnSquares(1);
            });
        }
Exemplo n.º 3
0
        public void SpawnSquares_When2PlacesRemainingAnd2SquaresAreToBeSpawned_FillsWholeBoard()
        {
            //arrange
            var container = Substitute.For <IBoardContainer>();

            container.Height.Returns(3);
            container.Width.Returns(3);
            container.Squares.Returns(new ObservableCollection <SquareViewModel>()
            {
                new SquareViewModel {
                    X = 0, Y = 0
                },
                new SquareViewModel {
                    X = 1, Y = 0
                },
                new SquareViewModel {
                    X = 2, Y = 0
                },
                new SquareViewModel {
                    X = 0, Y = 1
                },
                new SquareViewModel {
                    X = 1, Y = 1
                },
                new SquareViewModel {
                    X = 2, Y = 1
                },
                new SquareViewModel {
                    X = 0, Y = 2
                },
            });

            var sut = new SquareSpawner(container);

            //act
            sut.SpawnSquares(2);
            //assert
            Assert.That(container.Squares.Count == container.Height * container.Width);
        }