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

public class QuestUI_Slot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
    private RectTransform rect;
    public RectTransform Rect
    {
        get
        {
            if (rect == null)
            {
                rect = GetComponent<RectTransform>();
            }
            return rect;
        }
    }

    public Image board;
    public Image icon;
    public QuestInfo quest;

    public void setQuest(QuestInfo questInfo)
    {
        if (questInfo == null)
        {
            quest = questInfo;
            board.color = QuestManager.Instance.questBoardColor[0];
            icon.sprite = null;
            return;
        }
        quest = questInfo;
        if (questInfo.isSuccess)
        {
            icon.sprite = questInfo.questIcon;
            board.color = QuestManager.Instance.questBoardColor[1];
        }
        else
        {
            board.color = QuestManager.Instance.questBoardColor[0];
        }

    }



    public void OnPointerEnter(PointerEventData eventData)
    {
        if (quest == null)
        {
            return;
        }
        GameManager.Instance.toolTipOn(quest.QuestTag, this.transform.position, Vector2.one, quest.QuestContent);
    }
    public void OnPointerExit(PointerEventData eventData)
    {
        if (quest == null)
        {
            return;
        }
        GameManager.Instance.toolTipOff(quest.QuestTag);
    }

}
