private CollectableItem GetRandomBonus() { LevelProps levelProps = obstacleSpawner.GetLevelProps(); int bonusCount = levelProps.levelParachutes.Length; CollectableItem randomCollectable = levelProps.levelParachutes[UnityEngine.Random.Range(0, bonusCount)] .GetComponent <CollectableItem>(); while (randomCollectable.collectableType == CollectableItem.CollectableType.RandomCollectable) { randomCollectable = levelProps.levelParachutes[UnityEngine.Random.Range(0, bonusCount)] .GetComponent <CollectableItem>(); } return(randomCollectable); }