PermanentDetail.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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 security attack
  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 unblockable
  86. if (permanent.IsUnblockable)
  87. {
  88. effectString += $"- Unblockable\n";
  89. }
  90. #endregion
  91. #region blocker
  92. if (permanent.HasBlocker)
  93. {
  94. effectString += $"- Blocker\n";
  95. }
  96. #endregion
  97. #region Pierce
  98. if (permanent.HasPierce)
  99. {
  100. effectString += $"- Pierce\n";
  101. }
  102. #endregion
  103. #region Reboot
  104. if (permanent.HasReboot)
  105. {
  106. effectString += $"- Reboot\n";
  107. }
  108. #endregion
  109. #region Evade
  110. if (permanent.HasEvade)
  111. {
  112. effectString += $"- Evade\n";
  113. }
  114. #endregion
  115. #region Rush
  116. if (permanent.HasRush)
  117. {
  118. effectString += $"- Rush\n";
  119. }
  120. #endregion
  121. #region Alliance
  122. if (permanent.HasAlliance)
  123. {
  124. effectString += $"- Alliance\n";
  125. }
  126. #endregion
  127. #region Barrier
  128. if (permanent.HasBarrier)
  129. {
  130. effectString += $"- Barrier\n";
  131. }
  132. #endregion
  133. #region Retaliation
  134. if (permanent.HasRetaliation)
  135. {
  136. for (int i = 0; i < permanent.RetaliationCount; i++)
  137. {
  138. effectString += $"- Retaliation\n";
  139. }
  140. }
  141. #endregion
  142. #region Jamming
  143. if (permanent.HasJamming)
  144. {
  145. effectString += $"- Jamming\n";
  146. }
  147. #endregion
  148. #region Raid
  149. if (permanent.HasRaid)
  150. {
  151. effectString += $"- Raid\n";
  152. }
  153. #endregion
  154. #region Mind Link
  155. if (permanent.HasMindLink)
  156. {
  157. effectString += $"- Mind Link\n";
  158. }
  159. #endregion
  160. #region Fortitude
  161. if (permanent.HasFortitude)
  162. {
  163. effectString += $"- Fortitude\n";
  164. }
  165. #endregion
  166. #region Blitz
  167. if (permanent.HasBlitz)
  168. {
  169. effectString += $"- Blitz\n";
  170. }
  171. #endregion
  172. #region Scapegoat
  173. if (permanent.HasScapegoat)
  174. {
  175. effectString += $"- Scapegoat\n";
  176. }
  177. #endregion
  178. #region Collision
  179. if (permanent.HasCollision)
  180. {
  181. effectString += $"- Collision\n";
  182. }
  183. #endregion
  184. #region Partition
  185. if (permanent.HasPartition)
  186. {
  187. effectString += $"- Partition\n";
  188. }
  189. #endregion
  190. #region Security Attack Changes
  191. if (permanent.HasSecurityAttackChanges)
  192. {
  193. for (int i = 0; i < permanent.SecurityAttackChanges.Count; i++)
  194. {
  195. string text = permanent.SecurityAttackChanges[i] > 0 ? $"- Security Attack +{permanent.SecurityAttackChanges[i]}\n" : $"- Security Attack {permanent.SecurityAttackChanges[i]}\n";
  196. effectString += text;
  197. }
  198. }
  199. #endregion
  200. #region effect
  201. foreach (ICardEffect cardEffect in cardEffects)
  202. {
  203. if (cardEffect is IChangeSAttackEffect)
  204. {
  205. continue;
  206. }
  207. if (cardEffect is ICanSuspendByDigisorptionEffect)
  208. {
  209. continue;
  210. }
  211. if (cardEffect is IAddSkillEffect)
  212. {
  213. continue;
  214. }
  215. if (cardEffect is IBlockerEffect)
  216. {
  217. continue;
  218. }
  219. if (cardEffect is IRushEffect)
  220. {
  221. continue;
  222. }
  223. if (cardEffect is IRebootEffect)
  224. {
  225. continue;
  226. }
  227. if (cardEffect is IAddDigivolutionRequirementEffect)
  228. {
  229. continue;
  230. }
  231. if (cardEffect is CanNotBeDestroyedByBattleClass && cardEffect.EffectName == "Jamming")
  232. {
  233. continue;
  234. }
  235. if (cardEffect.IsNotShowUI)
  236. {
  237. continue;
  238. }
  239. effectString += $"- {cardEffect.EffectName}\n";
  240. }
  241. #endregion
  242. effectText.text = effectString.Replace("、", ",").Replace(",", ",");
  243. effectText.raycastTarget = false;
  244. for (int i = 0; i < pokemonScroll.content.childCount; i++)
  245. {
  246. Destroy(pokemonScroll.content.GetChild(i).gameObject);
  247. }
  248. //Adds Top card to stack
  249. CardInfo topCardInfo = Instantiate(cardInfoPrefab, pokemonScroll.content);
  250. topCardInfo.SetUpCardInfo(permanent.TopCard, permanent);
  251. //Adds Digivolution Cards
  252. foreach (CardSource cardSource in permanent.DigivolutionCards.Clone())
  253. {
  254. CardInfo cardInfo = Instantiate(cardInfoPrefab, pokemonScroll.content);
  255. cardInfo.SetUpCardInfo(cardSource);
  256. }
  257. //Adds Linked Cards
  258. foreach (CardSource cardSource in permanent.LinkedCards.Clone())
  259. {
  260. CardInfo cardInfo = Instantiate(cardInfoPrefab, pokemonScroll.content);
  261. cardInfo.SetUpCardInfo(cardSource);
  262. }
  263. Vector3 targetPositon = Vector3.zero;
  264. Vector3 startPosition = Vector3.zero;
  265. if (_permanent.ShowingPermanentCard.transform.position.x > 27)
  266. {
  267. targetPositon = new Vector3(-390, 0, 0);
  268. startPosition = new Vector3(-130, 0, 0);
  269. }
  270. else
  271. {
  272. targetPositon = new Vector3(390, 0, 0);
  273. startPosition = new Vector3(130, 0, 0);
  274. }
  275. pokemonInfoPanel.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
  276. float animationTime = 0.12f;
  277. var sequence = DOTween.Sequence();
  278. sequence
  279. .Append(pokemonInfoPanel.transform.DOScale(new Vector3(1.3f, 1.3f, 1.3f), animationTime));
  280. sequence.Play();
  281. await Task.Delay(TimeSpan.FromSeconds(Time.deltaTime));
  282. pokemonScroll.verticalNormalizedPosition = 1;
  283. }
  284. bool _first = false;
  285. public void CloseUnitDetail()
  286. {
  287. if (_first)
  288. {
  289. if (Opening.instance != null)
  290. {
  291. Opening.instance.PlayCancelSE();
  292. }
  293. }
  294. _first = true;
  295. gameObject.SetActive(false);
  296. }
  297. public void OnClickCardImage()
  298. {
  299. if (_permanent != null)
  300. {
  301. if (_permanent.TopCard != null)
  302. {
  303. GManager.instance.cardDetail.OpenCardDetail(_permanent.TopCard, true);
  304. if (GManager.instance != null)
  305. {
  306. GManager.instance.PlayDecisionSE();
  307. }
  308. }
  309. }
  310. if (topCard != null)
  311. {
  312. GManager.instance.cardDetail.OpenCardDetail(topCard, true);
  313. if (GManager.instance != null)
  314. {
  315. GManager.instance.PlayDecisionSE();
  316. }
  317. }
  318. }
  319. }