Exemplo n.º 1
0
        /// <summary>
        /// Check if the player click any key
        /// </summary>
        /// <param name="ElapsedTime"></param>
        public void ClickedKeys(double ElapsedTime)
        {
            //Prevent player from fast clicking
            FrameTimer += (float)ElapsedTime;
            if (FrameTimer >= 0.1f)
            {
                FrameTimer -= 0.1f;
                if (Grid.GameOn())
                {
                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Down))
                    {
                        UpDown.Play(false);
                        Grid.MoveDown();
                    }

                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Up))
                    {
                        UpDown.Play(false);
                        Grid.MoveUp();
                    }

                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Left))
                    {
                        LeftRight.Play(false);
                        Grid.MoveLeft();
                    }

                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Right))
                    {
                        LeftRight.Play(false);
                        Grid.MoveRight();
                    }
                }

                if (Engine.KeyClicked(System.Windows.Forms.Keys.Space))
                {
                    if (BackgroundMusic.IsBeingPlayed)
                    {
                        BackgroundMusic.StopPlaying();
                    }
                    else
                    {
                        BackgroundMusic.Play(true);
                    }
                }

                if (!Grid.GameOn())
                {
                    if (Engine.KeyClicked(System.Windows.Forms.Keys.Enter))
                    {
                        Score = new Score(this.Engine, Grid.Score);
                        Engine.RegisterScene(Score);
                        Engine.GoToScene(Score);
                    }
                }
            }
            //Go back to the menu
            if (Engine.KeyClicked(System.Windows.Forms.Keys.Escape))
            {
                Menu menu = new Menu(Engine, this);
                Engine.GoToScene(menu);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// When the player go to other scene, if music is on, it will be stopped
 /// </summary>
 /// <returns></returns>
 public override bool OnDestroy()
 {
     BackgroundMusic.StopPlaying();
     return(base.OnDestroy());
 }