private void LoadSection() { Vector3 oldSectionPosition; LevelSectionController newSection = Instantiate(LevelSections.Find(x => x.Section == _nextSection), transform); _levelSections.Add(newSection); if (newSection.Section != SectionType.START_SECTION) { oldSectionPosition = _levelSections[_levelSections.Count - 2].transform.position; newSection.transform.position = new Vector3(oldSectionPosition.x + _levelSections[_levelSections.Count - 2].OffsetX, oldSectionPosition.y + _levelSections[_levelSections.Count - 2].OffsetY, 0.0f); } CinemachineSmoothPath.Waypoint newWaypoint = new CinemachineSmoothPath.Waypoint(); newWaypoint.position = new Vector3(newSection.CameraPathPoint.transform.position.x, newSection.CameraPathPoint.transform.position.y, CameraDistance); _cameraWaypoints.Add(newWaypoint); OnCameraWaypointsChanged(_cameraWaypoints); _pressureWayoints.Add(new Vector3(newSection.CameraPathPoint.transform.position.x, newSection.CameraPathPoint.transform.position.y, 0.0f)); _pressureWayoints.Add(newSection.PressurePathPoint.transform.position); List <SectionType> possibleNextSections = newSection.PossibleNextSections; _nextSection = possibleNextSections[_pseudoRandom.Next(0, possibleNextSections.Count - 1)]; }
void Start() { controller = GameObject.FindWithTag("GameController"); controlScript = controller.GetComponent <LevelSectionController>(); leftBorder = -controlScript.borderDistance; }