public void DropItems() { GameObject itemPickupPrefab = Manager.inventoryManager.GetItemPickupPrefab(); for (int i = 0; i < droppableItems.Count; i++) { GameObject itemToBeDropped = itemPickupPrefab; ItemPickup itemPickup = itemToBeDropped.GetComponent <ItemPickup>(); itemPickup.SetItem(droppableItems[i]); itemPickup.SetStackQuantity(1); itemPickup.SetImage(); itemPickup.SetWasDropped(false); var spawnedItem = Instantiate(itemPickup, new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z), Quaternion.identity); } }
public void PlayerDropItem() { if (draggedSlot != null) { print("Dropping item"); GameObject player = GameObject.FindGameObjectWithTag("Player"); GameObject itemPickupGameObject = itemPickupPrefab; ItemPickup newItemPickup = itemPickupGameObject.GetComponent <ItemPickup>(); newItemPickup.SetItem(draggedSlot.Item); newItemPickup.SetStackQuantity(draggedSlot.Amount); newItemPickup.SetImage(); newItemPickup.SetWasDropped(true); var itemPickup = Instantiate(itemPickupGameObject, new Vector3(player.transform.position.x, player.transform.position.y, player.transform.position.z), Quaternion.identity); draggedSlot.Item = null; draggedSlot.Amount = 0; ClearDraggedItem(); Manager.hotbarManager.UpdateHotbarSlots(); } }
/// <summary> /// When the enemy dies, drop its items and destroy the enemy /// </summary> private void Death() { if (enemy.dropChance > Random.Range(0, 1f)) { ItemPickup item = Instantiate(itemPrefab, transform.parent); item.SetItem(new ItemStack(enemy.itemDrops[Random.Range(0, enemy.itemDrops.Length)].item, 1)); item.transform.position = transform.position; } int numExpOrbs = HelperScripts.RandomVec(enemy.numExpOrbs); int expPerOrb = Mathf.RoundToInt(enemy.experienceDrop / (float)numExpOrbs); GetComponent <EnemyMovement>().RemoveSpotClaim(); Destroy(gameObject); for (int i = 0; i < numExpOrbs; i++) { Experience exp = Instantiate(experiencePrefab, transform.parent); exp.transform.position = transform.position; exp.experienceAmount = expPerOrb; } }