Listeners

To extend Core GameKit to the limit of your imagination, we have Listener scripts so that you can add custom behavior through code that will hook into a great many Core GameKit events. Each Listener script is an empty skeleton code template that you should not modify. Instead you should create subclasses from them to use for your purposes. For each method in these events, you are passed context objects so you can tell exactly what is happening. If you need more events to listen to, let us know!

Note: There is an example subclass of the Killable Listener in Example Scene 1, attached to the Main Camera prefab. It listens to the Killable on the Player prefab.

 

Hooking Up Listeners

Hooking up Listener scripts is easy. Let's take a look at Killable Listener. To set it up:

     
  1. Select a Killable object in your Scene.
  2.  
  3. In the Inspector, add a Killable Listener script from the Component menu (let's just use the stock one for now).

That's it! The Listener will look for a compatible object to listen to in the same Game Object automatically. i.e. adding a Killable Listener to a Game Object with Killable will automatically hook them together.

 

Note: If you want the listener to live in a different Game Object, the steps are a little different.

     
  1. In the Inspector, add a Killable Listener script from the Component menu (let's just use the stock one for now) to the Game Object you want to listen.
  2.  
  3. Select the Killable you want to listen to in the Hierarchy.
  4.  
  5. Under the Inspector for the Killable script, notice the "Listener" field which is currently unassigned. Drag the Game Object with the Killable Listener script into there.

That's it! Your Listener is now hooked up and will get called from Killable when the events occur. Note that the Listener does not need to be in the same object as the Killable.

 

Included Listeners & Events

We have included Listeners for the following. Click on a link to jump to that section:

     
  1. Level Wave Settings: Events for Level Wave Settings
  2.  
  3. Killable: Events for Killable
  4.  
  5. Pool Boss: Events for Pool Boss
  6.  
  7. Prefab Pool: Events for Prefab Pools
  8.  
  9. Triggered Spawner: Events for Triggered Spawners
  10.  
  11. Syncro Spawner: Events for Syncro Spawners
  12.  
  13. World Variable: Events for World Variables. Can display / update the value on a Text component in Unity uGUI, NGUI, or TextMeshPro.
  14.  
  15. Timed Despawner: Events for Timed Despawner
  16.  
  17. Triggered Despawner: Events for Triggered Despawner
  18.  
  19. Wave Music Changer: Events for Wave Music Changer

Level Settings Listener Events

     
  1. GameOver
  2.  
  3. Lose (GameOver but you didn't win)
  4.  
  5. LevelStarted (fired when the first Wave in a Level starts).
  6.  
  7. LevelEnded (fired when the last Wave in a Level is completed).
  8.  
  9. WaveItemsRemainingChanged (to update a display or any logic)
  10.  
  11. WaveTimeRemainingChanged (to update a display of seconds)
  12.  
  13. WaveStarted

    Tip: Use LevelSettings.CurrentLevelWave if you want to get the wave #.
  14.  
  15. WaveEnded
  16.  
  17. WaveEndedEarly
  18.  
  19. WaveSkipped
  20.  
  21. WaveCompleteBonusesStart (in case you want to modify the bonuses before they're awarded).
  22.  
  23. WaveRestarted
  24.  
  25. Win

Killable Listener Events

     
  1. Awake
  2.  
  3. SpawnerDestroyed
  4.  
  5. Despawning
  6.  
  7. TakingDamage
  8.  
  9. DamagePrefabSpawned
  10.  
  11. DamagePrefabFailedToSpawn
  12.  
  13. DeathDelayStarted
  14.  
  15. DeathPrefabSpawned
  16.  
  17. DeathPrefabFailedToSpawn
  18.  
  19. ModifyingDamageWorldVariables
  20.  
  21. ModifyingDeathWorldVariables
  22.  
  23. WaitingToDestroyKillable (used to play a death animation or other side effect)
  24.  
  25. DestroyingKillable
  26.  
  27. DeterminingScenario - used to change the Scenario used (which set of World Variables are going to be modified)

Pool Boss Listener Events

     
  1. PercentInitialized
  2.  
  3. InitializationComplete
  4.  
  5. ItemSpawned
  6.  
  7. ItemDespawned

Prefab Pool Listener Events

     
  1. PrefabGrabbedFromPool
  2.  
  3. PoolRefilling

Triggered Spawner Listener Events

     
  1. CustomEventReceived
  2.  
  3. Despawned
  4.  
  5. EventPropagating
  6.  
  7. PropagatedEventReceived
  8.  
  9. WaveEndedEarly
  10.  
  11. PropagatedWaveEndedEarly
  12.  
  13. ItemFailedToSpawn
  14.  
  15. ItemSpawned
  16.  
  17. Spawned
  18.  
  19. WaveEliminated
  20.  
  21. WaveFinishedSpawning
  22.  
  23. WaveStart
  24.  
  25. WaveRepeat
  26.  
  27. SpawnerDespawning

Syncro Spawner Listener Events

     
  1. EliminationWaveCompleted
  2.  
  3. ItemFailedToSpawn
  4.  
  5. ItemSpawned
  6.  
  7. WaveFinishedSpawning
  8.  
  9. WaveStart
  10.  
  11. WaveRepeat

World Variable Listener Events

     
  1. UpdateValue
 

World Variable Listener also has some fields for display logic.

     
  1. Decimal Places (number of decimal places).
  2.  
  3. Use Comma formatting.

Timed Despawner Listener Events

     
  1. Despawning

Triggered Despawner Listener Events

     
  1. Despawning

Wave Music Changer Listener Events

     
  1. MusicChanging