diff --git a/Freeway/Assets/Audio.cs b/Freeway/Assets/Audio.cs new file mode 100644 index 0000000..4e9c350 --- /dev/null +++ b/Freeway/Assets/Audio.cs @@ -0,0 +1,30 @@ +using UnityEngine.Audio; +using System; +using UnityEngine; + +public class Audio : MonoBehaviour +{ + public Sound[] sounds; + + // Use this for initialization + void Awake () { + + foreach (Sound s in sounds) + { + s.source = gameObject.AddComponent(); + s.source.clip = s.clip; + + s.source.volume = s.volume; + s.source.pitch = s.pitch; + + } + + } + + public void Play(string name) + { + Sound s = Array.Find(sounds, sound => sound.name == name); + s.source.Play(); + } + +} \ No newline at end of file diff --git a/Freeway/Assets/Audio.cs.meta b/Freeway/Assets/Audio.cs.meta new file mode 100644 index 0000000..441bede --- /dev/null +++ b/Freeway/Assets/Audio.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 864726633d557cf40a327461b02d0c4a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Freeway/Assets/Chicken1.cs b/Freeway/Assets/Chicken1.cs index cb83023..78f5751 100644 --- a/Freeway/Assets/Chicken1.cs +++ b/Freeway/Assets/Chicken1.cs @@ -9,8 +9,7 @@ public class Chicken1 : MonoBehaviour public float speed; public Text countText1; - private int count1; - private int y; + public int count1; // Use this for initialization void Start() @@ -37,7 +36,9 @@ void OnCollisionEnter2D(Collision2D collisionInfo) } if (collisionInfo.gameObject.tag == "Car") { - transform.position = new Vector2(4.15f, -7.15f); + transform.position = new Vector2(-4.15f, -5.765f); + FindObjectOfType