Game Development Reference
In-Depth Information
Let's inform the
ScoreWatcher
script to pay attention to the
bossDied
event.
Open up
ScoreWatcher
and add an event listener to
OnEnable
:
BossEventController.bossDied += addScore;
And, of course, be sure to unregister the event in
OnDisable
:
BossEventController.bossDied -= addScore;
Now, you can earn points whenever the boss gets killed.
Add an extra event to allow the player to earn points
whenever the boss takes damage.
Next, you will notice that we use a bunch of nodes. These nodes are simple—the
term node is used here to refer to anything that is locational. A node is nothing more
than a GameObject that contains nothing more than a
Transform
section, as shown
in the following screenshot:
You may have noticed that anywhere we define these nodes in the
code, we always define a full GameObject, and from there, we access
it with
nodeGameObject.transform.position
. Well, that's not
entirely needed! You may already know this, but Unity allows you
to set a property in the
Inspector
panel with a component on another
object! This means you could actually define the nodes as
Transform
thisNode;
instead of
GameObject thisNode;
. If you challenge
yourself to modify the code like this, then you can access a node's
position by simply using
thisNode.position
. Handy!