Skip to content

Commit

Permalink
Add various sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusChrist committed Jun 15, 2018
1 parent 7bab644 commit 86250ff
Show file tree
Hide file tree
Showing 11 changed files with 154 additions and 39 deletions.
Binary file added Assets/Resources/crash.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions Assets/Resources/crash.mp3.meta

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

Binary file added Assets/Resources/explosion1.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions Assets/Resources/explosion1.mp3.meta

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

Binary file added Assets/Resources/explosion3.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions Assets/Resources/explosion3.mp3.meta

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

Binary file added Assets/Resources/takeOff.mp3
Binary file not shown.
22 changes: 22 additions & 0 deletions Assets/Resources/takeOff.mp3.meta

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

43 changes: 28 additions & 15 deletions Assets/Scripts/EarthDefender/Backend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@
using System.Collections.Generic;
using UnityEngine;

public class Backend : MonoBehaviour {

public class Backend : MonoBehaviour {



public AudioSource source;
public AudioClip bgMusic;
public AudioClip takeOffSound;
public AudioClip explosionSound;
public AudioClip gameOverSound;

public int Score { get; private set; }
Expand Down Expand Up @@ -53,7 +57,8 @@ public static Vector3 getEarthPos()


// Use this for initialization
void Awake () {
void Awake () {

//source.Play((AudioClip)Resources.Load("bgMusic"));

// Init values
Expand All @@ -78,14 +83,13 @@ void Awake () {
_instance = this;

source.clip = bgMusic;
source.Play();
}





// Update is called once per frame
source.Play();

}


// Update is called once per frame

void Update () {

ShowScore();
Expand All @@ -112,11 +116,20 @@ void Update () {
}

gameFinished = true;
source.Stop();
source.clip = null;
//source.PlayOneShot((AudioClip)Resources.Load("gameOver"));
source.clip = gameOverSound;
source.Stop();

source.clip = null;

//source.PlayOneShot((AudioClip)Resources.Load("gameOver"));

source.clip = takeOffSound;
source.Play();

source.clip = explosionSound;
source.Play();

//source.clip = gameOverSound;
//source.Play();
}


Expand Down
57 changes: 33 additions & 24 deletions Assets/Scripts/EarthDefender/Earth.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Earth : MonoBehaviour {

public RedFlickerEffect flicker;

// Use this for initialization
void Start () {

Backend.SetEarth(this);

}

private void OnTriggerEnter(Collider other)
{
Backend.EarthHit();
Destroy(other.gameObject);
flicker.StartFlicker();
}


}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Earth : MonoBehaviour {

public AudioSource source;
public AudioClip takeOffSound;
public AudioClip explosionSound;

public RedFlickerEffect flicker;

// Use this for initialization
void Start () {

Backend.SetEarth(this);

}

private void OnTriggerEnter(Collider other)
{
Backend.EarthHit();
Destroy(other.gameObject);
flicker.StartFlicker();

source.clip = takeOffSound;
source.Play();
source.clip = explosionSound;
source.Play();
}


}
5 changes: 5 additions & 0 deletions Assets/Scripts/EarthDefender/Meteor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

public class Meteor : MonoBehaviour {

public AudioSource source;
public AudioClip explosionSound;

[SerializeField]
private GameObject explosion;

Expand Down Expand Up @@ -32,6 +35,8 @@ public void OnClick()

if(Robustness <= 0)
{
source.clip = explosionSound;
source.Play();
Backend.DestroyMeteor(this);
}
}
Expand Down

0 comments on commit 86250ff

Please sign in to comment.