当前位置: 首页>>代码示例>>C#>>正文


C# Inventory.AddItem方法代码示例

本文整理汇总了C#中Inventory.AddItem方法的典型用法代码示例。如果您正苦于以下问题:C# Inventory.AddItem方法的具体用法?C# Inventory.AddItem怎么用?C# Inventory.AddItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Inventory的用法示例。


在下文中一共展示了Inventory.AddItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

 void Start ()
 {
     state = ShopState.NONE;
     shopInventory = GetComponent<Inventory> ();
     itemDB = (ItemDatabase)GameObject.Find ("ItemDatabase").GetComponent<ItemDatabase> ();
     shopInventory.AddItem (ItemIDs.RADISH_SEEDS, INFINITE);
     shopInventory.AddItem (ItemIDs.ONION_SEEDS, INFINITE);
     shopInventory.AddItem (ItemIDs.POTATO_SEEDS, INFINITE);
     shopInventory.AddItem (ItemIDs.TOMATO_SEEDS, INFINITE);
     shopInventory.AddItem (ItemIDs.BEAN_SEEDS, INFINITE);
     scrollPos = Vector2.zero;
     ResetItemData ();
 }
开发者ID:lannes,项目名称:farm-with-friends,代码行数:13,代码来源:Shop.cs

示例2: buyPotion1

	public void buyPotion1 () {
		MyResources=GameData.MyPlayer.Resources;
		if(MyResources[Constants.GOLD_RES]>250){
			_inventory= GameObject.Find("Inventory").GetComponent<Inventory>();
			_inventory.AddItem(3,1);
			_inventory.UseResources(Constants.GOLD_RES,250);	
			print (MyResources[Constants.GOLD_RES]);
		}
	}
开发者ID:CarsonRoscoe,项目名称:DefendAman,代码行数:9,代码来源:BuyPotion5.cs

示例3: Craft

 public bool Craft(Inventory inventory)
 {
     if (inventory.HasItem(m_RequiredItems))
     {
         inventory.AddItem(m_ItemType);
         return true;
     }
     return false; //not all mats are owned
 }
开发者ID:JakeClark1129,项目名称:GlobalGameJamVancouver,代码行数:9,代码来源:Craftable.cs

示例4: buyPotion1

	public void buyPotion1 () {
		print ("Button 1 pressed");
		MyResources=GameData.MyPlayer.Resources;
		if(MyResources[Constants.GOLD_RES]>=500){
			_inventory= GameObject.Find("Inventory").GetComponent<Inventory>();
			_inventory.AddItem(7,1);
			_inventory.UseResources(Constants.GOLD_RES,500);	
			print (MyResources[Constants.GOLD_RES]);
		}
	}
开发者ID:CarsonRoscoe,项目名称:DefendAman,代码行数:10,代码来源:BuyPotion1.cs

示例5: LuoAseValikko

    void LuoAseValikko()
    {
        // Asevalikko
        Inventory inventory = new Inventory();
        inventory.Y = Screen.Top - 20;
        Add(inventory);

        Weapon rynkky = new AssaultRifle(20, 10);
        Weapon plasma = new PlasmaCannon(20, 10);
        Weapon kanuuna = new Cannon(20,10);
        kanuuna.Image = Inventory.ScaleImageDown(kanuuna.Image, 4);

        inventory.AddItem(rynkky, rynkky.Image);
        inventory.AddItem(plasma, plasma.Image);
        inventory.AddItem(kanuuna, kanuuna.Image);
        inventory.ItemSelected += AseValittu;

        // Valitse pelin aluksi rynkky
        inventory.SelectItem(rynkky);
    }
开发者ID:juherask,项目名称:sejypeli,代码行数:20,代码来源:KukkulanKuningas.cs

示例6: Init

        public void Init()
        {
            emptyInventory = new Inventory (10);

            JsonDataHandler json = new JsonDataHandler ();
            rubbishItems = json.GetInventoryItemArray ("Rubbish");

            fullInventory = new Inventory (rubbishItems.Length);

            emptyObserver = new ObserverImpl(emptyInventory);
            fullObserver = new ObserverImpl(fullInventory);

            ((Subject) emptyInventory).AddObserver(emptyObserver);
            ((Subject) fullInventory).AddObserver(fullObserver);

            foreach (InventoryItem item in rubbishItems) {
                fullInventory.AddItem(item);
            }
        }
开发者ID:ocoulson,项目名称:MScProjectUnity,代码行数:19,代码来源:InventoryTest.cs

