Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Scene Manager Script
- var gameTime = 30;
- static var score = 0;
- static var lives = 3;
- static var missleMode =false;
- var ObjectsToSpawn : Transform[] ;
- var SpawnInterval : float= 15;
- var MaxObjectsSpawned : float= 3;
- var MinObjectsSpawned : float= 1;
- private var _NextSpawn : float=1;
- function Start ()
- { InvokeRepeating ("CountDown", 1.0,1.0); }
- { _NextSpawn = Time.time + SpawnInterval; }
- //Game Loop
- function Update ()
- {
- {
- if(lives <= 0)
- { Application.LoadLevel("Screen_Lose");
- lives = 3;
- PlayerPrefs.SetInt ("SCORE", score);
- score = 0; }
- if(gameTime <= 0)
- { Application.LoadLevel("Screen_Win");
- lives = 3;
- PlayerPrefs.SetInt ("SCORE", score);
- score = 0; }
- if(Time.time >= _NextSpawn)
- { int objectsToSpawn = Random.Range(MinObjectsSpawned, MaxObjectsSpawned);
- for(int i < 0; i < objectsToSpawn; ++i)
- { Instantiate(ObjectsToSpawn(Random.Range(0, ObjectsToSpawn.Length), transform.position. Quaternion.identity); } _NextSpawn = Time.time + SpawnInterval; }
- }
- }
- //Increase the Score when the player shoots an astroid
- function AddScore ()
- { score +=1; }
- //Subtract a life when the player collides with an asteroid
- function SubtractLife ()
- { lives -=1; }
- //Subtract a life when the player collides with an asteroid
- function AddLife ()
- { lives +=1; }
- //Subtract a life when the player collides with an asteroid
- function LoadMissiles ()
- { missleMode=true; }
- // Subtract one from the game timer every second
- function CountDown ()
- { if(--gameTime == 0)
- { CancelInvoke ("CountDown"); } }
- //Create and Display the HUD information for the player
- function OnGUI ()
- { GUI.Label (Rect (10,10,100,20), "Score: " +score);
- GUI.Label (Rect (10,25,100,35), "Lives: " +lives);
- GUI.Label (Rect (10,50,100,20), "Time left: " +gameTime); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement