Exemplo n.º 1
0
        public void CheckBlockCollisions(List <IBlock> blocks, List <IPlayer> players)
        {
            Game1.Side             collisionType;
            BlockCollisionDetector blockDetector  = new BlockCollisionDetector();
            BlockGravityHandler    gravityHandler = new BlockGravityHandler();

            foreach (IBlock block in blocks)
            {
                if (block is BrickBlock)
                {
                    Rectangle currentBlock = block.GetRectangle();
                    foreach (IPlayer player in players)
                    {
                        Rectangle currentPlayer = player.GetRectangle();

                        collisionType = blockDetector.DetermineCollision(currentBlock, currentPlayer);

                        if (collisionType.Equals(Game1.Side.Top))
                        {
                            block.ChangeState(Game1.Side.Top);
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void BreakBlock()
        {
            block1 = new BrokenBrickBlock(new Vector2(location.X + 10, location.Y));
            block2 = new BrokenBrickBlock(new Vector2(location.X - 10, location.Y));
            block3 = new BrokenBrickBlock(new Vector2(location.X + 10, location.Y + 10));
            block4 = new BrokenBrickBlock(new Vector2(location.X - 10, location.Y + 10));

            BlockGravityHandler gravityHandler = new BlockGravityHandler();

            gravityHandler.ApplyGravityToBlock(this);
        }