private void Start() { if (Description.Count > 0) { currentSpawn = Description[0]; } playerController = GameObject.Find("Player").GetComponent <PlayerController>(); SetUpAllowedColors(); }
private void Update() { perItemTimer += Time.deltaTime; bool shouldIterate = indexInDescription <Description.Count && perItemTimer> currentSpawn.TimeAfterPrevious && currBlock < currentSpawn.blocksInRound; if (shouldIterate) { perItemTimer = 0.0f; currBlock++; bool shouldSpawn = currentSpawn.AllowedColors != EColorFlag.None; if (shouldSpawn) { GameObject wall = Instantiate(WallPrefab, transform.position, Quaternion.identity, null); var comp = wall.GetComponent <Wall>(); comp.color = EColorRGBHelper.GetRandomFlagFromFlags(currentSpawn.AllowedColors); comp.Speed = currentSpawn.blockSpeed; } } else if (currBlock >= currentSpawn.blocksInRound) { roundAfterTimer += Time.deltaTime; if (indexInDescription == 0 && !AudioManager.bgmPlaying && roundAfterTimer > currentSpawn.TimeAfterAround / 2) { AudioManager.StartBGM(); } if (roundAfterTimer > currentSpawn.TimeAfterAround) { roundAfterTimer = 0.0f; currBlock = 0; prevIndex = indexInDescription; if (indexInDescription < Description.Count - 1) { indexInDescription++; } currentSpawn = Description[indexInDescription]; if (prevIndex != indexInDescription) { AudioManager.PlayVoice(indexInDescription); } SetUpAllowedColors(); } } }