コード例 #1
0
        /// <summary>
        /// Drink Potion is a method that is specific to heros. I did not inherit it from Character. Therefore I don't need the override keyword.
        /// Also, I don't want to rewrite this method for every single class that inherits from hero, so I am making one to rule them all here.
        /// </summary>
        public void DrinkPotion(PotionName PotionName)
        {
            Potion p = Potions.Where(p => p.Name == PotionName).FirstOrDefault();

            p.Drink(Name);

            // Potions give you a health boost. So make sure to increase your health bar!
            HealthBar += p.HealthBoostAmount;

            // Potions are a one time use, so remove it from your list of potions
            Potions.Remove(p);
        }