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

public class LevelSettings : MonoBehaviour
{
    public Config.RayColor[] GoalColors = new Config.RayColor[1];
    public int LevelNumber = 1;

    IEnumerator Start()
    {
        print("Starting level " + LevelNumber + "...");

        GameController.Instance.GoalOn.transform.parent.gameObject.SetActive(true);
        GameController.Instance.SetGoalMode(false, GoalColors[0]);
        GameController.Instance.UpdateGemColors();

        //Show level number for 2 seconds
        GameController.Instance.levelText.gameObject.SetActive(true);
        yield return GameController.Instance.levelText.StartCoroutine(GameController.Instance.ShowText("Level " + LevelNumber, 2));

        yield return null;

        while (true)
        {
            GameController.Instance.rayShooter.AllowShoot = true;
            while (GameController.Instance.rayShooter.AllowShoot)
                yield return null;

            yield return new WaitForSeconds(1);
        }
    }

    void OnDestroy()
    {
        try
        {
            GameController.Instance.GoalOn.transform.parent.gameObject.SetActive(false);
        }
        catch { }
    }
}
