PermanentDetail.cs 9.2 KB

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