Advertisement
Guest User

Moose's Code

a guest
Aug 23rd, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class Brick : MonoBehaviour {
  5.  
  6.     public int maxHits;
  7.     public int blockValue ;
  8.     private int hitCount ;
  9.     private LevelManager levelManager ;
  10.  
  11.     void Start () {
  12.         hitCount = 0 ;
  13.         levelManager = GameObject.FindObjectOfType<LevelManager>() ;
  14.     }
  15.  
  16.     // Update is called once per frame
  17.     void Update () {
  18.    
  19.     }
  20.    
  21.     void OnCollisionEnter2D (Collision2D collision) {
  22.         hitCount++ ;
  23.        
  24.         if (hitCount >= maxHits) {
  25.             Destroy(gameObject) ;
  26.         }
  27.        
  28.         //print ("Brick Hit") ;
  29.         //SimulateWin() ;
  30.     }
  31.    
  32.     // TODO Remove this method once we can actually win.
  33.     void SimulateWin() {
  34.         levelManager.LoadNextLevel();
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement