We now want to make it so that when we collect all of the orbs in the level, the goal will appear, and then you will win the game when you touch it:
Go back into
MonoDevelop
, and select theGameController
class. Once there, add the following variables:public static GameController _instance; private int orbsCollected; private int orbsTotal;
As normal, we will need to set these variables as well in the
Start
function after theBuildLevel
function call, otherwise theOrb
objects will not exist:GameObject[] orbs; orbs = GameObject.FindGameObjectsWithTag("Orb"); orbsCollected = 0; orbsTotal = orbs.Length;
We will also want to initialize the
_instance
variable, but instead of usingStart
, we will useAwake
, as follows:void Awake...