Skip to content
Permalink
3a30942fd4
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
56 lines (48 sloc) 1.21 KB
using UnityEngine;
using System.Collections;
public class GameCamera : MonoBehaviour {
private Transform target;
private float maxX = 0f;
private int buttonWidth = 400;
private int buttonHeight = 100;
private bool buttonShown=false;
public int currentLevel = 0;
public int nextLevel = 0;
public OutPortal exit;
public GUIStyle gStyle;
public void setTarget(Transform t) {
target = t;
}
void OnGUI() {
if (!exit.hitP){
if(!target){
Invoke ("showButton", 1.55f);
}
if (buttonShown && !target){
if (GUI.Button (new Rect(Screen.width /2 - buttonWidth/2, Screen.height /2 - buttonHeight/2, buttonWidth, buttonHeight), "YOU HAVE DIED", gStyle)) {
Application.LoadLevel (currentLevel);
}
}
else{
buttonShown=false;
}
}
else{
if (GUI.Button (new Rect(Screen.width /2 - buttonWidth/2, Screen.height /2 - buttonHeight/2, buttonWidth, buttonHeight), "LEVEL COMPLETE", gStyle)) {
Application.LoadLevel (nextLevel);
}
}
}
void showButton(){
buttonShown=true;
}
void LateUpdate() {
if (target) {
float x = target.position.x;
if (x > maxX) {
transform.position = new Vector3(x,transform.position.y,transform.position.z);
maxX = x;
}
}
}
}