public GameObject TrySpawn(Transform parent, float difficulty) { GameObject newSpawn = null; // Within allowable timespan? if (timer <= Time.time) { timer = Time.time + interval; // Within acceptable difficulty range? Chance factor? if (difficulty >= minDifficulty && difficulty <= maxDifficulty && (prefab) && SeededRandom.Value() <= chance) { newSpawn = GameObject.Instantiate(prefab) as GameObject; newSpawn.transform.SetParent(parent); } } return(newSpawn); }