﻿using FlipFall.Audio;
using FlipFall.Levels;
using FlipFall.Progress;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;

/// <summary>
/// Manages all UI Elements of the respective scene
/// </summary>

namespace FlipFall.UI
{
    public class UICreditsManager : MonoBehaviour
    {
        //public enum UIState { levelSelection, home, settings, game, title, shop, editor, credits, buyPro }
        //public static UIState uiState;
        public static UICreditsManager _instance;

        public Animator animator;
        public GameObject credits;

        private void Start()
        {
            if (_instance != null && _instance != this)
            {
                Destroy(this.gameObject);
                return;
            }
            _instance = this;

            animator.SetTrigger("fadein");

            Main.onSceneChange.AddListener(SceneChanging);
        }

        private void SceneChanging(Main.ActiveScene scene)
        {
            animator.ResetTrigger("fadein");
            animator.ResetTrigger("fadeout");
            animator.SetTrigger("fadeout");
        }

        public void HomeButtonClicked()
        {
            SoundManager.ButtonClicked();
            Main.SetScene(Main.ActiveScene.home);
        }

        public void RateButtonClicked()
        {
            SoundManager.ButtonClicked();
            Application.OpenURL("market://details?id=com.florianwolf.flipfall");
        }
    }
}