Game Development Reference
In-Depth Information
each alien destroyed
DisplayScore.Score+=50;
//once the bullet is destroyed,
allow the player
//to shoot again
ControlShip.canShoot=true;
}
//if bullet collides with barriers,
destroy it and a
//piece of the barrier
if(other.gameObject.tag=="BarrierBrick"){
Destroy(gameObject);
Destroy(other.gameObject);
//once the bullet is destroyed,
allow the player
//to shoot again
ControlShip.canShoot=true;
}
}
If you want to, you can improve the prototype by defining different amounts of points
for different enemy types, as it is with the original Space Invaders; you can achieve
that by adding more tags and assigning them to different enemy types.
1. The last thing we want to do with the score is to update the HiScore variable
when the match ends, whether the player or the aliens win. We can achieve
it with the following simple line of code:
//update the Hiscore
if(DisplayScore.Score>DisplayScore.HiScore){
DisplayScore.HiScore=DisplayScore.Score;
}
Search WWH ::




Custom Search