
Untitled
By: a guest on
Apr 5th, 2012 | syntax:
None | size: 0.99 KB | hits: 32 | expires: Never
var gameTime : float = 60;
var scoreHC : int = 0;
var lives : int = 1;
function Start() {
InvokeRepeating ("Countdown", 1.0, 1.0);
}
function Update () {
if(lives <= 0) {
Application.LoadLevel("Lose");
lives = 1;
gameTime = 60;
PlayerPrefs.SetInt("SCOREHC", scoreHC);
scoreHC = 0;
}
if(gameTime <= 0) {
Application.LoadLevel("win");
lives = 1;
gameTime = 60;
PlayerPrefs.SetInt("SCOREHC", scoreHC);
scoreHC = 0;
}
print("Score: " + scoreHC);
}
function AddScoreHC() {
scoreHC += 1;
}
function LoseLife() {
lives -= 1;
}
function AddLife() {
lives += 1;
}
function Countdown() {
if(--gameTime == 0) {
CancelInvoke("Countdown");
}
}
function OnGUI () {
GUI.Label(Rect(10, 10, 100, 20), "Score: " + scoreHC);
GUI.Label(Rect(10, 25, 100, 25), "Lives left: " + lives);
GUI.Label(Rect(Screen.width - 100, 10, 100, 50), "Time left: " + gameTime);
}