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

public class EndCollider : MonoBehaviour
{
    private PlayerMovement player;
    public bool reached;
    public Button startButton;
    public Button nextLevelButton;
    public Button retryButton;
    private TimerScript timeScript;

    // Start is called before the first frame update
    void Start()
    {
        player = FindObjectOfType<PlayerMovement>();
        timeScript = FindObjectOfType<TimerScript>();
    }

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

    private void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Player")
        {
            player.playerStarted = false;
            player.GetComponent<Rigidbody2D>().velocity = Vector2.zero;
            player.GetComponent<Animator>().SetBool("isWalking",false);
            reached = true;
            print ("you win");

            startButton.gameObject.SetActive(false);
            nextLevelButton.gameObject.SetActive(true);
            retryButton.gameObject.SetActive(true);
            timeScript.canCount = false;
        }
    }
}
