Example #1
0
 public Bonus this[BonusName name]
 {
     get
     {
         return(this[(int)name]);
     }
 }
Example #2
0
 public void OnBonusLost(BonusName name, BonusAction action)
 {
     if (onBonusOff.ContainsKey(name))
     {
         onBonusOff[name] += action;
     }
     else
     {
         onBonusOff[name] = action;
     }
 }
Example #3
0
    public void ApplyBonus(BonusName name, float duration)
    {
        if (!timers.ContainsKey(name))
        {
            timers[name] = new BonusTimer();
        }

        timers[name].timer = 0;
        if (timers[name].duration == 0.0f && onBonusOn.ContainsKey(name))
        {
            onBonusOn[name]();
        }
        timers[name].duration = duration;
    }
Example #4
0
 public bool IsActive(BonusName name)
 {
     return(timers.ContainsKey(name) && timers[name].duration > 0.0f);
 }
Example #5
0
        public void UseBonus(ref Grid grid, ref Platform platform, ref List <Ball> balls)
        {
            if (_id == BonusName.Random)
            {
                _id = (BonusName)_rand.Next(1, _maxBonusID + 1);
            }

            switch (_id)
            {
            case BonusName.DoubleBall:
                GameControl.PlaySound(GameControl.Sound.ExtraBall);
                int ballsCount = balls.Count;
                for (int i = 0; i < ballsCount; i++)
                {
                    balls.Add(new Ball(balls[i]));
                }
                break;

            case BonusName.BallSizeUp:
                foreach (Ball ball in balls)
                {
                    ball.SizeUp();
                }
                break;

            case BonusName.BallSizeDown:
                foreach (Ball ball in balls)
                {
                    ball.SizeDown();
                }
                break;

            case BonusName.BallSpeedDown:
                foreach (Ball ball in balls)
                {
                    ball.Speed--;
                }
                break;

            case BonusName.BallSpeedUp:
                foreach (Ball ball in balls)
                {
                    ball.Speed++;
                }
                break;

            case BonusName.PlatformSizeUp:
                platform.SizeUp();
                break;

            case BonusName.PlatformSizeDown:
                platform.SizeDown();
                break;

            case BonusName.PlatformSpeedUp:
                platform.Speed++;
                break;

            case BonusName.PlatformSpeedDown:
                platform.Speed--;
                break;

            case BonusName.ExtraLife:
                GameControl.AddLife();
                break;

            case BonusName.ExtraPoints:
                GameControl.AddPoints(1000);
                GameControl.PlaySound(GameControl.Sound.ExtraPoints);
                break;

            case BonusName.Skull:
                foreach (Ball ball in balls)
                {
                    grid.Children.Remove(ball);
                }
                balls.Clear();
                break;
            }

            grid.Children.Remove(this);
        }
Example #6
0
 //-------------------------------------------------------
 public Bonus(Grid grid, BonusName ID, double x, double y)
     : base(new Uri("./Graphics/bonus-" + (int)ID + ".png", UriKind.Relative), grid, x, y)
 {
     _id = ID;
 }