using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Goal : MonoBehaviour
{
    public GameManager gm;
    public int playerNumber = 0;

    public GoalLight goalLight;
    // Start is called before the first frame update
    void Start()
    {
        this.gm = GameObject.FindGameObjectWithTag("GameManager").GetComponent<GameManager>();   
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.transform.tag == "Ball")
        {
            if (this.playerNumber == 1)
            {
                this.gm.scorePlayer2 += 1;
            }
            if (this.playerNumber == 2)
            {
                this.gm.scorePlayer1 += 1;
            }

            this.goalLight.LightUp();

            this.gm.ResetPositions();
        }
    }
}
