Exemplo n.º 1
0
        public void IFoundTheRegion()
        {
            var configuration = new RegionManagerConfiguration()
            {
                Columns   = 3,
                Rows      = 3,
                TotalSize = new Size(120, 120)
            };
            var blocks = new List <Block>
            {
                new BasicBlock(null, new Size(10, 10))
                {
                    Position = new Vector2(15, 15)
                },
                new BasicBlock(null, new Size(10, 10))
                {
                    Position = new Vector2(35, 15)
                }
            };

            RegionManager regionManager = new RegionManager(configuration, blocks);
            var           blocksNear    = regionManager.GetBlocksByRegion(new Vector2(15, 5));

            List <IBlock> found = new List <IBlock>(blocksNear);

            Assert.AreEqual(found.Count, 2);
        }
Exemplo n.º 2
0
        //Este debería mirar los límites, no el playing state (creo)
        public Board(List <IBlock> blocks, List <IBlock> irromptableBlocks, Size boardSize, float ballDiameter)
        {
            _blocks             = blocks;
            _irromptableBlocks  = irromptableBlocks;
            _actionsOnCollision = new Dictionary <BlockCollisionType, CollisionDetected>()
            {
                { BlockCollisionType.Left, OnLeftCollision },
                { BlockCollisionType.Top, OnTopCollision },
                { BlockCollisionType.Right, OnRightCollision },
                { BlockCollisionType.Bottom, OnBottomCollision }
            };

            //Esto es Ball.Size.Width * Ball.Scale
            _ballDiameter = ballDiameter;
            _ballRadius   = _ballDiameter / 2;

            List <IBlock> allBlocks = new List <IBlock>(_blocks);

            allBlocks.AddRange(_irromptableBlocks);

            foreach (IBlock block in _blocks) //Creo que aqui no hace falta todos porque los irrompibles me dan igual
            {
                block.AddObserver(this);
            }

            var regionManagerConfiguration = new RegionManagerConfiguration
            {
                Columns   = 3,
                Rows      = 5,
                TotalSize = boardSize
            };

            _regionManager = new RegionManager(regionManagerConfiguration, allBlocks);

            _blockCollisionDetector = new BallBlockCollisionDetector(allBlocks, _ballDiameter);
        }