Advertisement
Guest User

Untitled

a guest
Mar 10th, 2012
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. private var spawnTime : float;
  2. var godDelay : float;
  3. var explosion : GameObject;
  4. var explosionSound : GameObject;
  5.  
  6. function Awake () {
  7. spawnTime = Time.time;
  8. }
  9.  
  10. function OnTriggerEnter (col : Collider) {
  11. if (( (col.gameObject.tag == "EnemyProjectile") || (col.gameObject.tag == "Enemy")) && (Time.time > spawnTime + godDelay)) {
  12. Instantiate(explosion, transform.position, transform.rotation);
  13. Instantiate(explosionSound, transform.position, transform.rotation);
  14. GameController.lives -= 1;
  15. if (GameController.lives > 0) {
  16. gameObject.Find("GameController").GetComponent(GameController).Respawn();
  17. } else {
  18. GameController.gameOver = true;
  19. }
  20. if (col.gameObject.tag == "Enemy") {
  21. GameController.totalEnemies -= 1;
  22. }
  23. Destroy(col.gameObject);
  24. Destroy(gameObject);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement