private void SetDeathBarrier() { var db = Instantiate(deathBarrier, transform.position, Quaternion.identity); db.localScale = new Vector3((float)(levelPartLength * originalNumberOfLevelParts), db.localScale.y, db.localScale.z); db.transform.position += new Vector3(db.localScale.x / 2, 0f, 0f); Vector3 lowestVector = new Vector3(db.localScale.x / 2, 0f, 0f); foreach (var part in CurrentLevelParts) { LevelPartGenerator partScript = part.GetComponent <LevelPartGenerator>(); if (partScript != null) { foreach (var platform in partScript.platformList) { if (platform.transform.position.y < lowestVector.y) { lowestVector = new Vector3(lowestVector.x, platform.transform.position.y, lowestVector.z); } } } } db.transform.position = lowestVector + new Vector3(0f, -10f, 0f); if (levelPartsList.Count == 0) { var endPart = Instantiate(endZone, new Vector3(currentLevelPart_x, db.transform.position.y, 0), Quaternion.identity); endPart.localScale = new Vector3((float)(levelPartLength / 2), endPart.localScale.y, endPart.localScale.z); endPart.transform.position += new Vector3(endPart.localScale.x / 2, 0f, 0f); //var eCol = endPart.GetComponent<BoxCollider>(); //eCol.isTrigger = true; } }
private void SpawnLevelPart(Vector3 spawnPosition) { int stageMaxInt = levelPartsList.Count - 1; int stageInt = Random.Range(0, stageMaxInt); var currentLevelPart = Instantiate(levelPartsList[stageInt], spawnPosition, Quaternion.identity); LevelPartGenerator currentLevelPartScript = currentLevelPart.GetComponent <LevelPartGenerator>(); currentLevelPartScript.parentTransform = transform; currentLevelPartScript.levelPartLength = levelPartLength; currentLevelPartScript.endLevelPartVector = spawnPosition + new Vector3(levelPartLength, 0f, 0f); currentLevelPartScript.maxPlatformVerticalSpace = maxPlatformVerticalSpace; currentLevelPartScript.maxPlatformHorizontalSpace = maxPlatformHorizontalSpace; currentLevelPartScript.numberOfPlatformsPerlevelPart = numberOfPlatformsPerlevelPart; levelPartsList.RemoveAt(stageInt); //CurrentLevelParts.Add(currentLevelPart); CurrentLevelPartChange(currentLevelPart); }