Permalink
Cannot retrieve contributors at this time
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?
SpaceKitten/Assets/Scripts/GameCamera.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
56 lines (48 sloc)
1.21 KB
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
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; | |
} | |
} | |
} | |
} |