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

public class InGameUI : MonoBehaviour
{

    public Button replayButton;
    public Image loseImage;
    public Image winImage;

    void Awake()
    {
        Messenger<string>.AddListener("GameOverFailure", OnGameOverFailure);
        Messenger.AddListener("GameOverGoalReached", OnGameOverGoalReached);
    }

    void OnDestroy()
    {
        Messenger<string>.RemoveListener("GameOverFailure", OnGameOverFailure);
        Messenger.RemoveListener("GameOverGoalReached", OnGameOverGoalReached);
    }

    // Start is called before the first frame update
    void Start()
    {
        winImage.enabled = false;
        loseImage.enabled = false;
        replayButton.gameObject.SetActive(false);
    }

    void OnGameOverFailure(string message)
    {
        winImage.enabled = false;
        loseImage.enabled = true;
        replayButton.gameObject.SetActive(true);
    }

    void OnGameOverGoalReached()
    {
        loseImage.enabled = false;
        winImage.enabled = true;
        replayButton.gameObject.SetActive(true);
    }
}
