Beispiel #1
0
        public MenuScreen(string bgResname)
            : base(bgResname)
        {
            /*
            FrameAnimator a = new FrameAnimator(100, 101);
            AnimationSequence anse = new AnimationSequence("loop", 0, 7);
            anse.Mode = AnimationSequence.AnimationMode.LOOP;
            a.AddAnimation(anse);
            obj.Animator = a;
            */

            menuButtons = new ButtonObj[4];

            menuButtons[0] = new ButtonObj("Play");
            menuButtons[0].SpriteName = "buttonBg";
            menuButtons[0].TouchNotifier = touchEvent;

            menuButtons[1] = new ButtonObj("High Score");
            menuButtons[1].SpriteName = "buttonBg";
            menuButtons[1].TouchNotifier = touchEvent;

            menuButtons[2] = new ButtonObj("About");
            menuButtons[2].SpriteName = "buttonBg";
            menuButtons[2].TouchNotifier = touchEvent;

            menuButtons[3] = new ButtonObj("Exit");
            menuButtons[3].SpriteName = "buttonBg";
            menuButtons[3].TouchNotifier = touchEvent;

            foreach (ButtonObj bo in menuButtons)
            {
                base.addObject(bo);
            }

            currentMenuButton = 0;

            titleObj = new GameObj();
            titleObj.SpriteName = "title";
            base.addObject(titleObj);
        }
 public void Update(long time, GameObj obj)
 {
     currentFrame++;
     if (currentFrame > frameTo)
     {
         switch (mode)
         {
             case AnimationMode.LOOP:
                 currentFrame = frameFrom;
                 break;
             case AnimationMode.STOP_AT_START:
                 status = AnimationStatus.STOP;
                 obj.animationEnded(this);
                 currentFrame = frameTo;
                 break;
             case AnimationMode.STOP_AT_END:
                 status = AnimationStatus.STOP;
                 obj.animationEnded(this);
                 currentFrame--;
                 break;
         }
     }
 }
Beispiel #3
0
 public void AddSubObjects(GameObj obj)
 {
     if (subObjects == null)
     {
         subObjects = new List<GameObj>();
     }
     subObjects.Add(obj);
 }
Beispiel #4
0
 public void addScreenObject(GameObj obj)
 {
     screenObjects.Add(obj);
 }
Beispiel #5
0
 public void addObject(GameObj obj)
 {
     gameObjects.Add(obj);
 }
Beispiel #6
0
 public void addAfterInit(GameObj obj)
 {
     tempAddlist.Add(obj);
 }
Beispiel #7
0
 public void PauseTextTouchEvent(TouchLocation loc, GameObj go)
 {
     gameState = GameState.PLAY;
     go.Visible = false;
 }
Beispiel #8
0
        public PlayScreen(string bgResname)
            : base(bgResname)
        {
            random = new Random(System.DateTime.UtcNow.Millisecond);
            freqDivider = 0;
            scorePos = new Vector2(5, 3);
            MinBalloonSpeed = -1.5f;
            isBannerOn = false;
            Level = 0;
            CreateMode = CreationMode.NORMAL;

            UpdateLevelParameters();
            explosionsRequired = 5;
            gameState = GameState.PLAY;
            lastPauseTouch = 0;

            // pause button
            pauseObj = new GameObj();
            pauseObj.SpriteName = "pause";
            pauseObj.TouchNotifier = PauseTouchEvent;
            this.addScreenObject(pauseObj);

            pauseTextObj = new GameObj();
            pauseTextObj.SpriteName = "pausetext";
            pauseTextObj.TouchNotifier = PauseTextTouchEvent;
            pauseTextObj.Visible = false;
            this.addScreenObject(pauseTextObj);

            quitButton = new ButtonObj("Quit");
            quitButton.SpriteName = "buttonBg";
            quitButton.TouchNotifier = delegate(TouchLocation loc, GameObj go)
            {
                reset();
                game.UnPauseGame();
                game.SetCurrentScreen(1);
            };
            quitButton.Visible = false;
            this.addScreenObject(quitButton);

            gameOverObj = new GameObj();
            gameOverObj.SpriteName = "gameover";
            gameOverObj.TouchNotifier = delegate(TouchLocation loc, GameObj go)
            {
                int screen = 1;
                if (Guide.IsVisible) return;

                if (game.ScoreManager.IsHighScore(Score))
                {
                    startInput();
                    // show input.. get name
                    // save high score..
                    // screen = 3;
                }
                else
                {
                    reset();
                    game.UnPauseGame();
                    game.SetCurrentScreen(screen);
                }
            };
            gameOverObj.Visible = false;
            this.addScreenObject(gameOverObj);
        }
Beispiel #9
0
 private void ScoreTransformEnded(GameObj o)
 {
     TextObj t = (TextObj)o;
     Score += Convert.ToInt32(t.Text);
     o.MarkForDelete = true;
 }
Beispiel #10
0
        private TextObj GetText(string txt, GameObj go)
        {
            TextObj scoreText = new TextObj();
            scoreText.Position = go.Position;
            scoreText.Font = GameConfig.me().ScoreFont;
            scoreText.Text = txt;

            scoreText.AddTransform(new LinearTransform(0, 60, (int)(50 - scoreText.Position.X), (int)(10 - scoreText.Position.Y)));

            scoreText.TransformNotifier = ScoreTransformEnded;

            return scoreText;
        }
