Ejemplo n.º 1
0
 public void PurchaseAdventurer(AdventurerType? adventurerType)
 {
     if (adventurerType != null)
     {
         if (adventurerType == AdventurerType.Warrior)
         {
             store.PurchaseAdventurer(AdventurerType.Warrior, Warrior.Cost(), 1);
         }
         else if (adventurerType == AdventurerType.Rogue)
         {
             store.PurchaseAdventurer(AdventurerType.Rogue, Rogue.Cost(), 1);
         }
         else if (adventurerType == AdventurerType.Mage)
         {
             store.PurchaseAdventurer(AdventurerType.Mage, Mage.Cost(), 1);
         }
     }
 }
        /// <summary>
        /// 訓練冒險者
        /// </summary>
        /// <param name="type"></param>
        public static IAdventurer TrainAdventurer(AdventurerType type)
        {
            switch (type)
            {
            case AdventurerType.Archer:
                Console.WriteLine("訓練一個弓箭手");

                return(new Archer());

            case AdventurerType.Warrior:
                Console.WriteLine("訓練一個鬥士");

                return(new Warrior());

            // 冒險者類別新增時,需修改程式增加
            default:
                return(null);
            }
        }
Ejemplo n.º 3
0
 public void PurchaseAdventurer(AdventurerType adventurerType, float heroCost, int numberToAdd)
 {
     if (player.Gold >= (heroCost * numberToAdd))
     {
         switch (adventurerType)
         {
             case AdventurerType.Warrior:
                 player.AddWarrior(numberToAdd);
                 break;
             case AdventurerType.Rogue:
                 player.AddRogue(numberToAdd);
                 break;
             case AdventurerType.Mage:
                 player.AddMage(numberToAdd);
                 break;
             default:
                 break;
         }
         UpdateStoreDisplay();
     }
 }