using UnityEngine;
using System.Collections;

public class AguaComportamento : MonoBehaviour {

	public GameObject boia;
	public AudioSource boiaUp;
	public AudioSource waterSplash;
	public GameObject wave;
	private Rigidbody2D rb;

	void Start(){
		rb = boia.GetComponent<Rigidbody2D> ();
	}

	void OnTriggerEnter2D(Collider2D c){
		if(c.name.Contains("Pedra")){
			wave.transform.position = new Vector3 (-1,wave.transform.position.y,wave.transform.position.z);
			rb.AddForce(new Vector2(0,1300));
			boiaUp.Play ();
			waterSplash.Play ();
			c.GetComponent<Rigidbody2D> ().gravityScale = 1;
			c.GetComponent<Rigidbody2D> ().velocity=Vector2.zero;
		}

	}
	void OnTriggerExit2D(Collider2D c){
		if(c.name=="Boia"){
			PlayerStat.instance.boiaSaiu = true;
			PlayerStat.instance.invencible = false;
		}
	}
}
