Code Cleanup: tetromino audio source
This commit is contained in:
parent
15e5bb8c04
commit
abe59f86b1
1 changed files with 12 additions and 6 deletions
|
@ -4,8 +4,14 @@ using UnityEngine.SceneManagement;
|
|||
public class tetrominoUserControl : MonoBehaviour
|
||||
{
|
||||
public GameObject activeTetromino;
|
||||
|
||||
private AudioSource audioSource;
|
||||
|
||||
// Update is called once per frame
|
||||
private void Start()
|
||||
{
|
||||
audioSource = GetComponent<AudioSource>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetButtonDown("tetrisMoveLeft") && activeTetromino != null)
|
||||
|
@ -13,7 +19,7 @@ public class tetrominoUserControl : MonoBehaviour
|
|||
if (!checkMoveCollisions(Vector2.left))
|
||||
{
|
||||
activeTetromino.gameObject.transform.position += Vector3.left * 1.0f;
|
||||
GetComponent<AudioSource>().Play();
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +28,7 @@ public class tetrominoUserControl : MonoBehaviour
|
|||
if (!checkMoveCollisions(Vector2.right))
|
||||
{
|
||||
activeTetromino.gameObject.transform.position += Vector3.right * 1.0f;
|
||||
GetComponent<AudioSource>().Play();
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,20 +37,20 @@ public class tetrominoUserControl : MonoBehaviour
|
|||
if (!checkMoveCollisions(Vector2.down))
|
||||
{
|
||||
activeTetromino.gameObject.transform.position += Vector3.down * 1.0f;
|
||||
GetComponent<AudioSource>().Play();
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
if (Input.GetButtonDown("tetrisRotateLeft") && activeTetromino != null)
|
||||
{
|
||||
checkRotateCollisions(90);
|
||||
GetComponent<AudioSource>().Play();
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
if (Input.GetButtonDown("tetrisRotateRight") && activeTetromino != null)
|
||||
{
|
||||
checkRotateCollisions(90);
|
||||
GetComponent<AudioSource>().Play();
|
||||
audioSource.Play();
|
||||
}
|
||||
|
||||
if (Input.GetButtonDown("Quit"))
|
||||
|
|
Loading…
Reference in a new issue