WXMC/.svn/pristine/90/905a3d022443b58e74beae774c2a6a2e1f5e9297.svn-base
2024-12-04 16:18:46 +08:00

65 lines
1.8 KiB
Plaintext

using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.UI;
public class PuzzleCardExplainItem : MonoBehaviour
{
public Image img_tarot;
public PuzzleTarotCard TarotCard;
[SerializeField]
private Button m_explainBtn;
[SerializeField]
public TMPro.TMP_Text m_explainText;
[SerializeField]
private Button m_backBtn;
[SerializeField]
private Button m_questionBtn;
[SerializeField]
public CanvasGroup canvasGroup;
private Vector3 m_localPosition;
private Action<PuzzleCardExplainItem> m_questionAc;
public void Init(PuzzleTarotCardItem tarotCard,string content,Action<PuzzleCardExplainItem> questionClick)
{
m_questionAc = questionClick;
TarotCard = tarotCard.TarotCard;
img_tarot.sprite = TarotCard.TarotImage;
m_explainBtn.onClick.AddListener(ExplainCard);
m_backBtn.onClick.AddListener(BackBtnClick);
m_questionBtn.onClick.AddListener(QuestionBtnClick);
m_explainText.text =content;
canvasGroup.alpha = 0f;
}
void ExplainCard()
{
m_localPosition = transform.localPosition;
m_explainBtn.enabled = false;
transform.DOLocalMove(new Vector3(0,300,0),1f);
transform.DOScale(Vector3.one*4f,1f).OnComplete(()=>
{
canvasGroup.alpha = 0f;
canvasGroup.DOFade(1f, 1f);
}
);
transform.SetAsLastSibling();
}
void BackBtnClick()
{
canvasGroup.DOFade(0f, 1f);
transform.DOLocalMove(m_localPosition,1f);
transform.DOScale(Vector3.one,1f);
m_explainBtn.enabled = true;
}
void QuestionBtnClick()
{
canvasGroup.gameObject.SetActive(false);
m_questionAc(this);
}
}