コード例 #1
0
 private void HandleCraftInteraction(Person actor, string itemType, string itemName)
 {
     Item newItem;
     if (itemType == "weapon" && actor.InventorryContains(ItemType.Wood, ItemType.Iron))
     {
         newItem=new Weapon(itemName);
         this.AddToPerson(actor, newItem);
     }
     else if (itemType == "armor" && actor.InventorryContains(ItemType.Iron))
     {
         newItem =new Armor(itemName);
         this.AddToPerson(actor, newItem);
     }
 }
コード例 #2
0
 private void HandleGatherInteraction(Person actor, string itemName)
 {
     if (actor.Location is IGatheringLocation)
     {
         var location = actor.Location as IGatheringLocation;
         if (actor.InventorryContains(location.RequiredItem))
         {
             var gatheredItem = location.ProduceItem(itemName);
             this.AddToPerson(actor, gatheredItem);
         }
     }
 }