31 lines
971 B
C#
31 lines
971 B
C#
using UnityEngine;
|
|
|
|
public class Goal : MonoBehaviour
|
|
{
|
|
public Team team;
|
|
void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if(collision.gameObject.CompareTag("Player")){
|
|
Debug.Log($"GOAL! {team.ToString()}", gameObject);
|
|
Ball ball = collision.gameObject.GetComponent<Ball>();
|
|
Debug.Log(ball.name);
|
|
GameManager.instance.OnGoal(team);
|
|
}else if(collision.gameObject.CompareTag("Puck")){
|
|
Debug.Log("Puck goal", gameObject);
|
|
Puck puck = collision.gameObject.GetComponent<Puck>();
|
|
Debug.Log(puck.name);
|
|
puck.ScheduleReset();
|
|
}
|
|
}
|
|
|
|
void OnTriggerExit2D(Collider2D collision)
|
|
{
|
|
if(collision.gameObject.CompareTag("Puck")){
|
|
Debug.Log("Puck exit goal", gameObject);
|
|
Puck puck = collision.gameObject.GetComponent<Puck>();
|
|
Debug.Log(puck.name);
|
|
puck.UnscheduleReset();
|
|
}
|
|
}
|
|
}
|