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

public class TitlePageManager : MonoBehaviour {
    public GameObject GameplayManagerPrefab;
    public GameObject switchBoardPrefab;
    public GameObject titlePage;


    public GameObject zoomIn;
    public Material alphaOut;
    private bool zoomInTrue = false;
    private bool alphaOutTrue = false;

    public void Start()
    {
        titlePage.SetActive(true);
        alphaOut.color = Color.black;

    }
    public void StartButton()
    {
        GameplayManagerPrefab.SetActive(true);
        switchBoardPrefab.SetActive(true);
        zoomInTrue = true;
        alphaOutTrue = true;
        AudioManager.Instance.PlaySoundEffect(AudioManager.Instance.GenericClick);
        AudioManager.Instance.BGMAudioSource.loop = false;
        AudioManager.Instance.BGMAudioSource.Stop();
    }

    void Update()
    {
        float speed = 5f;
        if(zoomInTrue) {
            zoomIn.transform.localScale = new Vector3((zoomIn.transform.localScale.x - Time.deltaTime * speed), (zoomIn.transform.localScale.y - Time.deltaTime * speed), (zoomIn.transform.localScale.z - Time.deltaTime * speed));
        }
        if(alphaOutTrue) {
            alphaOut.color = new Color(alphaOut.color.r, alphaOut.color.g, alphaOut.color.b, alphaOut.color.a - Time.deltaTime * speed);
            //zoomOut.transform.localScale = new Vector3((zoomOut.transform.localScale.x + Time.deltaTime), (zoomOut.transform.localScale.y + Time.deltaTime), (zoomOut.transform.localScale.z + Time.deltaTime));
        }
        if((zoomIn.transform.localScale.x <= 0 && zoomIn.transform.localScale.y <= 0 && zoomIn.transform.localScale.z <= 0) &&
            (alphaOut.color.a <= 0)) {
            titlePage.SetActive(false);
        }
    }
}
