usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;publicclassObstacleSpawner:MonoBehaviour{privateEventTimelinetimeline=newEventTimeline();publicGameObjectcaveWallsPrefab,rockTopPrefab,rockBottomPrefab,narrowPassagePrefab,rockJawsPrefab;publicLevelScrollingscrolling;publicMessengermessenger;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;}vartransformT=((GameObject)Instantiate(prefab,newVector3(spawnLine,e.height,0),Quaternion.identity)).transform;scrolling.Obstacles.Add(transformT);}voidStart(){for(inti=0;i<120;i+=5){timeline.Add(i,0,ObstacleType.caveWalls);}timeline.Add(2,2.75f,ObstacleType.rockTop);timeline.Add(8,-2,ObstacleType.rockBottom);timeline.Add(20,0,ObstacleType.narrowPassage);timeline.Add(30,0,ObstacleType.rockJaws);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;}}