using System.Collections; using System.Collections.Generic; using UnityEngine; public class Obstacle : MonoBehaviour { public List easyObstacleObjs; public List mediumObstacleObjs; public List hardObstacleObjs; private void Start() { Starter(); } public void Starter() { List list = DifficultyList(); int rand = Random.Range(0, list.Count); list[rand].gameObject.SetActive(true); } List DifficultyList() { int difficultyLevel = (int)GameManager.instance.difficultyLevel; //return difficultyLevel == 0 ? easyObstacleObjs : difficultyLevel == 1 ? mediumObstacleObjs : hardObstacleObjs; int percentAge = Random.Range(0, 100); if (difficultyLevel == 0) { return easyObstacleObjs; } else if (difficultyLevel == 1) { if (percentAge < 75) { return mediumObstacleObjs; } else { Debug.Log("Difficulty Medium but Obstacle Easy"); return easyObstacleObjs; } } else { if (percentAge < 75) { return hardObstacleObjs; } else if (percentAge >= 75 && percentAge < 87) { Debug.Log("Difficulty Hard but Obstacle Medium"); return mediumObstacleObjs; } else { Debug.Log("Difficulty Hard but Obstacle Easy"); return easyObstacleObjs; } } } }