private int spawnItems(List <ItemSpawnLocation> spawnLocations, int min, int max, ItemType type) { int spawnCount = Random.Range(min, max + 1); int i = 0; while (i < spawnCount) { ItemSpawnLocation spawnLocation = spawnLocations [Random.Range(0, spawnLocations.Count)]; if (spawnLocation.item == null) { PickableItemContainer item = PickableitemFactory.Instance.pool.Retrieve(); spawnLocation.item = item; Vector3 pos = spawnLocation.transform.position; if (type == ItemType.AMMO) { item.ammo.gameObject.SetActive(true); pos.y += 1f; } else { item.health.gameObject.SetActive(true); pos.y += 0.8f; } item.transform.position = pos; i++; } } return(spawnCount); }
// Update is called once per frame void Update() { if (item != null && ((type == ItemType.AMMO && item.ammo.pickedUp) || (type == ItemType.HEALTH && item.health.pickedUp))) { SpO2GameManager.Instance.ItemPickedUp(item, type); item = null; } }
public void ItemPickedUp(PickableItemContainer item, ItemType type) { if (type == ItemType.AMMO) { ammoCount--; } else { healthCount--; } PickableitemFactory.Instance.pool.Return(item); }