CardInfo.cs 4.8 KB

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