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

public class AttrDescPanel : MonoBehaviour {

    public UIBackRayBehind behindMask;
    public RectTransform descPanel;
    public Text desc;
    public Vector2 offset;          // 和点击的属性偏离

    private int lastAttrID;         // 上一次显示的属性,再次点击会关闭该界面

    private void Awake()
    {
        behindMask._BackClick.AddListener(Close);
        lastAttrID = -1;
    }

    public void ShowAttr(int attrID, Transform selectAttrTran)
    {
        if(attrID == lastAttrID)
        {
            lastAttrID = -1;
        }
        else
        {
            lastAttrID = attrID;
            desc.text = StrDictionary.GetClientDictionaryString("#{" + (attrID + 70000) + "}");
            Vector3 pos = selectAttrTran.position;
            descPanel.position = selectAttrTran.position + (Vector3)offset;
            this.gameObject.SetActive(true);
        }
    }

    public void Close()
    {
        this.gameObject.SetActive(false);
    }
}