using UnityEngine;
using System.Collections;

public class ActionManager : MonoBehaviour {
	GetHit getHit;
	CarScript carScript;
	public float fGiroStrenght = 200;

	public AudioSource derrapeSnd;

	// Use this for initialization
	void Start () 
	{
		getHit = GameObject.Find("Squirrel").GetComponentInChildren<GetHit>();
		carScript = GameObject.Find("Coche").GetComponent<CarScript>();


	}
	
	// Update is called once per frame
	void Update () {
	
	}	
	void OnTriggerEnter (Collider other) 
	{
		if (other.tag == "Car")
		{
			//print ("Action!");

			derrapeSnd.Play();

			if(Input.GetAxis("SquirrelHorizontal") != 0)
			{
				getHit.Jump(Input.GetAxis("SquirrelHorizontal"));
			}else if(Input.GetAxis("SquirrelHorizontal") == 0)
			{
				//dejar la explosion de la Ardilla donde esta
			}

			if(Input.GetAxis("CarHorizontal") != 0)
			{
				//girar el coche a la izq
				carScript.fRotationY = -Input.GetAxis("CarHorizontal")*fGiroStrenght-100;

			}else if(Input.GetAxis("CarHorizontal") == 0)
			{
				//dejar al coche seguir con su ruta
//				carScript.fRotationY = -Input.GetAxis("CarHorizontal")*fGiroStrenght;
			}

		}
	}
}
