using UnityEngine;
using System.Collections;

public class Goal : MonoBehaviour
{
    public int teamIndex;

    ParticleSystem goalBlast;

	// Use this for initialization
	void Start ()
    {
        goalBlast = transform.Find("GoalBlast").GetComponent<ParticleSystem>();
	}
	
	// Update is called once per frame
	void Update () {
	
	}

    void OnTriggerEnter(Collider other)
    {
        if(other.tag == "Ball")
        {
            Ball.instance.EnteredGoal();
            goalBlast.Play();
            if (teamIndex == 0)
            {
                Scoreboard.instance.AddRed();
                Scoreboard.instance.RemoveBlue();
            }
            else
            {
                Scoreboard.instance.RemoveRed();
                Scoreboard.instance.AddBlue();
            }

            //Time.timeScale = 0.9f;
        }
    }
}
