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


C# Item.Clone方法代码示例

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


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

示例1: Add

    public bool Add(ref Item item)
    {
        IEnumerator enumerator = WeaponsList.GetEnumerator();

        while(enumerator.MoveNext())
        {
            Item weapon = (Item)enumerator.Current;
            if (weapon.Information.getID() == item.Information.getID())
            {
              //  weapon.setSlotID(InventoryHeadID);
                weapon.Information.Number = weapon.Information.Number + item.Information.Number;

               // Debug.Log("Zwieszkono ilosc itemu *********");
                return false;
            }
        }

        Debug.Log("Dodano NOWY  itemu *********");
        Item newItem = (Item)item.Clone();
        item = newItem;

        InventoryHeadID++;
        item.Information.Number++;
        item.setSlotID(InventoryHeadID);
        WeaponsList.Add(item);

        enumerator = WeaponsList.GetEnumerator();
        while (enumerator.MoveNext())
        {
            if( object.ReferenceEquals(item, enumerator.Current) )
                Debug.Log("WYSTEPUJE KURWA JEBANA REFERENCJA POMIEDZY POIERDOLONYI OBIEKTAMI");
        }
        return true;
    }
开发者ID:Lukasz199312,项目名称:SmithCrafter,代码行数:34,代码来源:Inventory.cs

示例2: AddWeapon

    // zwraca true jestli tworzy nowy slot
    public static bool AddWeapon(Item item)
    {
        foreach (Item weapon in Weapons)
        {
            if (weapon.Information.getID() == item.Information.getID())
            {
                weapon.setSlotID(InventoryHeadID);
                weapon.Information.Number++;
                Debug.Log("Zwieszkono ilosc itemu");
                return false;
            }
        }

        Item newItem = (Item)item.Clone();

        InventoryHeadID++;
        newItem.Information.Number++;
        newItem.setSlotID(InventoryHeadID);
        Weapons.Add(newItem);
        Debug.Log("dodano nowy slot");
        return true;
    }
开发者ID:Lukasz199312,项目名称:SmithCrafter,代码行数:23,代码来源:PlayerData.cs

示例3: AddItemToInventory

    public static bool AddItemToInventory(Item item)
    {
        //Looking for the same item
        if (item.isStackable) //If the item is stackable
        {
            for (int i = 0; i < Items.Length; i++)
            {
                if (Items[i] != null)
                {
                    if (Items[i].Name == item.Name)
                    {
                        Items[i].Count += item.Count;
                        GlobalEventText.AddMessage(string.Format("You picked up \"{0}\" (x{1})", item.Name, item.Count));
                        if (InventoryCaneva.panel.gameObject.activeInHierarchy)
                            InventoryCaneva.RefreshUI();
                        return true;
                    }
                }
            }
        }

        //Trying to add the item to the inventory
        for (int i = 0; i < Items.Length; i++)
        {
            if (Items[i] == null)
            {
                Items[i] = (Item)item.Clone();
                GlobalEventText.AddMessage(string.Format("You picked up \"{0}\" (x{1})", item.Name, item.Count));
                if (InventoryCaneva.panel.gameObject.activeInHierarchy)
                    InventoryCaneva.RefreshUI();
                return true;
            }
        }

        //Inventory full
        Debug.Log("Inventory full!");
        GlobalEventText.AddMessage(string.Format("You can't pickup \"{0}\", because your inventory is full", item.Name));
        return false;
    }
开发者ID:PierreGac,项目名称:turbulent-dwarf,代码行数:39,代码来源:Inventory.cs

示例4: CreateGameObjectFromItem

    public static GameObject CreateGameObjectFromItem(Item item)
    {
        GameObject obj = new GameObject(item.Name);
        //Sprite renderer
        SpriteRenderer sprite = obj.AddComponent<SpriteRenderer>();
        sprite.sprite = item.InGameSprite;
        sprite.sortingLayerID = item.SortingLayer;

        //BoxCollider
        BoxCollider2D collider = obj.AddComponent<BoxCollider2D>();
        collider.size = sprite.sprite.bounds.size;

        MonoItem monoItem = obj.AddComponent<MonoItem>();
        monoItem.thisItem = (Item)item.Clone();
        monoItem.thisItem.gameObject = obj;
        monoItem.Type = item.Type;
        monoItem.isJustSpawned = true;
        monoItem.spriteRenderer.enabled = true;

        return obj;
    }
开发者ID:PierreGac,项目名称:turbulent-dwarf,代码行数:21,代码来源:MonoItem.cs

示例5: Split

	public void Split(Item item, int pos, int amount)
	{
		int NewItemStackAmount = amount;
		int OldItemStackAmount = Items [pos].StackAmount - amount;

		Item SplitItem = item.Clone ();
		SplitItem.StackAmount = NewItemStackAmount;

		if (Additem (SplitItem)) 
		{
			Items[pos].StackAmount = OldItemStackAmount;
		}
	}
开发者ID:Gapti,项目名称:Starboard_INT,代码行数:13,代码来源:ItemStorage.cs


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