void SetSpeed(ObstacleSpeed obsSpeed) { if (obsSpeed.Equals(ObstacleSpeed.Slow)) { speed = Random.Range(speedSlowMin, speedSlowMax); } if (obsSpeed.Equals(ObstacleSpeed.Fast)) { speed = Random.Range(speedFastMin, speedFastMax); } if (obsSpeed.Equals(ObstacleSpeed.Random)) { speed = Random.Range(speedSlowMin, speedFastMax); } }
// Spawns an obstacle based on provided information from LevelController.cs public void SpawnObstacle(ObstacleSpeed obsSpeed) { // If the level has not reached the maximum number of obstacles and obstacles should be spawned if (currObs < maxObs && !obsSpeed.Equals(ObstacleSpeed.NULL)) { SpawnPointAndRotation(); obstacle.GetComponent <ObstacleBehavior>().rotX = rotX; obstacle.GetComponent <ObstacleBehavior>().rotY = rotY; obstacle.GetComponent <ObstacleBehavior>().rotZ = rotZ; SetSpeed(obsSpeed); Instantiate(obstacle, chosenSpawn, Quaternion.identity); currObs += 1; } }