private void SpawnLoot(int numLoot) { for (int i = 0; i < height; ++i) { for (int j = 0; j < width; ++j) { Vector2 cell = new Vector2(i, j); if (Vector2.Distance(new Vector2(2, 2), cell) > 1) { GameObject newEnemy = Instantiate(Globals.LOOT, new Vector2(), Quaternion.identity); newEnemy.transform.SetParent(ObjectContainer.instance.loot.transform); newEnemy.transform.position = RandomTileFromCell(cell); } } } int numToDelete = (height * width) - numLoot - 5; for (int i = 0; i < numToDelete; ++i) { List <GameObject> lootList = ObjectContainer.GetAllLoot(); GameObject enemyToDelete = lootList[PRNG.Range(0, lootList.Count)]; DestroyImmediate(enemyToDelete); } }