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!
Hooking Up Listeners
Hooking up Listener scripts is easy. Let's take a look at Killable Listener. To set it up:
- Select a Killable object in your Scene.
- 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.
- 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.
- Select the Killable you want to listen to in the Hierarchy.
- 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:
- Level Wave Settings: Events for Level Wave Settings
- Killable: Events for Killable
- Pool Boss: Events for Pool Boss
- Prefab Pool: Events for Prefab Pools
- Triggered Spawner: Events for Triggered Spawners
- Syncro Spawner: Events for Syncro Spawners
- World Variable: Events for World Variables. Can display / update the value on a Text component in Unity uGUI, NGUI, or TextMeshPro.
- Timed Despawner: Events for Timed Despawner
- Triggered Despawner: Events for Triggered Despawner
- Wave Music Changer: Events for Wave Music Changer
Level Settings Listener Events
- Lose (GameOver but you didn't win)
- LevelStarted (fired when the first Wave in a Level starts).
- LevelEnded (fired when the last Wave in a Level is completed).
- WaveItemsRemainingChanged (to update a display or any logic)
- WaveTimeRemainingChanged (to update a display of seconds)
LevelSettings.CurrentLevelWaveif you want to get the wave #.
- WaveCompleteBonusesStart (in case you want to modify the bonuses before they're awarded).
Killable Listener Events
- WaitingToDestroyKillable (used to play a death animation or other side effect)
- DeterminingScenario - used to change the Scenario used (which set of World Variables are going to be modified)
Pool Boss Listener Events
Prefab Pool Listener Events
Triggered Spawner Listener Events
Syncro Spawner Listener Events
World Variable Listener Events
World Variable Listener also has some fields for display logic.
- Decimal Places (number of decimal places).
- Use Comma formatting.
Timed Despawner Listener Events
Triggered Despawner Listener Events
Wave Music Changer Listener Events