Example #1
0
 public override void ChangeState(Microsoft.Xna.Framework.Input.MouseState state)
 {
     if (state.LeftButton != ButtonState.Pressed && state.RightButton != ButtonState.Pressed)
     {
         if (_Sprite.Contains(state.X, state.Y))
         {
             _Sprite.CurrentFrame = 1;
         }
         else
         {
             _Sprite.CurrentFrame = 0;
         }
     }
     if (state.LeftButton == ButtonState.Pressed && _Sprite.Contains(state.X, state.Y) && _LastMouseState.LeftButton == ButtonState.Released)
     {
         _Sprite.CurrentFrame = 2;
         if (OnValueChanged != null)
         {
             OnValueChanged();
         }
         float snd = 12 - _Game.SoundVolume();
         if (snd != 12)
         {
             _Sound.Play(1 / snd, 0, 0);
         }
     }
     _LastMouseState = state;
 }
Example #2
0
 /// <summary>
 /// Реакция на изменения мыши
 /// </summary>
 /// <param name="state">The state.</param>
 public override void ChangeState(Microsoft.Xna.Framework.Input.MouseState state)
 {
     if (state.LeftButton != ButtonState.Pressed && state.RightButton != ButtonState.Pressed)
     {
         if (_Plus.Contains(state.X, state.Y))
         {
             _Plus.CurrentFrame = 1;
         }
         else
         {
             _Plus.CurrentFrame = 0;
         }
         if (_Minus.Contains(state.X, state.Y))
         {
             _Minus.CurrentFrame = 1;
         }
         else
         {
             _Minus.CurrentFrame = 0;
         }
     }
     if (state.LeftButton == ButtonState.Pressed && _LastMouseState.LeftButton == ButtonState.Released)
     {
         if (_Plus.Contains(state.X, state.Y) && (_Lent.CurrentFrame != 11))
         {
             _Lent.Update();
             PlaySound();
             if (OnValueChanged != null)
             {
                 OnValueChanged();
             }
         }
         if (_Minus.Contains(state.X, state.Y) && (_Lent.CurrentFrame != 0))
         {
             --_Lent.CurrentFrame;
             PlaySound();
             if (OnValueChanged != null)
             {
                 OnValueChanged();
             }
         }
     }
     _LastMouseState = state;
 }
Example #3
0
 /// <summary>Показывать подсказку</summary>
 /// <param name="state">Положение курсора.</param>
 private void ShowHint(MouseState state)
 {
     if (_Back.Contains(state.X, state.Y))
     {
         _ShowText   = true;
         _TextVector = new Vector2(state.X, state.Y);
     }
     else
     {
         _ShowText = false;
     }
 }
Example #4
0
 /// <summary>
 /// Реакция на изменения мыши
 /// </summary>
 /// <param name="state">The state.</param>
 public override void ChangeState(MouseState state)
 {
     if (state.LeftButton != ButtonState.Pressed && state.RightButton != ButtonState.Pressed)
     {
         if (_Sprite.Contains(state.X, state.Y))
         {
             if (_Checked)
             {
                 _Sprite.CurrentFrame = 2;
             }
             else
             {
                 _Sprite.CurrentFrame = 1;
             }
         }
         else
         {
             if (_Checked)
             {
                 _Sprite.CurrentFrame = 3;
             }
             else
             {
                 _Sprite.CurrentFrame = 0;
             }
         }
     }
     if (state.LeftButton == ButtonState.Pressed && _LastMouseState.LeftButton == ButtonState.Released && _Sprite.Contains(state.X, state.Y))
     {
         Checked = !_Checked;
         if (OnValueChanged != null)
         {
             OnValueChanged();
         }
     }
     _LastMouseState = state;
 }
Example #5
0
 /// <summary>
 /// Реакция на изменения мыши
 /// </summary>
 /// <param name="state">The state.</param>
 public override void ChangeState(MouseState state)
 {
     foreach (Control item in _Values)
     {
         item.ChangeState(state);
     }
     if (state.LeftButton != ButtonState.Pressed && state.RightButton != ButtonState.Pressed)
     {
         if (_Sprite.Contains(state.X, state.Y))
         {
             _Sprite.CurrentFrame = 1;
         }
         else
         {
             _Sprite.CurrentFrame = 0;
         }
     }
     if (state.LeftButton == ButtonState.Pressed && _LastMouseState.LeftButton == ButtonState.Released && _Sprite.Contains(state.X, state.Y))
     {
         _Sprite.CurrentFrame = 2;
         _Expand = !_Expand;
     }
     _LastMouseState = state;
 }
Example #6
0
        /// <summary>Обновляем состояние</summary>
        /// <param name="mouseState">Состояние мыши</param>
        /// <param name="keyboardState">Состояние клавиатуры</param>
        public void Update(MouseState mouseState, KeyboardState keyboardState)
        {
            if (mouseState.LeftButton == ButtonState.Pressed && _LastMouseState.LeftButton == ButtonState.Released)
            {
                if (_Texture.Contains(mouseState.X, mouseState.Y))
                {
                    _Texture.CurrentFrame = 1;
                }
                else
                {
                    _Texture.CurrentFrame = 0;
                    _Game.PlayerName      = _Text;
                }
            }
            if (keyboardState.IsKeyUp(Keys.Back) && (_LastKeyboardState.IsKeyDown(Keys.Back)) && _Texture.CurrentFrame == 1)
            {
                if (_Text.Length > 0)
                {
                    _Text = _Text.Substring(0, _Text.Length - 1);
                }
                else
                {
                    _Text = "";
                }
            }
            var keys = keyboardState.GetPressedKeys();

            foreach (Keys key in keys)
            {
                if (key >= Keys.A && key <= Keys.Z)
                {
                    _LastKey = key;
                }
            }

            if (keyboardState.IsKeyUp(_LastKey) && _LastKeyboardState.IsKeyDown(_LastKey))
            {
                _Text = _Text + _LastKey.ToString();
            }

            _LastMouseState    = mouseState;
            _LastKeyboardState = keyboardState;

            if (_Texture.CurrentFrame == 1)
            {
                if (_Delay != 0 && _DrawDelay == 25)
                {
                    _Delay--;
                    _Draw = false;
                    return;
                }
                else
                {
                    if (_DrawDelay != 0)
                    {
                        _DrawDelay--;
                        _Draw  = true;
                        _Delay = 25;
                        return;
                    }
                    else
                    {
                        _DrawDelay = 25;
                    }
                }
            }
        }