Ejemplo n.º 1
0
 public void RegisterGame(BalanceGame game)
 {
     game.LevelReset += new EventHandler(game_LevelReset);
     game.LeftBalanceBalls.CollectionChanged  += new NotifyCollectionChangedEventHandler(BalanceBalls_CollectionChanged);
     game.RightBalanceBalls.CollectionChanged += new NotifyCollectionChangedEventHandler(BalanceBalls_CollectionChanged);
     this.game = game;
 }
Ejemplo n.º 2
0
 private void InitializeGameController()
 {
     game = new BalanceGame();
     game.PlayerOneHeldBalls.CollectionChanged += new NotifyCollectionChangedEventHandler(HeldBalls_CollectionChanged);
     game.PlayerTwoHeldBalls.CollectionChanged += new NotifyCollectionChangedEventHandler(HeldBalls_CollectionChanged);
     game.LevelReset     += new EventHandler(game_LevelReset);
     game.LevelCompleted += new EventHandler(game_LevelCompleted);
     game.LevelLost      += new EventHandler(game_LevelLost);
     game.GameOver       += new EventHandler(game_GameOver);
     game.TimerTicked    += new EventHandler(timerCallback);
     game.NewGameStarted += new EventHandler(game_NewGameStarted);
     seesaw.RegisterGame(game);
     startNewMode(BalanceGame.Mode.Classic);
 }
Ejemplo n.º 3
0
        void timerCallback(object sender, EventArgs e)
        {
            if (!gameActive)
            {
                return;
            }
            BalanceGame bg = (BalanceGame)sender;

            scoreText.TextContent = bg.Score;
            timeText.Content      = bg.TimeLeft;

            if (bg.TimeLeft == 0)
            {
                gameActive = false;
                notime.Stop();
                notime.Play();
            }

            if (game.CurrentMode == BalanceGame.Mode.Challenge)
            {
                if (bg.TimeLeft < 10)
                {
                    ding.Stop();
                    ding.Play();
                }
            }
            else if (game.CurrentMode == BalanceGame.Mode.Classic)
            {
                if (bg.TimeLeft > 0)
                {
                    seesaw.animateRightBlocks();
                }
                else
                {
                    seesaw.animateRotateBlocks();
                }
                if (bg.TimeLeft <= 3)
                {
                    ding.Stop();
                    ding.Play();
                }
            }
        }
Ejemplo n.º 4
0
        void game_GameOver(object sender, EventArgs e)
        {
            gameActive = false;
            BalanceGame bg = (BalanceGame)sender;

            if (game.CurrentMode == BalanceGame.Mode.Classic)
            {
                lifeCanvas.Children.Clear();
            }

            modeLabel.Content = "Game Over!";

            finalScore.Content = "Score: " + bg.Score;
            playLabelAnimation(finalScore, delegate
            {
                finalScore.Opacity = 0;
            });

            //playAgain.BeginAnimation(UIElement.OpacityProperty, null);
            //playAgain.Opacity = 1;
        }