Esempio n. 1
0
        internal void PutGoodieAtRandomPlace()
        {
            //This method fires when user clicks Space Bar

            int    GoodieTopRandom  = 0;
            int    GoodieLeftRandom = 0;
            Random rnd = new Random();

            GoodieLeftRandom = rnd.Next(0, 1000);
            GoodieTopRandom  = rnd.Next(0, 500);
            _goodie.Destroy();                                                                      //Destroy previous goodie.
            _goodie = new Goodie(_playgroundCanvas, GoodieTopRandom, GoodieLeftRandom, _lifesLeft); //create randomized Goodie
        }
Esempio n. 2
0
        //Create Board
        private void CreateBoard()
        {
            _tmr.Stop();                      //Be sure Timer is stopped before continue.
            _tmrExplosion.Stop();             //timer stop
            _tmrImageBlink.Stop();            //stop blinking timer
            _musicManager.StopBgMusic();      //Stop Background music
            ClearBoard();                     //Clears board just in case it is not clear.
            IsGameRunning = false;            //Set flag NOT running for the pause button



            //Fresh Start.....................................................................
            _goodie    = new Goodie(_playgroundCanvas, 3);                                    //create new Goodie with 3 lifes
            _lifesLeft = _goodie.LivesLeft;                                                   //Will hold the current goodie lifes count
            this._textBlockGoodieLifeLeft.Text = _goodie.LivesLeft.ToString();                //set the physical texblock on MainPage

            if (IsGameLoad == true)                                                           //----On Game Load-----------------------------//If game is loaded Create Baddies based on saved data.
            {
                CreateBaddies2();                                                             //Create baddies based on saved data.
                _goodie.Destroy();                                                            //Destroy previous goodie.
                _goodie = new Goodie(_playgroundCanvas, _goodieTop, _goodieLeft, _lifesLeft); //Start goddie based on saved data.

                SetLoadedLivesCounters();                                                     //Onload set the Life counters here!!!
                _tmr.Start();                                                                 //Start the timer again.
                _tmrImageBlink.Start();                                                       //TIMER BLINK will wait for Goodie Collision with baddies
                IsGameRunning             = true;
                IsGameWasPlayedPreviously = true;                                             //helps to know if a game was ever started
                IsGameLoad = false;                                                           //----------------Important--------------------//Turn OFF the flag. Otherwise you will start new game from the load!!!!
                _tmrExplosion.Start();                                                        //Start explosion timer
            }
            else
            {
                CreateBaddies();             //Create 10 Baddies (important to initialize them before starting timer)
                _tmr.Start();                //START THE TIMER (Invoke OnTickHandler()Method each 150 milliseconds)
                _tmrImageBlink.Start();      //TIMER BLINK will wait for Goodie Collision with baddies

                IsGameWasPlayedPreviously = true;
                IsGameRunning             = true;
                _tmrExplosion.Start();       //test explosion timer
            }
        }