Skip to content

Commit

Permalink
added background music to Project1
Browse files Browse the repository at this point in the history
  • Loading branch information
robertoguazon committed Oct 24, 2016
1 parent 4bd9ad9 commit f64dccc
Show file tree
Hide file tree
Showing 27 changed files with 78 additions and 12 deletions.
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Project1_Borais-Francisco-Mabasa-Guazon/Assets/scenes/Menu.unity
Binary file not shown.
42 changes: 31 additions & 11 deletions Project1_Borais-Francisco-Mabasa-Guazon/Assets/scripts/Audio.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@

public class Audio : MonoBehaviour {

[SerializeField]
private AudioClip backgroundMusic;
[SerializeField]
private AudioClip dropChipSound;
[SerializeField]
private AudioClip pressButtonSound;
[SerializeField]

private static AudioSource _audioSource;
private static Audio _instance = null;
private static AudioSource _soundEffectsSource;
private static AudioSource _backgroundMusicSource;

private static AudioClip _backgroundMusic;
private static AudioClip _dropChipSound;
private static AudioClip _pressButtonSound;

private static Audio _instance = null;

void Awake() {
if (_instance == null) {

Expand All @@ -30,27 +37,40 @@ void Awake() {

// Use this for initialization
void Start () {

_audioSource = GetComponent<AudioSource>();
Debug.Log("Audio Source: " + _audioSource);
_soundEffectsSource = gameObject.AddComponent<AudioSource>();
_backgroundMusicSource = gameObject.AddComponent<AudioSource>();
Debug.Log("Audio Source: " + _soundEffectsSource);

_dropChipSound = dropChipSound;
_pressButtonSound = pressButtonSound;
_backgroundMusic = backgroundMusic;

_backgroundMusicSource.loop = true;
_backgroundMusicSource.volume = 0.5f;
PlayBackgroundMusic(); // start playing
}

public static void PlayDropChip() {
Debug.Log("Drop chip sound: " + _dropChipSound);
if (_audioSource.clip != _dropChipSound) {
_audioSource.clip = _dropChipSound;
if (_soundEffectsSource.clip != _dropChipSound) {
_soundEffectsSource.clip = _dropChipSound;
}
_audioSource.Play();
_soundEffectsSource.Play();
}

public static void PlayPressButton() {
if (_audioSource.clip != _pressButtonSound)
if (_soundEffectsSource.clip != _pressButtonSound)
{
_audioSource.clip = _pressButtonSound;
_soundEffectsSource.clip = _pressButtonSound;
}
_soundEffectsSource.Play();
}

public static void PlayBackgroundMusic() {
if (_backgroundMusicSource.clip != _backgroundMusic) {
_backgroundMusicSource.clip = _backgroundMusic;
}
_audioSource.Play();

_backgroundMusicSource.Play();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;
using System.Collections;

public class MenuController : MonoBehaviour {

// Use this for initialization
void Start () {

}

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Project1_Borais-Francisco-Mabasa-Guazon/Library/CurrentLayout.dwlt
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Project1_Borais-Francisco-Mabasa-Guazon/Library/assetDatabase3
Binary file not shown.
Binary file modified Project1_Borais-Francisco-Mabasa-Guazon/Library/expandedItems
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<Compile Include="Assets\scripts\Checker.cs" />
<Compile Include="Assets\scripts\GameController.cs" />
<Compile Include="Assets\scripts\Grid.cs" />
<Compile Include="Assets\scripts\MenuController.cs" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\SyntaxTree\UnityVS\2015\UnityVS.CSharp.targets" />
</Project>

0 comments on commit f64dccc

Please sign in to comment.