﻿using UnityEngine;
using System.Collections;

public class CandyProjectile : MonoBehaviour {

	public AudioClip hitGoodSound;

	public Player p;

	// Use this for initialization
	void Start () {
		p = GameObject.Find("Player").GetComponent<Player>();;
	}
	
	// Update is called once per frame
	void Update () {
	
	}


	void OnCollisionEnter2D(Collision2D coll) {
		if (coll.gameObject.tag == "Enemy")
		{

			audio.PlayOneShot( hitGoodSound );
			GameObject.Destroy(coll.gameObject);
			p.HitEnemy();
		
		}

		if(coll.gameObject.tag == "Floor")
		{
			GameObject.Destroy(gameObject);
		}
	}
}
