vjanomolee

ScriptSceneManager

Dec 7th, 2011
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Scene Manager Script
  2. var gameTime            = 30;
  3. static var score        = 0;
  4. static var lives        = 3;
  5. static var missleMode   =false;
  6. var ObjectsToSpawn : Transform[];
  7. var SpawnInterval   : float= 15;
  8. var MaxObjectsSpawned : int= 3;
  9. var MinObjectsSpawned : int= 1;
  10. var minimum : Vector3 ;
  11. var maximum : Vector3;
  12. var center  : Vector3;
  13.  
  14. private var _NextSpawn : float;
  15.  
  16. function Start ()
  17. { InvokeRepeating ("CountDown", 1.0,1.0); }
  18. { _NextSpawn == Time.time + SpawnInterval }
  19.  
  20. //Game Loop
  21. function Update ()
  22. {
  23.     if(lives <= 0)
  24.     { Application.LoadLevel("Screen_Lose");
  25.          lives = 3;
  26.          PlayerPrefs.SetInt ("SCORE", score);
  27.           score = 0; }
  28.    
  29.        
  30.         if(gameTime <= 0)
  31.         { Application.LoadLevel("Screen_Win");
  32.           lives = 3;
  33.           PlayerPrefs.SetInt ("SCORE", score);
  34.           score = 0; }
  35.        
  36.        
  37.         if(Time.time >= _NextSpawn)
  38.         { int objectsToSpawn = Random.Range(MinObjectsSpawned, MaxObjectsSpawned);
  39.         for(int i < 0; i < objectsToSpawn; ++i)
  40.         { Instantiate(ObjectsToSpawn(Random.Range(0, ObjectsToSpawn.Length), transform.position. Quaternion.identity); } _NextSpawn = Time.time + SpawnInterval; }
  41.        
  42.    
  43. }
  44. //Increase the Score when the player shoots an astroid
  45. function AddScore ()
  46. { score +=1; }
  47.  
  48. //Subtract a life when the player collides with an asteroid
  49. function SubtractLife ()
  50. { lives -=1; }
  51.  
  52. //Subtract a life when the player collides with an asteroid
  53. function AddLife ()
  54. { lives +=1; }
  55.  
  56. //Subtract a life when the player collides with an asteroid
  57. function LoadMissiles ()
  58. { missleMode=true; }
  59.  
  60. // Subtract one from the game timer every second
  61. function CountDown ()
  62. { if(--gameTime == 0)
  63.     { CancelInvoke ("CountDown"); } }
  64.  
  65. //Create and Display the HUD information for the player
  66. function OnGUI ()
  67. { GUI.Label (Rect (10,10,100,20), "Score: " +score);
  68.   GUI.Label (Rect (10,25,100,35), "Lives: " +lives);
  69.   GUI.Label (Rect (10,50,100,20), "Time left: " +gameTime); }
  70.  
  71.  
Advertisement
Add Comment
Please, Sign In to add comment