本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}