Esempio n. 1
0
        void CheckMousePosOnCLick()
        {
            MouseState mouseState = Mouse.GetState();

            if (mouseState.LeftButton == ButtonState.Pressed)
            {
                //main menu gumb
                if (mouseState.X <= _UI[0].position.X + (_UI[0].texture.Width / 2) * 0.5f && mouseState.X >= _UI[0].position.X - (_UI[0].texture.Width / 2) * 0.5f && mouseState.Y <= _UI[0].position.Y + (_UI[0].texture.Height / 2) * 0.5f && mouseState.Y >= _UI[0].position.Y - (_UI[0].texture.Height / 2) * 0.5f)
                {
                    this.Game.Components.Clear();
                    Scenes.MainMenu menu = new Scenes.MainMenu(this.Game);
                    this.Game.Components.Add(menu);
                }

                //retry gumb
                if (mouseState.X <= _UI[1].position.X + (_UI[1].texture.Width / 2) * 0.5f && mouseState.X >= _UI[1].position.X - (_UI[1].texture.Width / 2) * 0.5f && mouseState.Y <= _UI[1].position.Y + (_UI[1].texture.Height / 2) * 0.5f && mouseState.Y >= _UI[1].position.Y - (_UI[1].texture.Height / 2) * 0.5f)
                {
                    this.Game.Components.Clear();
                    Scenes.Level level = new Scenes.Level(this.Game);
                    this.Game.Components.Add(level);
                }

                //Exit gumb
                if (mouseState.X <= _UI[2].position.X + (_UI[2].texture.Width / 2) * 0.5f && mouseState.X >= _UI[2].position.X - (_UI[2].texture.Width / 2) * 0.5f && mouseState.Y <= _UI[2].position.Y + (_UI[2].texture.Height / 2) * 0.5f && mouseState.Y >= _UI[2].position.Y - (_UI[2].texture.Height / 2) * 0.5f)
                {
                    this.Game.Exit();
                }
            }
            if (mouseState.ScrollWheelValue != PrevisuMouseVale)
            {
                int diff = PrevisuMouseVale - mouseState.ScrollWheelValue;
                if (diff > 0)
                {
                    top = Math.Min(Math.Max(++top, 0), _LeaderBoard.Count - 14);
                    bot = Math.Min(Math.Max(++bot, 14), _LeaderBoard.Count);
                }
                else
                {
                    top = Math.Min(Math.Max(--top, 0), _LeaderBoard.Count - 14);
                    bot = Math.Min(Math.Max(--bot, 14), _LeaderBoard.Count);
                }
                PrevisuMouseVale = mouseState.ScrollWheelValue;
                makeTextbetween();
            }
        }
Esempio n. 2
0
        void CheckMousePosOnCLick()
        {
            MouseState mouseState = Mouse.GetState();

            if (mouseState.LeftButton == ButtonState.Pressed)
            {
                //main menu gumb
                if (mouseState.X <= _UI[0].position.X + (_UI[0].texture.Width / 2) * 0.5f && mouseState.X >= _UI[0].position.X - (_UI[0].texture.Width / 2) * 0.5f && mouseState.Y <= _UI[0].position.Y + (_UI[0].texture.Height / 2) * 0.5f && mouseState.Y >= _UI[0].position.Y - (_UI[0].texture.Height / 2) * 0.5f)
                {
                    this.Game.Components.Clear();
                    Scenes.MainMenu menu = new Scenes.MainMenu(this.Game);
                    this.Game.Components.Add(menu);
                }

                //save gub
                if (mouseState.X <= _UI[1].position.X + (_UI[1].texture.Width / 2) * 0.5f && mouseState.X >= _UI[1].position.X - (_UI[1].texture.Width / 2) * 0.5f && mouseState.Y <= _UI[1].position.Y + (_UI[1].texture.Height / 2) * 0.5f && mouseState.Y >= _UI[1].position.Y - (_UI[1].texture.Height / 2) * 0.5f)
                {
                    save();
                    this.Game.Components.Clear();
                    Scenes.LeaderBoard leaderBoard = new Scenes.LeaderBoard(this.Game);
                    this.Game.Components.Add(leaderBoard);
                }
            }
        }