Skip to main content

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.

Constructors​

MemberWhat it is
FruitNinja()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

13 private and internal fields
MemberWhat it is
private float angleRangeTotal spread in degrees of the launch angle.
private bool isStartingInspector Start button.
private bool isStoppingInspector Stop button.
private List<Item> itemsToSpawnItems picked from at random.
private float maxVelocityHighest launch speed.
private float minVelocityLowest launch speed.
private List<NetworkEntity> spawnedEntitiesEvery entity this spawner made. Never cleared.
private AltaCoroutine spawningRoutineThe running spawn coroutine, or null.
private float spawnLengthLength of the spawn line along the object's x axis.
private float spawnSpeedUpVariationPercentRandom variation applied to the spawn rate each time.
private AnimationCurve speedUpOvertimeSpawn rate multiplier over seconds since starting.
private float startSpawnIntervalSeconds between spawns at a rate of 1.
private float startTimeWhen spawning started.

Methods​

MemberWhat it is
void StartSpawning()Starts (or restarts) the spawn coroutine.
void StopSpawning()Stops the spawn coroutine.
5 private and internal methods
MemberWhat 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.