FruitNinja
A class in Root.Township, Alta.Cooking.
Test spawner that throws random items upward from a line, faster and faster over time. Has Start and Stop buttons in the inspector.
- Listed in Crafting and making
- Inherits or implements
NetworkEntityBehaviour - Documented in Cooking
Constructors
| Member | What it is |
|---|---|
FruitNinja() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private float angleRange | Total spread in degrees of the launch angle. |
private bool isStarting | Inspector Start button. |
private bool isStopping | Inspector Stop button. |
private List<Item> itemsToSpawn | Items picked from at random. |
private float maxVelocity | Highest launch speed. |
private float minVelocity | Lowest launch speed. |
private List<NetworkEntity> spawnedEntities | Every entity this spawner made. Never cleared. |
private AltaCoroutine spawningRoutine | The running spawn coroutine, or null. |
private float spawnLength | Length of the spawn line along the object's x axis. |
private float spawnSpeedUpVariationPercent | Random variation applied to the spawn rate each time. |
private AnimationCurve speedUpOvertime | Spawn rate multiplier over seconds since starting. |
private float startSpawnInterval | Seconds between spawns at a rate of 1. |
private float startTime | When spawning started. |
Methods
| Member | What it is |
|---|---|
void StartSpawning() | Starts (or restarts) the spawn coroutine. |
void StopSpawning() | Stops the spawn coroutine. |
5 private and internal methods
| Member | What it is |
|---|---|
private void OnDrawGizmosSelected() | Draws the spawn line in the editor. |
private void OnValidate() | Runs the inspector Start or Stop buttons. |
private IEnumerator Spawn() (iterator) | Coroutine that spawns an item, then waits a shorter time as the speed-up curve rises. |
private void SpawnItem(Item toSpawn) | Spawns an item at a random point on the line and launches it upward at a random angle and speed. |
private void SpawnRandomItem() | Spawns a random item from the list, ignoring errors. |