public void Spawn(TunnelSegment segment) { if (playing.Value) { if (buildingStretch) { SpawnStretchLayout(segment, stretchRotation); } else { SpawnRandomLayout(segment); } } else { SpawnBlank(segment); // if next segment is the last, flag the spawning segment if (nextSegmentIsLastOfGame) { segment.lastSegmentOfGame = true; nextSegmentIsLastOfGame = false; } } }
void SpawnStretchLayout(TunnelSegment segment, int startRotation) { nextStretchLayout = currentStretch.GetNextLayout(); segment.Remake(nextStretchLayout, startRotation); if (currentStretch.IsNew()) { currentStretch = GetNewStretch(); buildingStretch = false; } }
void InitSegments() { segmentLength = segmentPrefab.floorPrefab.firewall.transform.localScale.z; for (int i = 0; i < poolSize; i++) { TunnelSegment newSegment = Instantiate(segmentPrefab, transform); newSegment.buffers = buffers; newSegment.transform.position += new Vector3(0, 0, segmentLength * i); segmentPool.Add(newSegment); } indexOfFirst = 0; indexOfLast = segmentPool.Count - 1; }
void SpawnBlank(TunnelSegment segment) { segment.RemakeBlank(); }
void SpawnRandomLayout(TunnelSegment segment) { segment.Remake(probabilityFirewall, probabilityCube); }