Game Development Reference
In-Depth Information
5. Now access the ControlSwarm script and add the following line inside the
Update() function:
//Display a "you won" message
DisplayGUI.GameEnd="YOU DESTROYED THE
ALIENS!";
6. This is the updated Update() function of the ControlSwarm script:
function Update () {
if(bCollide)
{
goRight=!goRight;
for(var myEnemy:GameObject in
enemyList)
{
if(myEnemy!=null)
{
myEnemy.transform.Translate(Vector3(0,-3,0));
}
}
bCollide=false;
}
//update the enemyList count
enemyList=GameObject.FindGameObjectsWithTag("Enemies");
//check when the count of aliens gets
to 0
if(enemyList.length==0)
{
//all aliens destroyed, pause
the game and display
Search WWH ::




Custom Search