GameController Code
private var Level : int;
var Player : GameObject;
static var totalEnemies : int;
static var Lives : int = 3;
var powerupprefab : GameObject;
static var powerup : GameObject ;
static var GameOver : boolean;
static var isWin : boolean;
// for the boss crabturret
static var crabturret : int;
var enemies : GameObject[];
var guiSkin : GUISkin;
private var SpawnGrid;
function Awake(){
Lives = 3;
GameOver = false;
powerup = powerupprefab;
totalEnemies = 1;
isWin = false;
crabturret = 1;
DontDestroyOnLoad(this);
SpawnGrid = new Array();
SpawnGrid[0] = new Array(Vector3(-27,114,15), Vector3(-29,114,15) , Vector3(-31,114,15) , Vector3(-33,114,15) );
SpawnGrid[1] = new Array(Vector3(-27,114,13), Vector3(-29,114,13) , Vector3(-31,114,13) , Vector3(-33,114,13) );
SpawnGrid[2] = new Array(Vector3(-27,114,11), Vector3(-29,114,11) , Vector3(-31,114,11) , Vector3(-33,114,11) );
SpawnGrid[3] = new Array(Vector3(-27,114,9), Vector3(-29,114,9) , Vector3(-31,114,9) , Vector3(-33,114,9) );
Instantiate(Player, Vector3(-43, 114, 4.5), Quaternion.Euler(0,180,0));
}
function Update () {
if (totalEnemies == 0){
isWin = true;
//levelEnd();
}
}
function levelEnd(){
Level += 1;
if (Level == 1){
isWin = true;
yield WaitForSeconds(1);
}
}
function Respawn(){
yield WaitForSeconds(1);
Instantiate(Player, Vector3(-43, 114, 4.5), Quaternion.Euler(0, -180,0));
}
function OnGUI()
{
GUI.skin = guiSkin;
if (GameOver == true){
if (GUI.Button ( Rect ( Screen.width / 2 -140, 100, 300, 100), "Restart" ))
{
Application.LoadLevel(0);
}
}
if (isWin)
{
GUI.Label (Rect ( Screen.width / 2 -140, 100, 300, 100), "You Win" );
Application.LoadLevel("sh_l1"); //sky hawks test level
}
}