Exemple #1
0
        //this is coupled with a few things it doesn't need to be.
        public void Hit(IList<IItem> items, bool isMario, bool isBig, HUD hud, SoundEffects sound)
        {
            switch (state)
            {
                case BrickState.bstar:
                    sound.Popup();
                    IItem star = new Items.Star(xPosition, yPosition - 16, camera);
                    items.Add(star);
                    state = BrickState.qempty;
                    BrickSprite = new Sprites.HitQBlockSprite();
                    break;

                case BrickState.bcoin:
                    sound.Coin();
                    IItem c;
                    //make the coin noise
                    c = new Items.Coin(xPosition, yPosition - Constants.tileLength, camera);
                    items.Add(c);
                    if (isMario)
                    {
                        hud.increaseScoreMario(Constants.brokenBrickValue);
                        hud.addCoinMario();
                    }
                    else
                    {
                        hud.increaseScoreLuigi(Constants.brokenBrickValue);
                        hud.addCoinLuigi();
                    }
                    state = BrickState.qempty;
                    BrickSprite = new Sprites.HitQBlockSprite();
                    break;

                case BrickState.bempty:
                    if (isBig)
                    {
                        sound.BreakBlock();
                        if (isMario)
                        {
                            hud.increaseScoreMario(Constants.brokenBrickValue);
                        }
                        else
                        {
                            hud.increaseScoreLuigi(Constants.brokenBrickValue);
                        }
                        state = BrickState.destroyed;
                        BrickSprite = null;
                    }
                    break;

                case BrickState.qitem:
                    IItem i;
                    sound.Popup();
                    if (!isBig) {
                        i = new Items.Mushroom(xPosition, yPosition - Constants.tileLength, camera);
                    }

                    else {
                        i = new Items.Fireflower(xPosition, yPosition - Constants.tileLength, camera);
                    }
                    items.Add(i);
                    state = BrickState.qempty;
                    BrickSprite = new Sprites.HitQBlockSprite();
                    break;

                case BrickState.qlife:
                    items.Add(new Items.Oneup(xPosition, yPosition - Constants.tileLength, camera));
                    state = BrickState.qempty;
                    BrickSprite = new Sprites.HitQBlockSprite();
                    break;

                case BrickState.qcoin:
                    sound.Coin();
                    //make the coin noise
                    c = new Items.Coin(xPosition, yPosition - Constants.tileLength, camera);
                    items.Add(c);
                    if (isMario)
                    {
                        hud.increaseScoreMario(Constants.brokenBrickValue);
                        hud.addCoinMario();
                    }
                    else
                    {
                        hud.increaseScoreLuigi(Constants.brokenBrickValue);
                        hud.addCoinLuigi();
                    }
                    state = BrickState.qempty;
                    BrickSprite = new Sprites.HitQBlockSprite();
                    break;
                default:
                    break;
            }
        }