using UnityEngine;
using System.Collections;

public class BlahReceiver : MonoBehaviour {

	public AudioSource rightFoot;
	public AudioSource leftFoot;
	
	
	public AudioClip stepA;
	public AudioClip stepB;
	
	public bool walking = false;
	
	public void Gblah(string yo){
		if (walking){
			if (yo == "R"){
				rightFoot.audio.volume = 0.5f;
				rightFoot.audio.pitch = Random.Range(0.9f,1f);
				
				int floorType = 0;
				Ray footRay = new Ray(rightFoot.transform.position + Vector3.up, -Vector3.up);
				RaycastHit floorHit = new RaycastHit();
				if (Physics.Raycast(footRay, out floorHit, 2f)){
					if (floorHit.collider.gameObject.layer == 10){
						floorType = 1;
					}
				}
				if (floorType == 0){
					rightFoot.PlayOneShot(stepA);
				}else{
					rightFoot.audio.volume = 2f;
					rightFoot.audio.pitch = Random.Range(1.2f,1.3f);
					rightFoot.PlayOneShot(stepB);
				}
			}else{
				leftFoot.audio.volume = 0.5f;
				leftFoot.audio.pitch = Random.Range(0.9f,1f);
				
				int floorType = 0;
				Ray footRay = new Ray(leftFoot.transform.position + Vector3.up, -Vector3.up);
				RaycastHit floorHit = new RaycastHit();
				if (Physics.Raycast(footRay, out floorHit, 2f)){
					if (floorHit.collider.gameObject.layer == 10){
						floorType = 1;
					}
				}
				if (floorType == 0){
					leftFoot.PlayOneShot(stepA);
				}else{
					leftFoot.audio.volume = 2f;
					leftFoot.audio.pitch = Random.Range(1.2f,1.3f);
					leftFoot.PlayOneShot(stepB);
				}
			}
		}
	}
	
}
