TO SQUASH: Yummy text on get.

This commit is contained in:
2026-08-27 21:51:28 -04:00
parent 67fc884bc4
commit ba1a7ba281
16 changed files with 496 additions and 71 deletions
+23 -14
View File
@@ -18,13 +18,15 @@ public class YummyCake : MonoBehaviour
public GameObject keyPrefab;
public Canvas canvas;
private AudioSource audioSource;
private Animator animator;
private WorldFiller worldFiller;
private static float laserProbability = 0.4f;
private static float laserProbability = 0.25f;
private static float magnetProbability = 0.2f;
@@ -70,21 +72,31 @@ public class YummyCake : MonoBehaviour
private void SpawnItem(float randomValue)
{
if (randomValue < laserProbability)
float laserThreshold = laserProbability;
float magnetThreshold = laserThreshold + magnetProbability;
float keyThreshold = magnetThreshold + keyProbability;
GameObject item = null;
if (randomValue < laserThreshold)
{
Instantiate(laserPrefab, transform.position, Quaternion.identity);
item = Instantiate(laserPrefab, transform.position, Quaternion.identity);
}
else if (randomValue < magnetProbability)
else if (randomValue < magnetThreshold)
{
Instantiate(magnetPrefab, transform.position, Quaternion.identity);
item = Instantiate(magnetPrefab, transform.position, Quaternion.identity);
}
else if (randomValue < keyProbability)
else if (randomValue < keyThreshold)
{
Instantiate(keyPrefab, transform.position, Quaternion.identity);
item = Instantiate(keyPrefab, transform.position, Quaternion.identity);
}
else
{
Instantiate(lightningPrefab, transform.position, Quaternion.identity);
item = Instantiate(lightningPrefab, transform.position, Quaternion.identity);
}
if (item != null)
{
item.GetComponent<YummyBase>().canvas = canvas;
}
}
@@ -106,14 +118,11 @@ public class YummyCake : MonoBehaviour
else
{
// The first yummy is guaranteed.
float randomValue = 0.0f;
SpawnItem(Random.value);
while (randomValue < manyProbability)
while (Random.value < manyProbability)
{
SpawnItem(randomValue);
// Update randomValue to determine if we should spawn another item.
randomValue = Random.value;
SpawnItem(Random.value);
}
}
}