PermanentDetail.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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 Ascension
  191. if (permanent.HasAscension)
  192. {
  193. effectString += $"- Ascension\n";
  194. }
  195. #endregion
  196. #region Security Attack Changes
  197. if (permanent.HasSecurityAttackChanges)
  198. {
  199. for (int i = 0; i < permanent.SecurityAttackChanges.Count; i++)
  200. {
  201. string text = permanent.SecurityAttackChanges[i] > 0 ? $"- Security Attack +{permanent.SecurityAttackChanges[i]}\n" : $"- Security Attack {permanent.SecurityAttackChanges[i]}\n";
  202. effectString += text;
  203. }
  204. }
  205. #endregion
  206. #region effect
  207. foreach (ICardEffect cardEffect in cardEffects)
  208. {
  209. if (cardEffect is IChangeSAttackEffect)
  210. {
  211. continue;
  212. }
  213. if (cardEffect is ICanSuspendByDigisorptionEffect)
  214. {
  215. continue;
  216. }
  217. if (cardEffect is IAddSkillEffect)
  218. {
  219. continue;
  220. }
  221. if (cardEffect is IBlockerEffect)
  222. {
  223. continue;
  224. }
  225. if (cardEffect is IRushEffect)
  226. {
  227. continue;
  228. }
  229. if (cardEffect is IRebootEffect)
  230. {
  231. continue;
  232. }
  233. if (cardEffect is IAddDigivolutionRequirementEffect)
  234. {
  235. continue;
  236. }
  237. if (cardEffect is CanNotBeDestroyedByBattleClass && cardEffect.EffectName == "Jamming")
  238. {
  239. continue;
  240. }
  241. if (cardEffect is IAddDetailEffect)
  242. {
  243. continue;
  244. }
  245. if (cardEffect.IsNotShowUI)
  246. {
  247. continue;
  248. }
  249. effectString += $"- {cardEffect.EffectName}\n";
  250. }
  251. #endregion
  252. #region AddDetails
  253. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  254. {
  255. #region Effects of permanents in play
  256. foreach (Permanent otherPermanent in player.GetFieldPermanents())
  257. {
  258. foreach (ICardEffect cardEffect in otherPermanent.EffectList(EffectTiming.None))
  259. {
  260. if (cardEffect is IAddDetailEffect)
  261. {
  262. if (cardEffect.CanTrigger(null))
  263. {
  264. if (((IAddDetailEffect)cardEffect).PermanentCondition(permanent))
  265. {
  266. effectString += $"- {((IAddDetailEffect)cardEffect).GetDetail()}\n";
  267. }
  268. }
  269. }
  270. }
  271. }
  272. #endregion
  273. #region Effects of Players
  274. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  275. {
  276. if (cardEffect is IAddDetailEffect)
  277. {
  278. if (cardEffect.CanTrigger(null))
  279. {
  280. if (((IAddDetailEffect)cardEffect).PermanentCondition(permanent))
  281. {
  282. effectString += $"- {((IAddDetailEffect)cardEffect).GetDetail()}\n";
  283. }
  284. }
  285. }
  286. }
  287. #endregion
  288. }
  289. #endregion
  290. effectText.text = effectString.Replace("、", ",").Replace(",", ",");
  291. effectText.raycastTarget = false;
  292. for (int i = 0; i < pokemonScroll.content.childCount; i++)
  293. {
  294. Destroy(pokemonScroll.content.GetChild(i).gameObject);
  295. }
  296. //Adds Top card to stack
  297. CardInfo topCardInfo = Instantiate(cardInfoPrefab, pokemonScroll.content);
  298. topCardInfo.SetUpCardInfo(permanent.TopCard, permanent);
  299. //Adds Digivolution Cards
  300. foreach (CardSource cardSource in permanent.DigivolutionCards.Clone())
  301. {
  302. CardInfo cardInfo = Instantiate(cardInfoPrefab, pokemonScroll.content);
  303. cardInfo.SetUpCardInfo(cardSource);
  304. }
  305. //Adds Linked Cards
  306. foreach (CardSource cardSource in permanent.LinkedCards.Clone())
  307. {
  308. CardInfo cardInfo = Instantiate(cardInfoPrefab, pokemonScroll.content);
  309. cardInfo.SetUpCardInfo(cardSource);
  310. }
  311. Vector3 targetPositon = Vector3.zero;
  312. Vector3 startPosition = Vector3.zero;
  313. if (_permanent.ShowingPermanentCard.transform.position.x > 27)
  314. {
  315. targetPositon = new Vector3(-390, 0, 0);
  316. startPosition = new Vector3(-130, 0, 0);
  317. }
  318. else
  319. {
  320. targetPositon = new Vector3(390, 0, 0);
  321. startPosition = new Vector3(130, 0, 0);
  322. }
  323. pokemonInfoPanel.transform.localScale = new Vector3(1.1f, 1.1f, 1.1f);
  324. float animationTime = 0.12f;
  325. var sequence = DOTween.Sequence();
  326. sequence
  327. .Append(pokemonInfoPanel.transform.DOScale(new Vector3(1.3f, 1.3f, 1.3f), animationTime));
  328. sequence.Play();
  329. await Task.Delay(TimeSpan.FromSeconds(Time.deltaTime));
  330. pokemonScroll.verticalNormalizedPosition = 1;
  331. }
  332. bool _first = false;
  333. public void CloseUnitDetail()
  334. {
  335. if (_first)
  336. {
  337. if (Opening.instance != null)
  338. {
  339. Opening.instance.PlayCancelSE();
  340. }
  341. }
  342. _first = true;
  343. gameObject.SetActive(false);
  344. }
  345. public void OnClickCardImage()
  346. {
  347. if (_permanent != null)
  348. {
  349. if (_permanent.TopCard != null)
  350. {
  351. GManager.instance.cardDetail.OpenCardDetail(_permanent.TopCard, true);
  352. if (GManager.instance != null)
  353. {
  354. GManager.instance.PlayDecisionSE();
  355. }
  356. }
  357. }
  358. if (topCard != null)
  359. {
  360. GManager.instance.cardDetail.OpenCardDetail(topCard, true);
  361. if (GManager.instance != null)
  362. {
  363. GManager.instance.PlayDecisionSE();
  364. }
  365. }
  366. }
  367. }