public bool itemPick(GameObject aimItem)//捡取一件道具 { ItemOnGround itemOnGround = aimItem.GetComponent <ItemOnGround>(); Item item = itemOnGround.item; if (item.type == ItemType.pistol || item.type == ItemType.shotgun || item.type == ItemType.sniperRifle || item.type == ItemType.assaultRifle) { weaponList.Add(new ItemBlock(item)); } else if (item.type == ItemType.armor) { armorList.Add(new ItemBlock(item)); } else if (item.type == ItemType.ring) { ringList.Add(new ItemBlock(item)); } else if (item.type == ItemType.expendable) { expendableList.Add(new ItemBlock(item)); } else if (item.type == ItemType.other) { otherList.Add(new ItemBlock(item)); } return(true); }
public void onOpen() { if (!empty) { if (_item != null && _item.name != "") { GameObject item = Instantiate(Resources.Load("Prefab/ItemOnGround"), transform.position, new Quaternion()) as GameObject; ItemOnGround iog = item.AddComponent <ItemOnGround>(); iog.item = _item; iog.num = 1; } Destroy(gameObject, 2); empty = true; } }