05 Missile Command

This example scene is located in Assets/Plugins/Weaver/Examples/05 Missile Command. It brings all the previous examples together in a simple game which also uses Pref Injection and Lazy Asset Injection.

  • Building is a partial class which is split into multiple files. The file in this example contains the code to destroy the buildings when they are hit at runtime while the procedural asset generation code for the Building example is located over in that folder because it isn't relevant to this example.
  • GameOverScreen uses Lazy Asset Injection to get a reference to its prefab. Instead of having a GameOverScreen field to get a direct reference, it has a Weaver.Asset<GameOverScreen> so Weaver will inject the prefab's resource path, meaning that at runtime the prefab doesn't get loaded into memory until it is actually used.
  • MissileLauncher allows the player to aim with the mouse cursor and click to fire Missiles.
  • Score uses a UI Text component to display the current value and an injected ObjectPool<FloatingText> to indicate when the value is changed.
    • It also uses [Pref] Injection to automatically save the high score value in PlayerPrefs.