Exemplo n.º 1
0
        internal override void HandleClick(int mouse_clicks, EventArgs e)
        {
            base.HandleClick(mouse_clicks, e);

            MouseEventArgs mea = e as MouseEventArgs;

            if (mea != null)
            {
                if (ButtonBounds.Contains(mea.Location))
                {
                    OnButtonClick(EventArgs.Empty);
                }
            }
        }
Exemplo n.º 2
0
        public void Update(GameTime gameTime)
        {
            if (!IsEnabled)
            {
                return;
            }

            MouseState mouseState = Mouse.GetState();

            if (ButtonBounds.Contains(mouseState.Position) && mouseState.LeftButton == ButtonState.Pressed)
            {
                _game.Replay();
            }
        }
Exemplo n.º 3
0
        public override void Update(GameTime gameTime)
        {
            if ((Name == "Resume" || Name == "End") && !Active)
            {
                Active = true;
            }

            if (Active)
            {
                //				if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && !ContainsMouse)
                //                    ContainsMouse = true;
                //				else if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && ContainsMouse)
                //                {
                //                    HasFocus = false;
                //                    ContainsMouse = false;
                //                }
                //				if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) &&
                //					InputHandler.IsScreenBeingTouched())
                //                {
                //                    HasFocus = true;
                //                    base.OnSelected(null);
                //                }
                #region Mouse
                if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && !ContainsMouse)
                {
                    ContainsMouse = true;
                }
                else if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) && ContainsMouse)
                {
                    HasFocus      = false;
                    ContainsMouse = false;
                }

                if (ContainsMouse && InputHandler.FingerRaised())
                {
                    HasFocus = true;
                    base.OnSelected(null);
                    #endregion

                    #region Touch
                    //if (ButtonBounds.Contains (InputHandler.TouchVectorScaled.ToPoint ()) && !ContainsMouse)
                    //    ContainsMouse = true;
                    //else if (!ButtonBounds.Contains (InputHandler.TouchVectorScaled.ToPoint ()) && ContainsMouse) {
                    //    HasFocus = false;
                    //    ContainsMouse = false;
                    //}

                    //if (ContainsMouse && InputHandler.FingerRaised ()) {
                    //    HasFocus = true;
                    //    base.OnSelected (null);
                }
                #endregion
            }
            else
            {
                var elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

                moveTimer += elapsed;

                if (moveTimer >= moveTimerDuration)
                {
                    moveTimer = 0;

                    if (!bounceUp)
                    {
                        Position = new Vector2(Position.X, Position.Y + 10);

                        if (Position.Y >= targetPoint + 22)
                        {
                            bounceUp = true;
                        }
                    }
                    else
                    {
                        Position = new Vector2(Position.X, Position.Y - 3);
                        if (Position.Y <= targetPoint)
                        {
                            Enabled = true;
                            Active  = true;

                            ButtonBounds = new Rectangle((int)Position.X, (int)Position.Y, ButtonBounds.Width, ButtonBounds.Height);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        //-------------------------------------------------------
        //------------------------Methods------------------------
        //-------------------------------------------------------

        protected virtual bool InBounds(MouseState mouseState)
        {
            return(ButtonBounds.Contains(mouseState.Position));
        }
Exemplo n.º 5
0
        public override void Update(GameTime gameTime)
        {
            #region Mouse
            if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            {
                Highlighted = true;
                HasFocus    = false;

                if (HasPlayed)
                {
                    HasPlayed = false;
                }
            }

            if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            {
                Highlighted = true;
                HasFocus    = true;
            }

            if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) &&
                InputHandler.FingerRaised())
            {
                HasFocus = true;
                base.OnSelected(null);
            }
            #endregion

            #region Touch
            //if (!ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            //{
            //    Highlighted = true;
            //    HasFocus = false;

            //    if (HasPlayed)
            //        HasPlayed = false;

            //}


            //if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()))
            //{
            //    Highlighted = true;
            //    HasFocus = true;

            //}

            //if (ButtonBounds.Contains(InputHandler.TouchVectorScaled.ToPoint()) &&
            //    InputHandler.FingerRaised())
            //{
            //    HasFocus = true;
            //    base.OnSelected(null);
            //}

            #endregion

            //if (HasFocus && !HasPlayed)
            //{
            //    SoundBoard.ButtonHighlight.Play();
            //    HasPlayed = true;
            //}
        }