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(){for(inti=0;i<120;i+=5){timeline.Add(i,newVector3(0,0,0),ObstacleType.caveWalls);}timeline.Add(0,newVector3(0,2.75f,0),ObstacleType.rockTop);timeline.Add(6,newVector3(0,-2,0),ObstacleType.rockBottom);timeline.Add(12,newVector3(0,0,0),ObstacleType.narrowPassage);timeline.Add(20,newVector3(0,-2.5f,2),ObstacleType.rockJaws);timeline.Add(25,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;}}