usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassObstacleSpawner:MonoBehaviour{privateEventTimelinetimeline=newEventTimeline();publicGameObjectcaveWallsPrefab,rockTopPrefab,rockBottomPrefab,narrowPassagePrefab,rockJawsPrefab,netPrefab;publicLevelScrollingscrolling;publicfloatspawnLine;privatevoidspawnOnEvent(EventTimeline.SpawnEvente){GameObjectprefab=null;switch(e.type){caseObstacleType.caveWalls:prefab=caveWallsPrefab;break;caseObstacleType.rockTop:prefab=rockTopPrefab;break;caseObstacleType.rockBottom:prefab=rockBottomPrefab;break;caseObstacleType.narrowPassage:prefab=narrowPassagePrefab;break;caseObstacleType.rockJaws:prefab=rockJawsPrefab;break;caseObstacleType.net:prefab=netPrefab;break;}varo=Instantiate(prefab,newVector3(spawnLine,e.position.y,e.position.z),Quaternion.identity);scrolling.Obstacles.Add(o);}voidStart(){varscene=UnityEngine.SceneManagement.SceneManager.GetActiveScene();if(scene.name=="TitleScreen"){for(inti=0;i<1000;i++){timeline.Add(i*2.5f,newVector3(0,0,0),ObstacleType.caveWalls);timeline.Add(i*12.5f+3,newVector3(0,2.75f,0),ObstacleType.rockTop);timeline.Add(i*12.5f+6,newVector3(0,-2,0),ObstacleType.rockBottom);timeline.Add(i*12.5f+9,newVector3(0,0,0),ObstacleType.narrowPassage);timeline.Add(i*12.5f+12.5f,newVector3(0,-2.5f,2),ObstacleType.rockJaws);timeline.Add(i*12.5f+15f,newVector3(0,0.5f,3),ObstacleType.net);}}elseif(scene.name=="Tutorial"){for(inti=0;i<60;i++)timeline.Add(i*2.5f,newVector3(0,0,0),ObstacleType.caveWalls);timeline.Add(10,newVector3(0,2.75f,0),ObstacleType.rockTop);timeline.Add(15,newVector3(0,-2,0),ObstacleType.rockBottom);timeline.Add(20,newVector3(0,2.75f,0),ObstacleType.rockTop);timeline.Add(23,newVector3(0,-2,0),ObstacleType.rockBottom);timeline.Add(26,newVector3(0,2.75f,0),ObstacleType.rockTop);timeline.Add(40,newVector3(0,0,0),ObstacleType.narrowPassage);timeline.Add(48,newVector3(0,-2.5f,2),ObstacleType.rockJaws);timeline.Add(56,newVector3(0,0.5f,3),ObstacleType.net);}elseif(scene.name=="Level1"){for(inti=0;i<1000;i++){timeline.Add(i*2.5f,newVector3(0,0,0),ObstacleType.caveWalls);timeline.Add(i*12.5f+3,newVector3(0,2.75f,0),ObstacleType.rockTop);timeline.Add(i*12.5f+6,newVector3(0,-2,0),ObstacleType.rockBottom);timeline.Add(i*12.5f+9,newVector3(0,0,0),ObstacleType.narrowPassage);timeline.Add(i*12.5f+12.5f,newVector3(0,-2.5f,2),ObstacleType.rockJaws);timeline.Add(i*12.5f+15f,newVector3(0,0.5f,3),ObstacleType.net);}}timeline.OnSpawnEvent+=spawnOnEvent;}// Update is called once per framevoidUpdate(){timeline.timeTick(Time.deltaTime);}voidOnDrawGizmosSelected(){Gizmos.color=Color.green;Gizmos.DrawLine(newVector3(spawnLine,-10,0),newVector3(spawnLine,10,0));}publicEventTimelineGetEventTimeline(){returntimeline;}}