Exemplo n.º 1
0
        public void ShouldSideFieldThrowsSquare(Side location)
        {
            var fieldSetting = new FieldSetting()
            {
                HorzDimension = 5, VertDimension = 4, SideDimension = 3
            };
            var sideField = SideField.Create(fieldSetting, location);

            bool same = true;

            for (uint i = 0; i < sideField.Width; i++)
            {
                var color       = sideField[i, 0].Color;
                var secondColor = sideField[i, 1].Color;
                var thirdColor  = sideField[i, 2].Color;

                var throwColor = sideField.Pop(i);
                color.ShouldBe(throwColor);
                sideField[i, 0].Color.ShouldBe(secondColor);
                sideField[i, 1].Color.ShouldBe(thirdColor);

                sideField[i, 2].Color.ShouldNotBe(Color.None);

                same &= sideField[i, 2].Color == thirdColor;
            }

            same.ShouldBeFalse();
        }
Exemplo n.º 2
0
        public void ShouldCreateSideField(Side location, Direction direction)
        {
            var fieldSetting = new FieldSetting()
            {
                HorzDimension = 5, VertDimension = 4, SideDimension = 3
            };
            var sideField = SideField.Create(fieldSetting, location);

            var width = (location == Side.Left || location == Side.Right) ? fieldSetting.VertDimension : fieldSetting.HorzDimension;

            sideField.Width.ShouldBe(width);
            sideField.Height.ShouldBe(fieldSetting.SideDimension);
            sideField.ThrowDirection.Value.ShouldBe(direction);
        }
Exemplo n.º 3
0
        public void SholdGenerateValuesForSideFields()
        {
            var fieldSetting = new FieldSetting()
            {
                HorzDimension = 5, VertDimension = 4, SideDimension = 3
            };
            var sideField = SideField.Create(fieldSetting, Side.Bottom);

            sideField.Generate();

            sideField.ForEach((item) =>
            {
                item.Color.ShouldNotBe(Color.None);
            });
        }
Exemplo n.º 4
0
        public void ShouldReturnReadonlyMatrix()
        {
            var fieldSetting = new FieldSetting()
            {
                HorzDimension = 5, VertDimension = 4, SideDimension = 3
            };
            var sideField = SideField.Create(fieldSetting, Side.Bottom);


            var matrix = sideField.ToReadonlyMatrix();

            matrix.ShouldNotBeNull();

            sideField.ForEach((item, x, y) => matrix[x, y].ShouldBe(item));
        }
Exemplo n.º 5
0
        public Scene(FieldSetting setting)
        {
            _matrixField = MainField.Create(setting);
            _sideFields  = new Dictionary <Side, SideField>
            {
                [Side.Top]    = SideField.Create(setting, Side.Top),
                [Side.Left]   = SideField.Create(setting, Side.Left),
                [Side.Bottom] = SideField.Create(setting, Side.Bottom),
                [Side.Right]  = SideField.Create(setting, Side.Right)
            };

            _movingSquare = new MovingSquare();
            _movingSquare.StateChanged += HandleMovingSquareStateChangedEvent;

            _score = new Score(setting);
            _score.ScoreUpdated += HandleScoreUpdatedEvent;

            _stateManagers = new List <IStateManager>();
            InitStateManagersList();
        }
Exemplo n.º 6
0
        public void ShouldSideFieldPutsSquare(Side location)
        {
            var fieldSetting = new FieldSetting()
            {
                HorzDimension = 5, VertDimension = 4, SideDimension = 3
            };
            var sideField = SideField.Create(fieldSetting, location);

            for (uint i = 0; i < sideField.Width; i++)
            {
                var color       = sideField[i, 0].Color;
                var secondColor = sideField[i, 1].Color;

                sideField.Push(i, Color.Red);

                sideField[i, 0].Color.ShouldBe(Color.Red);
                sideField[i, 1].Color.ShouldBe(color);

                sideField[i, 2].Color.ShouldBe(secondColor);
            }
        }