コード例 #1
0
        /// <summary>
        /// Adds a bonus.
        /// </summary>
        /// <param name="oneBrick">The one brick.</param>
        private void AddBonus(Brick oneBrick)
        {
            string bonusImage = "";
            Bonus.bonusType type = Bonus.bonusType.BallBigger;

            switch (rnd.Next(1, 11))
            {
                case 1:
                    type = Bonus.bonusType.BallBigger;
                    bonusImage = @"..\..\Resources\media\bonus\ballbigger.jpg";
                    break;
                case 2:
                    type = Bonus.bonusType.BallSmaller;
                    bonusImage = @"..\..\Resources\media\bonus\ballsmaller.jpg";
                    break;
                case 3:
                    type = Bonus.bonusType.HardBall;
                    bonusImage = @"..\..\Resources\media\bonus\hardball.jpg";
                    break;
                case 4:
                    type = Bonus.bonusType.LifeDown;
                    bonusImage = @"..\..\Resources\media\bonus\lifedown.jpg";
                    break;
                case 5:
                    type = Bonus.bonusType.LifeUp;
                    bonusImage = @"..\..\Resources\media\bonus\lifeup.jpg";
                    break;
                case 6:
                    type = Bonus.bonusType.NewBall;
                    bonusImage = @"..\..\Resources\media\bonus\newball.jpg";
                    break;
                case 7:
                    type = Bonus.bonusType.RacketLengthen;
                    bonusImage = @"..\..\Resources\media\bonus\racketlengthen.jpg";
                    break;
                case 8:
                    type = Bonus.bonusType.RacketShorten;
                    bonusImage = @"..\..\Resources\media\bonus\racketshorten.jpg";
                    break;
                case 9:
                    type = Bonus.bonusType.SteelBall;
                    bonusImage = @"..\..\Resources\media\bonus\steelball.jpg";
                    break;
                case 10:
                    type = Bonus.bonusType.StickyRacket;
                    bonusImage = @"..\..\Resources\media\bonus\stickyracket.jpg";
                    break;
            }

            Bonus bonus = new Bonus(oneBrick.PositionX + (oneBrick.Width / 2) - (bonusWidth / 2), oneBrick.PositionY + oneBrick.Height, bonusHeigth, bonusWidth, type, bonusImage);
            bonus.ScorePoint = 5;
            bonusList.Add(bonus);
            if (bonus.Descend(bonusSpeed, canvasLayer))
            {
                bonusList.Remove(bonus);
            }
        }