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


public class GoalsScript : MonoBehaviour
{
    public GameObject TextWin;
    public LevelLoader levelLoader;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))
        {
            TextWin.SetActive(true);
            //Scene Transition to next level
            GameObject.Find("Wizard").GetComponent<WizardMovement>().moveSpeed = -0.1f;
            GameObject.Find("Map").GetComponent<PlatformMove>().speed = -0.1f;
            GameObject.Find("MagicBook").GetComponent<BookFlying>().flyingSpeed = -0.1f;

            StartCoroutine(ENDGAME());
            
        }
    }

    IEnumerator ENDGAME(){
        yield return new WaitForSeconds(3);
        // Time.timeScale = 1;
        levelLoader.NextLevel();
    }

    
}