示例7: OnMouseDown

    void OnMouseDown()
    {
        //		itemType = item.Item.ItemType.ToString();
        //		itemID = item.Item.ItemID;
        //		Debug.Log (itemID.ToString());
        //		Debug.Log (itemType);

        if(photonView.isMine)
        {
            inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();
            if(inventory.AddItem (GetComponent<ItemScript>()))
            {

                //PhotonNetwork.Destroy (this.gameObject);
                //DestroyItem ();

                GetComponent<PhotonView>().RPC ("DestroyItem", PhotonTargets.All, null);

            }

        }
        else
        {

            inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();

            //item = this.GetComponent<ItemScript>();

            ItemScript newItem = tmp.GetComponent<ItemScript>();

            //newItem.Item = InventoryManager.Instance.ItemContainer.Consumables[itemID];
            //newItem.Item = InventoryManager.Instance.ItemContainer.Weapons[itemID];
            newItem.Item = InventoryManager.Instance.ItemContainer.Weapons[itemID];

            //newItem.Item = InventoryManager.Instance.ItemContainer.Consumables[findItem];

            inventory.AddItem(newItem);
            GetComponent<PhotonView>().RPC ("DestroyItem", PhotonTargets.All, null);

            Debug.Log (itemID.ToString());

        }
    }
开发者ID:jordanepickett,项目名称:RPG,代码行数:43,代码来源:PickUpWeapon.cs

示例8: DrawModelInEditor

    /// <summary>
    /// Display the Model in the Editor.</summary>
    void DrawModelInEditor(Inventory inventory)
    {
        for (int i = 0; i < inventory._items.Count; i++)
        {
            EditorGUILayout.BeginHorizontal("box");
            string displayRow = inventory._items[i]._name + "\tx " + inventory._quantities[i];
            EditorGUILayout.LabelField(displayRow);

            if (GUILayout.Button("+"))
            {
                inventory.AddItem(inventory._items[i], 1);
                EditorUtility.SetDirty(inventory);
                EditorGUILayout.EndHorizontal();
                break;
            }
            if (GUILayout.Button("-"))
            {
                inventory.RemoveItem(inventory._items[i], 1);
                EditorUtility.SetDirty(inventory);
                EditorGUILayout.EndHorizontal();
                break;
            }
            if (GUILayout.Button("X"))
            {
                inventory.RemoveItem(inventory._items[i], inventory._quantities[i]);
                EditorUtility.SetDirty(inventory);
                EditorGUILayout.EndHorizontal();
                break;
            }
            EditorGUILayout.EndHorizontal();
        }

        if (GUILayout.Button("Reset"))
        {
            inventory.Reset();
            EditorUtility.SetDirty(inventory);
        }
    }
开发者ID:PaulSchweizer,项目名称:GameDev,代码行数:40,代码来源:InventoryEditor.cs

示例9: InterpretParseInventoryList

	public void InterpretParseInventoryList(Inventory inventory, byte[] data)
	{
		List<ParseInventoryItem> items = new List<ParseInventoryItem>();
		BinaryFormatter bb = new BinaryFormatter();
		MemoryStream mm = new MemoryStream(data);
		items = (List<ParseInventoryItem>)bb.Deserialize(mm);
		for (int i = 0; i < items.Count; i++) 
		{
			if(items[i].UniqueItemId.IndexOf("ARMOR") != -1)
			{
				inventory.AddItem(Storage.LoadbyUniqueId<RPGArmor>(items[i].UniqueItemId, new RPGArmor()), items[i].ItemLevel, items[i].Amount, items[i].isItemViewed);
				if(items[i].IsItemEquipped)
				{
					inventory.EquipItem(items[i].UniqueItemId, items[i].ItemLevel);
				}
			}
			else if(items[i].UniqueItemId.IndexOf("ITEM") != -1)
			{
				inventory.AddItem(Storage.LoadbyUniqueId<RPGItem>(items[i].UniqueItemId, new RPGItem()), items[i].ItemLevel, items[i].Amount, items[i].isItemViewed);
			}
		}
	}
开发者ID:reaganq,项目名称:MagnetBots_unity,代码行数:22,代码来源:PlayerInformation.cs

示例10: MakePotion

    // Make a potion out of the ingredients in the cauldron,
    // add it into player's inventory and empty the cauldron
    void MakePotion()
    {
        database = GameObject.FindGameObjectWithTag("Item Database").GetComponent<ItemDatabase>();
        inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent<Inventory>();

        int redMushrooms = 0;
        int greenMushrooms = 0;
        int blueMushrooms = 0;
        potionCreated = 5; //number based on which potion is created

        for (int i=0; i < potionIngredients.Count; i++) {
            if (potionIngredients[i].itemID == 0) { // Red mushrooms
                redMushrooms += 1;
            }
            if (potionIngredients[i].itemID == 1){
                greenMushrooms += 1;
            }
            if (potionIngredients[i].itemID == 2){
                blueMushrooms += 1;
            }
        }
        print (" Red: "+ redMushrooms + " Green: "+greenMushrooms + " Blue: "+blueMushrooms);
        // Health potion
        if (redMushrooms == 1 && greenMushrooms == 1 && blueMushrooms == 1) {
            potionCreated = 3;
            potion = database.items [3];
            print ("Health potion");
        } else {
            // Super Jump potion
            if (redMushrooms == 1 && blueMushrooms == 2) {
                potionCreated = 4;
                potion = database.items [4];
                print ("Jump potion");
            }
            else {
                //Fireball potion
                if(redMushrooms == 3){
                    potionCreated = 6;
                    potion = database.items[5];
                    print ("Fireball potion");
                }
                else{
                    // Useless Potion
                    potionCreated = 5;
                    potion = database.items [5];
                    print ("No potion");
                }
            }
        }
        inventory.AddItem(potion.itemID);
        //Empty the cauldron
        this.potionIngredients.Clear();
        //Play animation
        playerModel.GetComponent<AnimationController>().CastSpell();
        //Play Cauldron bubbling sound
        cauldronBubblingSoundEffect = Instantiate (cauldronBubblingSound).gameObject;
        Destroy (cauldronBubblingSoundEffect, 2);
        //Save inventory
        Save();
        //Wait for the animation to finish before showing the message
        StartCoroutine ("WaitThreeSeconds");
    }
