public IEnumerator StartGeneration() { float chance = 100 / allColors.Length; cons = -0.0001f * Mathf.Pow(chance, 3) + 0.01f * Mathf.Pow(chance, 2) + 0.1483f * chance - 0.8432f; yield return(new WaitForSeconds(1)); started = true; while (started) { if (lastCube == null || currentDistance >= Distance) { lastCube = pooler.SpawnFromPull(PrefabCube, startPoint.position, transform); GameObject particle = lastCube.transform.GetChild(0).gameObject; particle.SetActive(false); lastCube.GetComponent <CubeToCanvasMovement>().statement = false; lastCube.GetComponent <CubeInBandMovement>().enabled = true; if (Random.Range(0, 100) < currentChance) { lastCube.GetComponent <Renderer>().materials[0].color = gameManager.CurrentCube.normal; currentChance = cons * koef; } else { currentChance += cons; Color color = allColors[Random.Range(0, allColors.Length)]; while (color == gameManager.CurrentCube.normal) { color = allColors[Random.Range(0, allColors.Length)]; } lastCube.GetComponent <Renderer>().materials[0].color = color; } currentDistance = 0; lastCubePos = startPoint.localPosition; } else { currentDistance += (lastCube.transform.localPosition - lastCubePos).magnitude; lastCubePos = lastCube.transform.localPosition; } yield return(null); } }
private void DropHeart() { pooler.SpawnFromPull(pointPrefab, transform.position); }