Created
February 1, 2016 03:04
-
-
Save victor-vargas2009/95c216c279f7bb3713c7 to your computer and use it in GitHub Desktop.
Block Breaker
This file contains hidden or 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 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