private IEnumerator StartChocolates() { while (true) { yield return(new WaitForSeconds( Random.Range(_levelData.ChcolateIntervals.IntervalStart, _levelData.ChcolateIntervals.IntervalEnd))); foreach (var chocolate in _levelData.ChocolateProbabilityes) { if (Random.Range(1, 100) < chocolate.Probability) { GameObject newChocolate = _factory.GetChocolate(chocolate.ChocolateType); newChocolate.transform.position = new Vector3( Random.Range(_startChocolatePointLeft.position.x, _startChocolatePointRight.position.x), _startChocolatePointLeft.position.y, _startChocolatePointLeft.position.z); } } } }