//---------------------- //PRIVATE METHODS //---------------------- //Drop an item when dead private void DropItem() { if (ItemDrop != null) { //Spawn the item on the loot table LevelManager.ItemSpawnInfo spawnInfo = new LevelManager.ItemSpawnInfo(ItemDrop, VEnemy.transform.position.x, VEnemy.transform.position.y); GameManager.Instance.SpawnItem(spawnInfo); } }
//---------------------- //PUBLIC METHODS //---------------------- //Spawn an item public void SpawnItem(LevelManager.ItemSpawnInfo info) { //Create the item GameObject item = (GameObject)Instantiate(VisualItem); //Add the item info to it item.GetComponent <VisualItem>().Info = info.item; info.item.VItem = item.GetComponent <VisualItem>(); //Set the world position of the item item.transform.position = new Vector3(info.xPos, info.yPos, 0); }