Skip to content

Instantly share code, notes, and snippets.

@victor-vargas2009
Created February 1, 2016 03:04
Show Gist options
  • Save victor-vargas2009/95c216c279f7bb3713c7 to your computer and use it in GitHub Desktop.
Save victor-vargas2009/95c216c279f7bb3713c7 to your computer and use it in GitHub Desktop.
Block Breaker
using UnityEngine;
using System.Collections;
public class LoseCollider : MonoBehaviour {
public static int playerLives = 2;
private LevelManager lvlManager;
private LivesTextIndicatorUI uiLivesIndicator;
private Ball ball;
void Start(){
ball = GameObject.FindObjectOfType<Ball>();
lvlManager = GameObject.FindObjectOfType<LevelManager>();
uiLivesIndicator = GameObject.FindObjectOfType<LivesTextIndicatorUI>();
}
void OnTriggerEnter2D(Collider2D trigger){
didPlayerLose();
}
void didPlayerLose(){
LoseCollider.playerLives--;
if(LoseCollider.playerLives<=0){
LoseCollider.playerLives = 0;
lvlManager.LoadLevel("Lose");
}else{
uiLivesIndicator.UpdateLivesText();
ball.resetGame();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment