PermanentDetail.cs 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using System;
  6. using DG.Tweening;
  7. using System.Threading.Tasks;
  8. using TMPro;
  9. using System.Linq;
  10. public class PermanentDetail : MonoBehaviour
  11. {
  12. [Header("パネル")]
  13. public GameObject pokemonInfoPanel;
  14. [Header("カード情報プレハブ")]
  15. public CardInfo cardInfoPrefab;
  16. public TextMeshProUGUI cardNameText;
  17. public ScrollRect pokemonScroll;
  18. public TextMeshProUGUI effectText;
  19. public Image CardImage;
  20. Permanent _permanent;
  21. [SerializeField] TMP_FontAsset CardNameFont_ENG;
  22. [SerializeField] TMP_FontAsset CardNameFont_JPN;
  23. CardSource topCard = null;
  24. public async void OpenUnitDetail(Permanent permanent)
  25. {
  26. GManager.instance.PlayDecisionSE();
  27. _permanent = permanent;
  28. if (permanent.TopCard != null)
  29. {
  30. topCard = permanent.TopCard;
  31. }
  32. this.gameObject.SetActive(true);
  33. CardImage.sprite = await permanent.TopCard.GetCardSprite();
  34. if (cardNameText != null)
  35. {
  36. if (ContinuousController.instance.language == Language.ENG)
  37. {
  38. cardNameText.font = CardNameFont_ENG;
  39. cardNameText.text = _permanent.TopCard.BaseENGCardNameFromEntity;
  40. }
  41. else
  42. {
  43. cardNameText.font = CardNameFont_JPN;
  44. cardNameText.text = _permanent.TopCard.BaseJPNCardNameFromEntity;
  45. }
  46. }
  47. List<ICardEffect> cardEffects = new List<ICardEffect>();
  48. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  49. {
  50. bool add = false;
  51. if (cardEffect is IDisableCardEffect)
  52. {
  53. add = true;
  54. }
  55. else
  56. {
  57. if (cardEffect.CanUse(null))
  58. {
  59. if (!string.IsNullOrEmpty(cardEffect.EffectName))
  60. {
  61. add = true;
  62. }
  63. }
  64. }
  65. if (add)
  66. {
  67. cardEffects.Add(cardEffect);
  68. }
  69. }
  70. string effectString = "";
  71. #region セキュリティアタック
  72. if (permanent.IsDigimon)
  73. {
  74. if (permanent.Strike_AllowMinus >= 0)
  75. {
  76. effectString += $"Security Attack : {permanent.Strike}\n";
  77. }
  78. else
  79. {
  80. effectString += $"Security Attack : {permanent.Strike} ({permanent.Strike_AllowMinus})\n";
  81. }
  82. effectString += $"-------------------------\n";
  83. }
  84. #endregion
  85. #region ブロッカー
  86. if (permanent.HasBlocker)
  87. {
  88. effectString += $"- Blocker\n";
  89. }
  90. #endregion
  91. #region 貫通
  92. if (permanent.HasPierce)
  93. {
  94. effectString += $"- Pierce\n";
  95. }
  96. #endregion
  97. #region 再起動
  98. if (permanent.HasReboot)
  99. {
  100. effectString += $"- Reboot\n";
  101. }
  102. #endregion
  103. #region 回避
  104. if (permanent.HasEvade)
  105. {
  106. effectString += $"- Evade\n";
  107. }
  108. #endregion
  109. #region 速攻
  110. if (permanent.HasRush)
  111. {
  112. effectString += $"- Rush\n";
  113. }
  114. #endregion
  115. #region 連携
  116. if (permanent.HasAlliance)
  117. {
  118. effectString += $"- Alliance\n";
  119. }
  120. #endregion
  121. #region 防壁
  122. if (permanent.HasBarrier)
  123. {
  124. effectString += $"- Barrier\n";
  125. }
  126. #endregion
  127. #region 道連れ
  128. if (permanent.HasRetaliation)
  129. {
  130. for (int i = 0; i < permanent.RetaliationCount; i++)
  131. {
  132. effectString += $"- Retaliation\n";
  133. }
  134. }
  135. #endregion
  136. #region ジャミング
  137. if (permanent.HasJamming)
  138. {
  139. effectString += $"- Jamming\n";
  140. }
  141. #endregion
  142. #region 突進
  143. if (permanent.HasRaid)
  144. {
  145. effectString += $"- Raid\n";
  146. }
  147. #endregion
  148. #region マインドリンク
  149. if (permanent.HasMindLink)
  150. {
  151. effectString += $"- Mind Link\n";
  152. }
  153. #endregion
  154. #region 不屈
  155. if (permanent.HasFortitude)
  156. {
  157. effectString += $"- Fortitude\n";
  158. }
  159. #endregion
  160. #region 進撃
  161. if (permanent.HasBlitz)
  162. {
  163. effectString += $"- Blitz\n";
  164. }
  165. #endregion
  166. #region セキュリティアタック変更
  167. if (permanent.HasSecurityAttackChanges)
  168. {
  169. for (int i = 0; i < permanent.SecurityAttackChanges.Count; i++)
  170. {
  171. string text = permanent.SecurityAttackChanges[i] > 0 ? $"- Security Attack +{permanent.SecurityAttackChanges[i]}\n" : $"- Security Attack {permanent.SecurityAttackChanges[i]}\n";
  172. effectString += text;
  173. }
  174. }
  175. #endregion
  176. #region 効果
  177. foreach (ICardEffect cardEffect in cardEffects)
  178. {
  179. if (cardEffect is IChangeSAttackEffect)
  180. {
  181. continue;
  182. }
  183. if (cardEffect is ICanSuspendByDigisorptionEffect)
  184. {
  185. continue;
  186. }
  187. if (cardEffect is IAddSkillEffect)
  188. {
  189. continue;
  190. }
  191. if (cardEffect is IBlockerEffect)
  192. {
  193. continue;
  194. }
  195. if (cardEffect is IRushEffect)
  196. {
  197. continue;
  198. }
  199. if (cardEffect is IRebootEffect)
  200. {
  201. continue;
  202. }
  203. if (cardEffect is IAddDigivolutionRequirementEffect)
  204. {
  205. continue;
  206. }
  207. if (cardEffect is CanNotBeDestroyedByBattleClass && cardEffect.EffectName == "Jamming")
  208. {
  209. continue;
  210. }
  211. if (cardEffect.IsNotShowUI)
  212. {
  213. continue;
  214. }
  215. effectString += $"- {cardEffect.EffectName}\n";
  216. }
  217. #endregion
  218. effectText.text = effectString.Replace("、", ",").Replace(",", ",");
  219. effectText.raycastTarget = false;
  220. for (int i = 0; i < pokemonScroll.content.childCount; i++)
  221. {
  222. Destroy(pokemonScroll.content.GetChild(i).gameObject);
  223. }
  224. List<CardSource> cardSources = permanent.cardSources.Clone();
  225. foreach (CardSource cardSource in cardSources)
  226. {
  227. CardInfo cardInfo = Instantiate(cardInfoPrefab, pokemonScroll.content);
  228. cardInfo.SetUpCardInfo(cardSource);
  229. foreach (ScrollRect scrollRect in cardInfo.scrollRects)
  230. {
  231. scrollRect.content = pokemonScroll.content;
  232. scrollRect.viewport = pokemonScroll.viewport;
  233. }
  234. }
  235. Vector3 targetPositon = Vector3.zero;
  236. Vector3 startPosition = Vector3.zero;
  237. if (_permanent.ShowingPermanentCard.transform.position.x > 27)
  238. {
  239. targetPositon = new Vector3(-390, 0, 0);
  240. startPosition = new Vector3(-130, 0, 0);
  241. }
  242. else
  243. {
  244. targetPositon = new Vector3(390, 0, 0);
  245. startPosition = new Vector3(130, 0, 0);
  246. }
  247. pokemonInfoPanel.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
  248. float animationTime = 0.12f;
  249. var sequence = DOTween.Sequence();
  250. sequence
  251. .Append(pokemonInfoPanel.transform.DOScale(new Vector3(1.3f, 1.3f, 1.3f), animationTime));
  252. sequence.Play();
  253. await Task.Delay(TimeSpan.FromSeconds(Time.deltaTime));
  254. pokemonScroll.verticalNormalizedPosition = 1;
  255. }
  256. bool _first = false;
  257. public void CloseUnitDetail()
  258. {
  259. if (_first)
  260. {
  261. if (Opening.instance != null)
  262. {
  263. Opening.instance.PlayCancelSE();
  264. }
  265. }
  266. _first = true;
  267. gameObject.SetActive(false);
  268. }
  269. public void OnClickCardImage()
  270. {
  271. if (_permanent != null)
  272. {
  273. if (_permanent.TopCard != null)
  274. {
  275. GManager.instance.cardDetail.OpenCardDetail(_permanent.TopCard, true);
  276. if (GManager.instance != null)
  277. {
  278. GManager.instance.PlayDecisionSE();
  279. }
  280. }
  281. }
  282. if (topCard != null)
  283. {
  284. GManager.instance.cardDetail.OpenCardDetail(topCard, true);
  285. if (GManager.instance != null)
  286. {
  287. GManager.instance.PlayDecisionSE();
  288. }
  289. }
  290. }
  291. }