Exemple #1
0
        private BalloonObj makeBalloon(BalloonObj.BalloonType type, BalloonObj.BalloonColor color)
        {
            BalloonObj balloon = new BalloonObj();
            balloon.SpriteName = formBalloonName(type, color);
            balloon.Scale = 2;
            balloon.TouchNotifier = balloonTouched;
            balloon.Type = type;
            balloon.Color = color;

            FrameAnimator a = new FrameAnimator(196 / 4, BalloonObj.BalloonType.GIFT == type || BalloonObj.BalloonType.BOMB == type ? 80 : 60);
            AnimationSequence flyingAnse = new AnimationSequence("flying", 0, 3);
            flyingAnse.Mode = AnimationSequence.AnimationMode.LOOP;

            AnimationSequence burstingAnse = new AnimationSequence("bursting", 4, 7);
            burstingAnse.Mode = AnimationSequence.AnimationMode.STOP_AT_END;

            a.AddAnimation(flyingAnse);
            a.AddAnimation(burstingAnse);

            balloon.Animator = a;
            balloon.AnimationNotifier = balloonBurstAnimationEnded;
            balloon.Animator.CurrentAnimationName = "flying";

            balloon.UpdateSpriteReference(game.SprManager);
            balloon.W = balloon.Type == BalloonObj.BalloonType.BOMB ? 50 : 75;
            balloon.UpdatePosition(10 + random.Next(game.Graphics.PreferredBackBufferWidth - 100), game.Graphics.PreferredBackBufferHeight + 20);
            screenHeight = game.Graphics.PreferredBackBufferHeight;

            balloon.BalloonOutNotifier = balloonOutEvent;
            balloon.TouchNotifier = balloonTouched;
            balloon.TouchesRequiredToBust = 1;

            if (BalloonObj.BalloonType.BOMB == type)
            {
                balloon.updateSpeed(0, -2.25f - ((float) random.NextDouble())*BombSpeedVar);
            }
            else if (BalloonObj.BalloonType.GIFT == type)
            {
                balloon.updateSpeed(0, -3.0f - ((float)random.NextDouble())*GiftSpeedVar);
            }
            else
            {
                balloon.updateSpeed(0, MinBalloonSpeed - ((float)random.NextDouble())*SpeedVar);
            }

            return balloon;
        }
Exemple #2
0
        private void createBalloon(BalloonObj.BalloonType type, BalloonObj.BalloonColor color)
        {
            BalloonCount++; // some data to optmize ball creation probability
            framesSinceLastCreate = 0; // to tweak game difficulty

            BalloonObj balloon = makeBalloon(type, color);

            if (type == BalloonObj.BalloonType.GIFT)
            {
                balloon.AddSubObjects(createGiftSubObj());
            }
            else if (type == BalloonObj.BalloonType.TRIPLE)
            {
                balloon.AddSubObjects(makeBalloon(BalloonObj.BalloonType.SINGLE, BalloonObj.BalloonColor.GREEN));
                balloon.AddSubObjects(makeBalloon(BalloonObj.BalloonType.SINGLE, BalloonObj.BalloonColor.RED));
            }

            if (balloon.getSubObjects() != null)
            {
                foreach (GameObj go in balloon.getSubObjects())
                {
                    go.Visible = false;
                    base.addObject(go);
                }
            }

            base.addObject(balloon);
        }
Exemple #3
0
 private string formBalloonName(BalloonObj.BalloonType type, BalloonObj.BalloonColor color)
 {
     string typeStr = BalloonObj.TYPE_STR[(int)type];
     return BalloonObj.COLOR_STR[(int)color] + "_Balloon" + (typeStr.Length > 1 ? "_" + typeStr : typeStr);
 }
Exemple #4
0
 private void balloonOutEvent(BalloonObj b)
 {
     if (!b.MarkForDelete)
     {
         b.MarkForDelete = true;
         if (b.Visible)
             BalloonCount--;
         bout++;
         if (b.Type == BalloonObj.BalloonType.SINGLE || b.Type == BalloonObj.BalloonType.TRIPLE)
         {
             BalloonsMissed++;
         }
     }
 }