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

public class UIManager : MonoBehaviour {
    public GameObject titleScreen, tapScreen, playScreen, gameOverScreen;
    public Text scoreText, finalScoreText;
    public Animator fade;

    void Awake()
    {
        Observer.scoreChangeHandler += OnScoreUp;
        Observer.gameTitleExitedHandler += OnGameTitleExited;
        Observer.gameInitiatedHandler += OnGameInitiated;
        Observer.gameOverHandler += OnGameOver;
        Observer.gameResetHandler += OnGameReset;
    }

    void OnScoreUp(int score)
    {
        scoreText.text = "score: " + score;
        finalScoreText.text = "final score: " + score;
    }

    void OnGameInitiated()
    {
        this.tapScreen.SetActive(false);
        this.playScreen.SetActive(true);
    }

    void OnGameTitleExited()
    {
        this.titleScreen.SetActive(false);
        this.tapScreen.SetActive(true);
    }

    void OnGameOver()
    {
        this.playScreen.SetActive(false);
        this.gameOverScreen.SetActive(true);
    }

    void OnGameReset()
    {
        Debug.Log("Reset!");
        this.fade.Play("on");
    }
}
