ShowEffectDiscriptionObject.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. using DG.Tweening;
  6. using UnityEngine.UI;
  7. public class ShowEffectDiscriptionObject : MonoBehaviour
  8. {
  9. [SerializeField] Transform parent;
  10. [SerializeField] Image CardImage;
  11. [SerializeField] Image CardImageOutline;
  12. [SerializeField] TextMeshProUGUI EffectDiscriptionText;
  13. ICardEffect cardEffect;
  14. public async void ShowEffectDiscription(ICardEffect cardEffect)
  15. {
  16. if (cardEffect != null)
  17. {
  18. if (cardEffect.EffectSourceCard != null)
  19. {
  20. if (string.IsNullOrEmpty(cardEffect.EffectDiscription))
  21. {
  22. CloseShowEffectDiscription();
  23. }
  24. else
  25. {
  26. this.cardEffect = cardEffect;
  27. CardImage.sprite = await cardEffect.EffectSourceCard.GetCardSprite();
  28. CardImageOutline.color = DataBase.CardColor_ColorDarkDictionary[cardEffect.EffectSourceCard.BaseCardColorsFromEntity[0]];
  29. EffectDiscriptionText.text = DataBase.ReplaceToASCII(cardEffect.EffectDiscription);
  30. Sequence sequence = DOTween.Sequence();
  31. sequence
  32. .Append(parent.DOLocalMoveX(840, 0.1f).SetEase(Ease.OutQuad));
  33. sequence.Play();
  34. StartCoroutine(CloseIEnumerator());
  35. }
  36. }
  37. }
  38. }
  39. IEnumerator CloseIEnumerator()
  40. {
  41. yield return new WaitForSeconds(5.5f);
  42. CloseShowEffectDiscription();
  43. }
  44. public void CloseShowEffectDiscription()
  45. {
  46. DestroyImmediate(this.gameObject);
  47. }
  48. public void OnClickCardImage()
  49. {
  50. if (this.cardEffect != null)
  51. {
  52. if (this.cardEffect.EffectSourceCard != null)
  53. {
  54. GManager.instance.cardDetail.OpenCardDetail(this.cardEffect.EffectSourceCard, true);
  55. if (GManager.instance != null)
  56. {
  57. GManager.instance.PlayDecisionSE();
  58. }
  59. }
  60. }
  61. }
  62. }