Beispiel #11
0
        private void giftTouched(TouchLocation loc, GameObj go)
        {
            //go.MarkForDelete = true;
            GiftObj gift = (GiftObj)go;
            gift.Touchable = false;
            gift.Animator.CurrentAnimationName = "bursting";
            base.addAfterInit(GetText("+30", go));

            createAwesomeBanner();
        }
Beispiel #12
0
        private void createAwesomeBanner()
        {
            if (!isBannerOn)
            {
                isBannerOn = true;
                GameObj g = new GameObj();
                g.SpriteName = "awesome";

                g.UpdateSpriteReference(game.SprManager);
                g.UpdatePosition(0, 150);

                g.AddTransform(new LinearTransform(0, 150, game.Graphics.PreferredBackBufferWidth, 0));
                g.TransformNotifier = delegate(GameObj o)
                {
                    o.MarkForDelete = true;
                    isBannerOn = false;
                };
                base.addAfterInit(g);
            }
        }
Beispiel #13
0
        private void addExplosion(bool afterEffect, Vector2 pos)
        {
            GameObj obj = new GameObj();

            obj.SpriteName = "explosive";

            FrameAnimator a = new FrameAnimator(200, 200);
            AnimationSequence bombing = new AnimationSequence("exploding", 0, 9);
            bombing.Mode = AnimationSequence.AnimationMode.STOP_AT_END;

            AnimationSequence bombing2 = new AnimationSequence("exploding2", 2, 9);

            a.AddAnimation(bombing);
            a.AddAnimation(bombing2);

            obj.Animator = a;
            obj.AnimationNotifier = explodeAnimationEnded;

            obj.Animator.CurrentAnimationName = afterEffect ? "exploding2" : "exploding";

            obj.UpdateSpriteReference(game.SprManager);
            obj.UpdatePosition((int) pos.X - 100 + random.Next(150), (int) pos.Y - 100 + random.Next(150));

            addAfterInit(obj);
        }
Beispiel #14
0
        public void PauseTouchEvent(TouchLocation loc, GameObj go)
        {
            if (game.CurrentFrameTime - lastPauseTouch > 20 && gameState == GameState.PLAY)
            {
                if (game.IsPaused) game.UnPauseGame();
                else game.PauseGame();

                lastPauseTouch = game.CurrentFrameTime;
                pauseTextObj.Visible = game.IsPaused;
                quitButton.Visible = game.IsPaused;
            }
        }
Beispiel #15
0
        public override void Apply(GameObj obj, long timer)
        {
            currentFrame++;
            int tx, ty;
            if (currentFrame >= startFrame && currentFrame <= endFrame)
            {
                deltaX = deltaX + stepX;
                deltaY = deltaY + stepY;

                tx = (int) Math.Floor(deltaX);
                ty = (int) Math.Floor(deltaY);

                deltaX = deltaX - tx; deltaY = deltaY - ty;

                if (Math.Abs(tx) > 0 || Math.Abs(ty) > 0)
                    obj.Move(tx, ty);

                if (currentFrame == endFrame && completeEventHandler != null)
                {
                    completeEventHandler(this);
                }
            }
        }
Beispiel #16
0
 public void touchEvent(TouchLocation tl, GameObj go)
 {
     if (tl.State == TouchLocationState.Released)
     {
         if (go == menuButtons[0])
         {
             nextScreeen = 2;
             startMenuHiding();
         }
         else if (go == menuButtons[1])
         {
             nextScreeen = 3;
             startMenuHiding();
         }
         else if (go == menuButtons[3])
         {
             nextScreeen = -1;
             startMenuHiding();
         }
         else if (go == menuButtons[2])
         {
             nextScreeen = 4;
             startMenuHiding();
         }
     }
 }
Beispiel #17
0
 public virtual void Apply(GameObj obj, long timer)
 {
     throw new NotImplementedException();
 }
Beispiel #18
0
        public void balloonTouched(TouchLocation loc, GameObj go)
        {
            if (loc.State != TouchLocationState.Released || gameState == GameState.OVER) return;

            BalloonObj b = (BalloonObj)go;
            b.TouchesRequiredToBust = b.TouchesRequiredToBust - 1;

            if (b.Type == BalloonObj.BalloonType.BOMB)
            {
                b.Touchable = false;
                b.MarkForDelete = true;
                explosionsRequired = 3;
                gameState = GameState.OVER;

                addExplosion(false, b.Position);
                addExplosion(true, b.Position);
                addExplosion(true, b.Position);
            }
            else if (b.TouchesRequiredToBust == 0)
            {
                b.Touchable = false;

                // update animation for busted
                // based on balloon type add another object (for diamon, or star)
                //b.MarkForDelete = true;
                b.Animator.CurrentAnimationName = "bursting";
                b.updateSpeed(0, 0);

                base.addAfterInit(GetText("+10", b));

                // now add subobjects of the balloon...
                if (b.getSubObjects() == null) return;
                int i = 0;
                foreach (GameObj go2 in b.getSubObjects())
                {
                    go2.Visible = true;
                    if (b.Type == BalloonObj.BalloonType.TRIPLE)
                    {
                        int tx = i == 0 ? (int) (b.Position.X - 30 - random.Next(20)) : (int)b.Position.X + 30 + random.Next(20);
                        // make sure balloons are within the screen
                        if (tx < 5) tx = 10;
                        if (tx > game.Graphics.PreferredBackBufferWidth - 20)
                            tx = game.Graphics.PreferredBackBufferWidth - 30;

                        go2.UpdatePosition(tx, (int)b.Position.Y);
                    }
                    else
                    {
                        go2.UpdatePosition((int)b.Position.X, (int)b.Position.Y + 40);
                    }
                    i++;
                }
            }
        }