开发者ID:jopesy,项目名称:The-Alchemist,代码行数:64,代码来源:Cauldron.cs

示例11: Start

    void Start()
    {
        ef = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>().EquipmentFactory;

        inventory = new Inventory();

        //Debug.Log("count: " + inventory.Items.Count.ToString());
        if (inventory.Items.Count <= 0)
        {

            int diceroll = Random.Range(1, 5);
            if (diceroll <= 3)
            {
                for (int i = 0; i < diceroll; i++)
                {
                    inventory.AddItem(ef.randomEquipment(2));
                }
            }
            else if (diceroll > 3)
            {
                inventory.AddItem(ef.randomEquipment(3));
            }
        }

        if(isActive)
        {
            Activate();
        }
    }
开发者ID:ryanadair009,项目名称:CMPS427,代码行数:29,代码来源:LootTrigger.cs

示例12: ShiftToInventory

 public void ShiftToInventory(Item item, Inventory inventoryA, Inventory inventoryB)
 {
     inventoryB.RemoveItem (item);
     inventoryA.AddItem (item);
 }
开发者ID:Antrum,项目名称:Unity,代码行数:5,代码来源:InventoryManager.cs

示例13: Attach

 public void Attach(Inventory inventory)
 {
     inventory.AddItem(this);
 }
开发者ID:thebatoust,项目名称:GameJamNatureRevenge,代码行数:4,代码来源:ItemV2.cs

示例14: Start

    // Use this for initialization
    void Start()
    {
        mInventory = new Inventory();
        mInventory.AddItem("Blooanium", "item_blooanium",	(int)Random.Range(36,62), 10);
        mInventory.AddItem("Waste", "item_waste",			(int)Random.Range(30,50), 13);
        mInventory.AddItem("Scrapmetal", "item_scrapmetal",	(int)Random.Range(20,300), 5);
        mInventory.AddItem("Fuelrods", "item_fuelrods",		(int)Random.Range(36,44), 20);
        mInventory.AddItem("Potatoes", "item_potatos",		(int)Random.Range(128,256), 2);
        mInventory.AddItem("Handhelds", "item_handhelds",	(int)Random.Range(12,56), 64);
        mInventory.AddItem("Pinklabel", "item_pinklabel",	(int)Random.Range(2,8), 96);
        mInventory.AddItem("Veggies", "item_veggies",		(int)Random.Range(12,400), 2);

        mNearbyShips = new List<GameObject>();
        mLineRenderers = new List<GameObject>();
        mCreatedMenuItemsToBeDestroyed = new Stack<GameObject>();
        GO_Player = GameObject.Find("Player");
    }
开发者ID:randonia,项目名称:ld30,代码行数:18,代码来源:StationController.cs

示例15: LuoUusiMaailma

    void LuoUusiMaailma(InputWindow ikkuna)
    {
        kentanNimi = ikkuna.InputBox.Text;
        Vedikartta = new List<PhysicsObject>();
        Gravity = new Vector(0, -900);
        LataaKentta(new ColorTileMap( generate(200, 60,kentanNimi) ) );
        LisaaNappaimet();
        Inventory inventory = new Inventory();
        Add(inventory);
        yu = new HorizontalLayout();
        yu.Spacing = 5;
        qq = new VerticalLayout();
        foreach (PhysicsObject esine in esineet())
        {
            inventory.AddItem(esine, kivihakku);
            inventory.SelectItem(esine);
        }
        inventory.Y = Screen.Top - 20;

        int luku = RandomGen.NextInt(1, 200);
        luopuu(luku);
        //luopuu(new Vector kentanPiste = Level.GetRandomPosition());

        Camera.Zoom(1.5);
        //Camera.ZoomToLevel();
        Camera.Follow(pelaaja1);

        luojano();
        esineet2 = new List<GameObject>();
        esineslotit = new List<Widget>();
        käsiselecteditem = 1;
        GameObject banaanit = new GameObject(35, 35);
        banaanit.Image = banaanikuva;
        esineet2.Add(banaanit);
        GameObject puuhakku = new GameObject(35, 35);
        puuhakku.Image = kivihakku;
        esineet2.Add(puuhakku);
        käsitaso = new List<Widget>();
        luoesinevalikko();
    }
开发者ID:EA99,项目名称:sejypeli,代码行数:40,代码来源:bbd.cs


注:本文中的Inventory.AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。