コード例 #1
0
        private void UsePotion()
        {
            int           _time         = 15;
            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.P))
            {
                if (Inventory._potionNb > 0)
                {
                    if (_time == 15)
                    {
                        int x = 0;
                        if (_playerM.Life < _playerM._lifemax)
                        {
                            while (_playerM.Life < _playerM._lifemax && x < 30)
                            {
                                _playerM.Life++;
                                x++;
                                _time = 0;
                            }
                            Inventory._potionNb--;
                            if (Inventory._potionNb == 0)
                            {
                                Inventory.AddEmptyPotion();
                            }
                        }
                    }
                    else
                    {
                        _time++;
                    }
                }
            }
        }