Skip to content

Commit

Permalink
Proper game over
Browse files Browse the repository at this point in the history
  • Loading branch information
AJLange committed Jul 11, 2014
1 parent 90cd3b2 commit eb0f455
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
10 changes: 8 additions & 2 deletions DeathScript.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using UnityEngine;
using System.Collections;

public class DeathScript : MonoBehaviour {


public class DeathScript : MonoBehaviour {
public string scene;
// Use this for initialization
void Start () {

Expand All @@ -16,7 +18,7 @@ void Update () {
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player") {
Debug.Break ();
EndGame();
return;
}

Expand All @@ -29,4 +31,8 @@ void OnTriggerEnter2D(Collider2D other)
Destroy (other.gameObject);
}
}

void EndGame(){
Application.LoadLevel (scene);
}
}
7 changes: 6 additions & 1 deletion HillScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class HillScript : MonoBehaviour {

public Vector2 speed = new Vector2(5, 0);
private Vector2 movement;
public string scene;

// Use this for initialization
void Start () {
Expand All @@ -28,7 +29,7 @@ void FixedUpdate () {
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player") {
Debug.Break ();
EndGame();
return;
}

Expand All @@ -37,5 +38,9 @@ void OnTriggerEnter2D(Collider2D other)
} else
return;
}

void EndGame(){
Application.LoadLevel (scene);
}
}

7 changes: 6 additions & 1 deletion KillPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class KillPlayer : MonoBehaviour {

public Vector2 speed = new Vector2(5, 0);
private Vector2 movement;
public string scene;

// Use this for initialization
void Start () {
Expand All @@ -28,7 +29,7 @@ void FixedUpdate () {
void OnTriggerEnter2D(Collider2D other)
{
if (other.tag == "Player") {
Debug.Break ();
EndGame();
return;
}

Expand All @@ -37,5 +38,9 @@ void OnTriggerEnter2D(Collider2D other)
Destroy (gameObject);
}
}

void EndGame(){
Application.LoadLevel (scene);
}
}

0 comments on commit eb0f455

Please sign in to comment.