Skip to content
Permalink
a3a487b560
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
78 lines (70 sloc) 2.66 KB
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class Brick : MonoBehaviour
{
public GameObject GameMaster;
public Score scoreScript;
Text score;
public static int scoreValue;
public AudioSource source;
public AudioClip beep;
void Awake()
{
score = GetComponent<Text>();
scoreValue = 0;
// source = GetComponent<AudioSource>();
}
void OnCollisionEnter(Collision other)
{
gameObject.AddComponent<AudioSource>();
gameObject.GetComponent<AudioSource>().clip = beep;
gameObject.GetComponent<AudioSource>().Play();
Destroy(gameObject);
scoreValue = scoreValue + 1;
}
void Update()
{
score.text = "Score: " + scoreValue;
if (scoreValue == 8)
{
Application.LoadLevel(2);
}
//switch(scoreValue)
//{
// case 1:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play();
// break;
// case 2:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play(); break;
// case 3:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play(); break;
// case 4:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play(); break;
// case 5:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play(); break;
// case 6:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play(); break;
// case 7:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play(); break;
// case 8:
// gameObject.AddComponent<AudioSource>();
// gameObject.GetComponent<AudioSource>().clip = beep;
// gameObject.GetComponent<AudioSource>().Play(); break;
//}
}
}