當前位置: 首頁>>代碼示例>>C#>>正文


C# Person.AddToInventory方法代碼示例

本文整理匯總了C#中TradeAndTravel.Person.AddToInventory方法的典型用法代碼示例。如果您正苦於以下問題:C# Person.AddToInventory方法的具體用法?C# Person.AddToInventory怎麽用?C# Person.AddToInventory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在TradeAndTravel.Person的用法示例。


在下文中一共展示了Person.AddToInventory方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CraftArmor

 private void CraftArmor(string newItemName, Person actor) 
 {
     var ironItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Iron);          
     if (ironItems != null && ironItems.Count() > 0 )
     {
        
         var item = new Armor(newItemName, null);
         actor.AddToInventory(item);
         ownerByItem.Add(item, actor);
         item.UpdateWithInteraction("craft");
     }         
 }        
開發者ID:krstan4o,項目名稱:TelerikAcademy,代碼行數:12,代碼來源:ExtendedIteractionManager.cs

示例2: HandleCraftInteraction

 private void HandleCraftInteraction(Person actor, string name)
 {
     if (actor.ListInventory().Exists(x => x is Iron))
     {
         if (actor.ListInventory().Exists(x => x is Weapon))
         {
             var item = new Weapon(name);
             actor.AddToInventory(item);
             this.AddToPerson(actor, item);
             return;
         }
         else
         {
             var item = new Armor(name);
             actor.AddToInventory(item);
             this.AddToPerson(actor, item);
         }
     }
 }
開發者ID:TeeeeeC,項目名稱:TelerikAcademy2015-2016,代碼行數:19,代碼來源:EntensionInteractionManager.cs

示例3: AddToPerson

 protected void AddToPerson(Person actor, Item item)
 {
     actor.AddToInventory(item);
     ownerByItem[item] = actor;
 }
開發者ID:alex687,項目名稱:SoftUni-Homeworks,代碼行數:5,代碼來源:InteractionManager.cs

示例4: HandleGatherInteraction

        private void HandleGatherInteraction(Person actor, string itemName)
        {
            //Gathering means a Person takes an item from a special location
            //A Person should be able to gather from mines and from forests
            //A Person can gather from a forest only if he has a Weapon in his inventory
            //Gathering from a forests results in adding a Wood item in the Person’s inventory
            //A Person can gather from a mine only if he has an Armor in his inventory
            //Gathering from a mine results in adding an Iron item in the Person’s inventory
            //Syntax: Joro gather newItemName – gathers an item, naming it newItemName if the Person Joro is at a mine or forest, and respectively has an Armor or Weapon

            if (actor.Location.LocationType == LocationType.Forest && actor.ListInventory().Any(a => a.GetType() == typeof(Weapon)))
            {
                Wood a = new Wood(itemName);
                base.AddToPerson(actor, a);
                actor.AddToInventory(new Wood(itemName));
            }

            if (actor.Location.LocationType == LocationType.Mine && actor.ListInventory().Any(a => a.GetType() == typeof(Armor)))
            {
                Iron a = new Iron(itemName);
                base.AddToPerson(actor, a);
                actor.AddToInventory(new Iron(itemName));
            }
        }
開發者ID:VDGone,項目名稱:TelerikAcademy-2,代碼行數:24,代碼來源:UpdatedInteractionManager.cs

示例5: HandleCraftInteraction

 private void HandleCraftInteraction(Person actor, string itemToCraft, string itemName)
 {
     //A Person can craft items, provided he has some items in his inventory
     //A Person should be able to craft Weapons and Armor
     //Crafting an Armor requires that the Person has Iron in his inventory
     //Results in adding an Armor item in the Person’s inventory
     //Crafting a Weapon requires that the Person has Iron and Wood in his inventory
     //Syntax: Joro craft weapon/armor newItemName - gathers an item, naming it newItemName if the Person Joro has the necessary
     switch (itemToCraft)
     {
         case "armor":
             if (actor.ListInventory().Any(a => a.GetType() == typeof(Iron)))
             {
                 Armor armor = new Armor(itemName);
                 base.AddToPerson(actor, armor);
                 actor.AddToInventory(new Armor(itemName));
             }
             break;
         case "weapon":
             if (actor.ListInventory().Any(a => a.GetType() == typeof(Iron)) && actor.ListInventory().Any(a => a.GetType() == typeof(Wood)))
             {
                 Weapon weapon = new Weapon(itemName);
                 base.AddToPerson(actor, weapon);
                 actor.AddToInventory(new Weapon(itemName));
             }
             break;
         default:
             break;
     }
 }
開發者ID:VDGone,項目名稱:TelerikAcademy-2,代碼行數:30,代碼來源:UpdatedInteractionManager.cs

示例6: HandleGatherInteraction

        private void HandleGatherInteraction(Person actor, string itemName)
        {
            var actorItems = actor.ListInventory();

            for (int i = 0; i < actorItems.Count; i++)
            {
                if (actorItems[i] is Weapon && actor.Location is Forest)
                {
                    var item = new Wood(itemName);
                    actor.AddToInventory(item);
                    this.ownerByItem.Add(item, actor);
                    return;
                }
                else if (actorItems[i] is Armor && actor.Location is Mine)
                {
                    var item = new Iron(itemName);
                    actor.AddToInventory(item);
                    this.ownerByItem.Add(item, actor);
                    return;
                }
            }
        }
開發者ID:razsilev,項目名稱:TelerikAcademy_Homework,代碼行數:22,代碼來源:Program.cs

示例7: HandleCraftInteraction

 private void HandleCraftInteraction(Person actor, string itemType, string itemName)
 {
     if (actor.ListInventory().Find(i => i is Iron) != null)
     {
         if (itemType == "weapon" && actor.ListInventory().Find(i => i is Wood) != null)
         {
             var item = new Weapon(itemName);
             actor.AddToInventory(item);
             this.ownerByItem.Add(item, actor);
         }
         else if (itemType == "armor")
         {
             var item = new Armor(itemName);
             actor.AddToInventory(item);
             this.ownerByItem.Add(item, actor);
         }
     }
 }
開發者ID:razsilev,項目名稱:TelerikAcademy_Homework,代碼行數:18,代碼來源:Program.cs

示例8: HandleGatherInteraction

        private void HandleGatherInteraction(string[] commandWords, Person actor)
        {
            if (actor.Location.LocationType == LocationType.Forest)
            {
                var inventoryItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Weapon);
                if (inventoryItems != null && inventoryItems.Count() > 0)
                {
                    var item = new Wood(commandWords[2], null);
                    actor.AddToInventory(item);
                    ownerByItem.Add(item, actor);
                    item.UpdateWithInteraction("gather");
                }
            }
            else if (actor.Location.LocationType == LocationType.Mine)
            {
                var inventoryItems = actor.ListInventory().Where(x => x.ItemType == ItemType.Armor);
                if (inventoryItems != null && inventoryItems.Count() > 0)
                {
                    var item = new Iron(commandWords[2], null);
                    actor.AddToInventory(item);
                    ownerByItem.Add(item, actor);
                }
            }

        }
開發者ID:krstan4o,項目名稱:TelerikAcademy,代碼行數:25,代碼來源:ExtendedIteractionManager.cs

示例9: HandleGatherInteraction

        private void HandleGatherInteraction(Person actor, string name)
        {
            var locationForest = actor.Location as Forest;
            if (locationForest is Forest)
            {
                if (actor.ListInventory().Exists(x => x is Weapon))
                {
                    var item = new Wood(name, actor.Location);
                    actor.AddToInventory(item);
                    this.AddToPerson(actor, item);
                }
            }

            var locationMine = actor.Location as Mine;
            if (locationMine is Mine)
            {
                if (actor.ListInventory().Exists(x => x is Armor))
                {
                    var item = new Iron(name, actor.Location);
                    actor.AddToInventory(item);
                    this.AddToPerson(actor, item);
                }
            }
        }
開發者ID:TeeeeeC,項目名稱:TelerikAcademy2015-2016,代碼行數:24,代碼來源:Program.cs


注:本文中的TradeAndTravel.Person.AddToInventory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。