Created
July 31, 2014 06:24
-
-
Save csclyde/cd1e158b80975a67b771 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma strict | |
public var fadeOutTexture : Texture2D; | |
var fadeOutRate : float = 0.3; | |
private var alpha = 0.0; | |
var delayTimer = 0.00; | |
static var gameOver = false; | |
var deathText : GUIText; | |
function Start () { | |
} | |
function Update () { | |
//if the player touches water, kill them | |
//if the players torch goes out, kill them | |
if(Torch.torchIntensity <= 0) { | |
gameOver = true; | |
delayTimer = Time.time + 3.00; | |
} | |
} | |
function OnGUI(){ | |
if(gameOver) { | |
alpha += fadeOutRate * Time.deltaTime; | |
alpha = Mathf.Clamp01(alpha); | |
GUI.color.a = alpha; | |
GUI.depth = -1000; | |
GUI.DrawTexture(Rect(0, 0, Screen.width, Screen.height), fadeOutTexture); | |
if(alpha >= 1 && Time.time > delayTimer) { | |
gameOver = false; | |
Checkpoints.GoToCurrentCheckpoint(); | |
Torch.torchIntensity = 300; | |
alpha = 0.0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment