using UnityEngine;
using System.Collections;

public class KnifeHit : MonoBehaviour {

    public GameObject Boom;

    void OnCollisionEnter(Collision Col)
    {
        if (Col.gameObject.tag == "Ground")
        {
            GameObject.FindGameObjectWithTag("ThrowSFX").GetComponent<AudioSource>().Stop();
            Destroy(gameObject);
        }
        else if (Col.gameObject.tag == "Sheep")
        {
            GameObject.FindGameObjectWithTag("ExplosionSFX").GetComponent<AudioSource>().Play();
            GameObject.FindGameObjectWithTag("SheepRunSFX").GetComponent<AudioSource>().Stop();
            GameObject.FindGameObjectWithTag("ButcherRunningSFX").GetComponent<AudioSource>().Stop();

            Instantiate(Boom,Col.contacts[0].point,Quaternion.identity);
            GameObject.FindGameObjectWithTag("Butcher").GetComponent<ShootKnife>().enabled = false;
            GameObject.FindGameObjectWithTag("Butcher").GetComponent<GameStatus>().TimeSurvived = Time.timeSinceLevelLoad;
            foreach (GameObject G in GameObject.FindGameObjectsWithTag("Ground"))
            {
                G.GetComponent<MovePlatform>().enabled = false;
            }
            foreach (GameObject G in GameObject.FindGameObjectsWithTag("Building"))
            {
                G.GetComponent<MoveBuildings>().enabled = false;
            }

            Destroy(Col.gameObject);
            GameObject.FindGameObjectWithTag("ThrowSFX").GetComponent<AudioSource>().Stop();
        }
    }
}
