CardInfo.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Events;
  6. using System;
  7. using TMPro;
  8. public class CardInfo : MonoBehaviour
  9. {
  10. [Header("BackGround")]
  11. public List<Image> BackGrounds = new List<Image>();
  12. public GameObject LinkBackground;
  13. [Header("CardImage")]
  14. public Image CardImage;
  15. [Header("進化元効果")]
  16. public TextMeshProUGUI InheritedEffectText;
  17. [SerializeField] TMP_FontAsset InheritedEffectFont_ENG;
  18. [SerializeField] TMP_FontAsset InheritedEffectFont_JPN;
  19. [SerializeField] Material InheritedEffectMaterial;
  20. public Image outlineImage;
  21. public Sprite HatenaCard;
  22. public List<ScrollRect> scrollRects = new List<ScrollRect>();
  23. UnityAction OnEnterAction;
  24. UnityAction OnExitAction;
  25. public CardSource cardSource { get; set; }
  26. public void OnEnter()
  27. {
  28. OnEnterAction?.Invoke();
  29. }
  30. public void OnExit()
  31. {
  32. OnExitAction?.Invoke();
  33. }
  34. public async void SetUpCardInfo(CardSource cardSource)
  35. {
  36. this.cardSource = cardSource;
  37. this.gameObject.SetActive(true);
  38. outlineImage.color = DataBase.CardColor_ColorDarkDictionary[cardSource.BaseCardColorsFromEntity[0]];
  39. InheritedEffectText.text = "";
  40. if (!cardSource.IsFlipped)
  41. {
  42. if (cardSource.PermanentOfThisCard() != null)
  43. {
  44. if (cardSource != cardSource.PermanentOfThisCard().TopCard)
  45. {
  46. if (ContinuousController.instance.language == Language.ENG)
  47. {
  48. InheritedEffectText.font = InheritedEffectFont_ENG;
  49. InheritedEffectText.fontSharedMaterial = InheritedEffectMaterial;
  50. if(!cardSource.IsLinked)
  51. InheritedEffectText.text = cardSource.InheritedEffectDiscription_ENG;
  52. else
  53. InheritedEffectText.text = cardSource.LinkEffectDiscription;
  54. }
  55. else
  56. {
  57. InheritedEffectText.font = InheritedEffectFont_JPN;
  58. InheritedEffectText.text = cardSource.InheritedEffectDiscription_JPN;
  59. }
  60. }
  61. }
  62. InheritedEffectText.color = Color.white;
  63. if (cardSource.BaseCardColorsFromEntity.Count >= 1)
  64. {
  65. if (!cardSource.BaseCardColorsFromEntity.Contains(CardColor.Black))
  66. {
  67. if (cardSource.BaseCardColorsFromEntity[0] == CardColor.Yellow || cardSource.BaseCardColorsFromEntity[0] == CardColor.White)
  68. {
  69. InheritedEffectText.color = Color.black;
  70. }
  71. }
  72. }
  73. CardImage.color = new Color(1, 1, 1, 1);
  74. CardImage.sprite = await cardSource.GetCardSprite();
  75. for (int i = 0; i < BackGrounds.Count; i++)
  76. {
  77. CardColor cardColor = CardColor.None;
  78. if (i < cardSource.BaseCardColorsFromEntity.Count)
  79. {
  80. cardColor = cardSource.BaseCardColorsFromEntity[i];
  81. BackGrounds[i].color = DataBase.CardColor_ColorDarkDictionary[cardColor];
  82. BackGrounds[i].gameObject.SetActive(true);
  83. }
  84. else
  85. {
  86. BackGrounds[i].gameObject.SetActive(false);
  87. }
  88. }
  89. //Link
  90. LinkBackground.SetActive(cardSource.IsLinked);
  91. }
  92. else
  93. {
  94. InheritedEffectText.text = "???";
  95. CardImage.color = new Color(1, 1, 1, 1);
  96. CardImage.sprite = HatenaCard;
  97. for (int i = 0; i < BackGrounds.Count; i++)
  98. {
  99. BackGrounds[i].color = DataBase.CardColor_ColorDarkDictionary[CardColor.White];
  100. }
  101. }
  102. }
  103. public void CloseSoulInfo()
  104. {
  105. this.gameObject.SetActive(false);
  106. }
  107. public void OnClick()
  108. {
  109. if (cardSource.IsFlipped)
  110. {
  111. return;
  112. }
  113. GManager.instance.cardDetail.OpenCardDetail(cardSource, true);
  114. if (GManager.instance != null)
  115. {
  116. GManager.instance.PlayDecisionSE();
  117. }
  118. }
  119. List<string> IndexStrings = new List<string>()
  120. {
  121. "①","②","③","④","⑤","⑥","⑦","⑧","⑨","⑩",
  122. "⑪","⑫","⑬","⑭","⑮","⑯","⑰","⑱","⑲","⑳",
  123. };
  124. }