HandCard.cs 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Events;
  6. using UnityEngine.EventSystems;
  7. using TMPro;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. public class HandCard : MonoBehaviour
  11. {
  12. [Header("カード画像")]
  13. public Image CardImage;
  14. [Header("選択アウトライン")]
  15. public GameObject Outline_Select;
  16. [Header("表画像表示")]
  17. public Image ShowFaceCard;
  18. [Header("スキル名")]
  19. public TextMeshProUGUI SkillNameText;
  20. [Header("カード場所Text")]
  21. public Text cardPositionText;
  22. [Header("コマンドパネル")]
  23. public CommandPanel handCardCommandPanel;
  24. [Header("コストアイコン")]
  25. public List<Image> CostIcons;
  26. [Header("コストテキスト")]
  27. public TextMeshProUGUI CostText;
  28. [Header("レベルアイコン")]
  29. public List<Image> LevelIcons;
  30. [Header("レベルテキスト")]
  31. public TextMeshProUGUI LevelText;
  32. [Header("進化コストアイコン")]
  33. public List<Image> EvoCostIcons;
  34. [Header("進化コストテキスト_レベル")]
  35. public List<TextMeshProUGUI> EvoCostTexts_Level;
  36. [Header("進化コストテキスト_メモリー")]
  37. public List<TextMeshProUGUI> EvoCostTexts_Memory;
  38. [Header("プレイテキスト")]
  39. public TextMeshProUGUI PlayText;
  40. [Header("ジョグレスプレイテキスト")]
  41. public TextMeshProUGUI JogressPlayText;
  42. [Header("バーストプレイテキスト")]
  43. public TextMeshProUGUI BurstPlayText;
  44. [Header("App Fusion play text")]
  45. public TextMeshProUGUI AppFusionPlayText;
  46. [Header("タイトルテキスト")]
  47. public TextMeshProUGUI titleText;
  48. [Header("1体進化矢印")]
  49. public GameObject singleDigivolutionArrow;
  50. [Header("ジョグレス進化矢印")]
  51. public GameObject jogressDigivolutionArrow;
  52. [Header("ジョグレスエフェクト")]
  53. public GameObject jogressEffect;
  54. [Header("DPテキスト")]
  55. public Text DPText;
  56. [Header("DP枠")]
  57. public List<Image> DPBackground_color = new List<Image>();
  58. [Header("進化元")]
  59. public List<Image> EvoRootCardImages = new List<Image>();
  60. [Header("白丸")]
  61. public Sprite WhiteCircle;
  62. [Header("虹丸")]
  63. public Sprite RainbowCircle;
  64. [Header("クリックテキスト")]
  65. public TextMeshProUGUI ClickText;
  66. public CardSource cardSource { get; set; }
  67. public UnityAction<HandCard> OnClickAction;
  68. public UnityAction<HandCard> BeginDragAction;
  69. public UnityAction<List<DropArea>> OnDragAction;
  70. public UnityAction<List<DropArea>> EndDragAction;
  71. public bool CanDrag;
  72. public List<Image> Outline_SelectImages { get; set; } = new List<Image>();
  73. public bool notHideSelectedIndexText { get; set; } = false;
  74. private void Start()
  75. {
  76. if (!notHideSelectedIndexText)
  77. {
  78. OffSelectedIndexText();
  79. }
  80. RemoveSelectEffect();
  81. for (int i = 0; i < Outline_Select.transform.childCount; i++)
  82. {
  83. if (Outline_Select.transform.GetChild(i).GetComponent<Image>() != null)
  84. {
  85. Outline_SelectImages.Add(Outline_Select.transform.GetChild(i).GetComponent<Image>());
  86. }
  87. }
  88. if (handCardCommandPanel != null)
  89. {
  90. handCardCommandPanel.CloseCommandPanel();
  91. }
  92. if (CostText != null)
  93. {
  94. CostText.transform.parent.gameObject.SetActive(false);
  95. }
  96. if (LevelText != null)
  97. {
  98. LevelText.transform.parent.gameObject.SetActive(false);
  99. }
  100. if (EvoCostIcons != null)
  101. {
  102. if (EvoCostIcons.Count >= 1)
  103. {
  104. for (int i = 0; i < EvoCostIcons.Count; i++)
  105. {
  106. EvoCostIcons[i].transform.parent.gameObject.SetActive(false);
  107. EvoCostIcons[i].transform.parent.parent.gameObject.SetActive(true);
  108. }
  109. }
  110. }
  111. OffPlayText();
  112. OffJogressPlayText();
  113. OffBurstPlayText();
  114. OffAppFusionPlayText();
  115. OffDP();
  116. OffEvoRootCardImage();
  117. OffClickText();
  118. if (singleDigivolutionArrow != null)
  119. {
  120. singleDigivolutionArrow.SetActive(false);
  121. }
  122. if (jogressDigivolutionArrow != null)
  123. {
  124. jogressDigivolutionArrow.SetActive(false);
  125. }
  126. if (jogressEffect != null)
  127. {
  128. jogressEffect.SetActive(false);
  129. }
  130. if (titleText != null)
  131. {
  132. titleText.gameObject.SetActive(false);
  133. }
  134. }
  135. public async void SetEvoRootCardImages(CardSource[] cardSources)
  136. {
  137. if (cardSources != null)
  138. {
  139. if (EvoRootCardImages != null)
  140. {
  141. if (cardSources.Length == 1)
  142. {
  143. if (singleDigivolutionArrow != null)
  144. {
  145. singleDigivolutionArrow.SetActive(true);
  146. }
  147. }
  148. else if (cardSources.Length == 2)
  149. {
  150. if (jogressDigivolutionArrow != null)
  151. {
  152. jogressDigivolutionArrow.SetActive(true);
  153. }
  154. if (jogressEffect != null)
  155. {
  156. jogressEffect.SetActive(true);
  157. }
  158. }
  159. for (int i = 0; i < cardSources.Length; i++)
  160. {
  161. if (EvoRootCardImages.Count > i)
  162. {
  163. if (EvoRootCardImages[i].transform.childCount >= 1)
  164. {
  165. EvoRootCardImages[i].transform.GetChild(0).gameObject.SetActive(false);
  166. }
  167. EvoRootCardImages[i].gameObject.SetActive(true);
  168. if (cardSources[i] != null)
  169. {
  170. EvoRootCardImages[i].sprite = await cardSources[i].GetCardSprite();
  171. }
  172. else
  173. {
  174. if (EvoRootCardImages[i].transform.childCount >= 1)
  175. {
  176. EvoRootCardImages[i].transform.GetChild(0).gameObject.SetActive(true);
  177. }
  178. }
  179. }
  180. }
  181. }
  182. }
  183. }
  184. public void OffEvoRootCardImage()
  185. {
  186. if (EvoRootCardImages != null)
  187. {
  188. for (int i = 0; i < EvoRootCardImages.Count; i++)
  189. {
  190. if (EvoRootCardImages.Count > i)
  191. {
  192. EvoRootCardImages[i].gameObject.SetActive(false);
  193. }
  194. }
  195. }
  196. }
  197. public void ShowDP()
  198. {
  199. if (DPText != null && DPBackground_color != null)
  200. {
  201. if (cardSource.IsDigimon && cardSource.CardDP >= 0)
  202. {
  203. DPText.transform.parent.gameObject.SetActive(true);
  204. DPText.text = cardSource.CardDP.ToString();
  205. for (int i = 0; i < DPBackground_color.Count; i++)
  206. {
  207. CardColor cardColor = CardColor.None;
  208. if (i < cardSource.CardColors.Count)
  209. {
  210. cardColor = cardSource.CardColors[i];
  211. }
  212. else
  213. {
  214. cardColor = cardSource.CardColors[0];
  215. }
  216. DPBackground_color[i].color = DataBase.CardColor_ColorLightDictionary[cardColor];
  217. }
  218. }
  219. else
  220. {
  221. DPText.transform.parent.gameObject.SetActive(false);
  222. }
  223. }
  224. }
  225. public void SetClickText()
  226. {
  227. if (ClickText != null)
  228. {
  229. ClickText.gameObject.SetActive(true);
  230. }
  231. }
  232. public void OffClickText()
  233. {
  234. if (ClickText != null)
  235. {
  236. ClickText.gameObject.SetActive(false);
  237. }
  238. }
  239. public void OffDP()
  240. {
  241. if (DPText != null)
  242. {
  243. DPText.transform.parent.gameObject.SetActive(false);
  244. }
  245. }
  246. public async void SetShowFaceCard()
  247. {
  248. if (ShowFaceCard != null && cardSource != null)
  249. {
  250. ShowFaceCard.gameObject.SetActive(true);
  251. ShowFaceCard.sprite = await cardSource.GetCardSprite();
  252. }
  253. }
  254. public void OffShowFaceCard()
  255. {
  256. if (ShowFaceCard != null)
  257. {
  258. ShowFaceCard.gameObject.SetActive(false);
  259. }
  260. }
  261. public void SetSkillName(ICardEffect cardEffect)
  262. {
  263. if (SkillNameText != null)
  264. {
  265. if (cardEffect != null)
  266. {
  267. if (!string.IsNullOrEmpty(cardEffect.EffectName))
  268. {
  269. SkillNameText.transform.parent.gameObject.SetActive(true);
  270. SkillNameText.text = cardEffect.EffectName;
  271. }
  272. }
  273. }
  274. }
  275. public void SetTitleText(string titleString)
  276. {
  277. if (titleText != null)
  278. {
  279. if (!string.IsNullOrEmpty(titleString))
  280. {
  281. titleText.gameObject.SetActive(true);
  282. titleText.text = titleString;
  283. }
  284. }
  285. }
  286. public void SetOutlineColor(Color color)
  287. {
  288. foreach (Image image in Outline_SelectImages)
  289. {
  290. image.color = color;
  291. }
  292. }
  293. public void SetBlueOutline()
  294. {
  295. SetOutlineColor(DataBase.SelectColor_Blue);
  296. }
  297. public void SetOrangeOutline()
  298. {
  299. SetOutlineColor(DataBase.SelectColor_Orange);
  300. }
  301. public void SetGreenOutline()
  302. {
  303. SetOutlineColor(DataBase.SelectColor_Green);
  304. }
  305. public void OnOutline()
  306. {
  307. if (Outline_Select != null)
  308. Outline_Select.SetActive(true);
  309. }
  310. public void OnSelect()
  311. {
  312. OnOutline();
  313. SetBlueOutline();
  314. }
  315. public void RemoveSelectEffect()
  316. {
  317. if(Outline_Select!= null)
  318. Outline_Select.SetActive(false);
  319. OffClickText();
  320. }
  321. public void SetUpHandCard(CardSource _cardSource, bool showCardImage = true)
  322. {
  323. cardSource = _cardSource;
  324. if (CardImage != null)
  325. {
  326. CardImage.gameObject.SetActive(true);
  327. }
  328. if (_cardSource.Owner.isYou && showCardImage)
  329. {
  330. SetUpHandCardImage();
  331. }
  332. else
  333. {
  334. SetUpReverseCard();
  335. }
  336. }
  337. public void SetUpCardPositionText(List<Permanent> permanents)
  338. {
  339. if (cardPositionText != null)
  340. {
  341. if (cardSource != null)
  342. {
  343. string cardPositionString = "";
  344. if (cardSource.PermanentOfThisCard() != null)
  345. {
  346. if (cardSource.Owner.GetFieldPermanents().Contains(cardSource.PermanentOfThisCard()))
  347. {
  348. int index = permanents.IndexOf(cardSource.PermanentOfThisCard()) + 1;
  349. cardPositionString = $"Field:{index}";
  350. }
  351. }
  352. else if (cardSource.Owner.HandCards.Contains(cardSource))
  353. {
  354. cardPositionString = "Hand";
  355. }
  356. else if (CardEffectCommons.IsExistOnTrash(cardSource))
  357. {
  358. cardPositionString = "Trash";
  359. }
  360. else if (cardSource.Owner.LibraryCards.Contains(cardSource))
  361. {
  362. cardPositionString = "Deck";
  363. }
  364. else if (cardSource.Owner.DigitamaLibraryCards.Contains(cardSource))
  365. {
  366. cardPositionString = "Digi - Egg Deck";
  367. }
  368. cardPositionText.transform.parent.gameObject.SetActive(true);
  369. cardPositionText.text = cardPositionString;
  370. }
  371. }
  372. }
  373. public void SetUpReverseCard()
  374. {
  375. CardImage.sprite = ContinuousController.instance.ReverseCard;
  376. OffShowFaceCard();
  377. if (SkillNameText != null)
  378. {
  379. SkillNameText.transform.parent.gameObject.SetActive(false);
  380. }
  381. if (cardPositionText != null)
  382. {
  383. cardPositionText.transform.parent.gameObject.SetActive(false);
  384. }
  385. }
  386. public bool ShowOpponent { get; set; } = false;
  387. bool onYourHand()
  388. {
  389. if (GManager.instance != null)
  390. {
  391. if (GManager.instance.You.HandCardObjects.Contains(this))
  392. {
  393. return true;
  394. }
  395. if (ShowOpponent)
  396. {
  397. return true;
  398. }
  399. if (!GManager.instance.turnStateMachine.DoneStartGame && cardSource.Owner.isYou)
  400. {
  401. return true;
  402. }
  403. }
  404. return false;
  405. }
  406. int _frameCount = 145;
  407. int _updateFrame = 150;
  408. float _validPressTime = 0.5f;
  409. float _requiredTime = 0.0f;
  410. bool _pressing = false;
  411. public bool IsExecuting { get; set; } = false;
  412. bool _firstRaycastTarget = true;
  413. private void Awake()
  414. {
  415. _firstRaycastTarget = CardImage.raycastTarget;
  416. }
  417. private void Update()
  418. {
  419. if (CardImage.color.a <= 0.1f)
  420. {
  421. CardImage.raycastTarget = false;
  422. }
  423. else
  424. {
  425. CardImage.raycastTarget = _firstRaycastTarget;
  426. }
  427. #region exception check
  428. if (cardSource == null)
  429. {
  430. return;
  431. }
  432. #endregion
  433. #region 長押しの取得
  434. #if !UNITY_EDITOR && UNITY_ANDROID
  435. if (pressing)
  436. {
  437. if(requiredTime < Time.time)
  438. {
  439. OnRightClicked();
  440. pressing = false;
  441. }
  442. }
  443. #endif
  444. #endregion
  445. #region Update only once every few frames
  446. _frameCount++;
  447. if (_frameCount < _updateFrame)
  448. {
  449. return;
  450. }
  451. else
  452. {
  453. _frameCount = 0;
  454. }
  455. #endregion
  456. if (onYourHand())
  457. {
  458. SetUpHandCardImage();
  459. }
  460. }
  461. public void SetPlayText(string message, Color color)
  462. {
  463. if (PlayText != null)
  464. {
  465. PlayText.transform.parent.gameObject.SetActive(true);
  466. PlayText.transform.parent.parent.gameObject.SetActive(true);
  467. PlayText.text = message;
  468. PlayText.color = color;
  469. }
  470. }
  471. public void OffPlayText()
  472. {
  473. if (PlayText != null)
  474. {
  475. PlayText.transform.parent.gameObject.SetActive(false);
  476. PlayText.transform.parent.parent.gameObject.SetActive(true);
  477. }
  478. }
  479. public void SetJogressPlayText()
  480. {
  481. if (JogressPlayText != null)
  482. {
  483. JogressPlayText.transform.parent.gameObject.SetActive(true);
  484. JogressPlayText.transform.parent.parent.gameObject.SetActive(true);
  485. }
  486. }
  487. public void OffJogressPlayText()
  488. {
  489. if (BurstPlayText != null)
  490. {
  491. BurstPlayText.transform.parent.gameObject.SetActive(false);
  492. BurstPlayText.transform.parent.parent.gameObject.SetActive(true);
  493. }
  494. if (AppFusionPlayText != null)
  495. {
  496. AppFusionPlayText.transform.parent.gameObject.SetActive(false);
  497. AppFusionPlayText.transform.parent.parent.gameObject.SetActive(true);
  498. }
  499. }
  500. public void SetBurstPlayText()
  501. {
  502. if (BurstPlayText != null)
  503. {
  504. BurstPlayText.transform.parent.gameObject.SetActive(true);
  505. BurstPlayText.transform.parent.parent.gameObject.SetActive(true);
  506. }
  507. }
  508. public void OffBurstPlayText()
  509. {
  510. if (JogressPlayText != null)
  511. {
  512. JogressPlayText.transform.parent.gameObject.SetActive(false);
  513. JogressPlayText.transform.parent.parent.gameObject.SetActive(true);
  514. }
  515. if (AppFusionPlayText != null)
  516. {
  517. AppFusionPlayText.transform.parent.gameObject.SetActive(false);
  518. AppFusionPlayText.transform.parent.parent.gameObject.SetActive(true);
  519. }
  520. }
  521. public void SetAppFusionPlayText()
  522. {
  523. if (AppFusionPlayText != null)
  524. {
  525. AppFusionPlayText.transform.parent.gameObject.SetActive(true);
  526. AppFusionPlayText.transform.parent.parent.gameObject.SetActive(true);
  527. }
  528. }
  529. public void OffAppFusionPlayText()
  530. {
  531. if (JogressPlayText != null)
  532. {
  533. JogressPlayText.transform.parent.gameObject.SetActive(false);
  534. JogressPlayText.transform.parent.parent.gameObject.SetActive(true);
  535. }
  536. if (BurstPlayText != null)
  537. {
  538. BurstPlayText.transform.parent.gameObject.SetActive(false);
  539. BurstPlayText.transform.parent.parent.gameObject.SetActive(true);
  540. }
  541. }
  542. public void PointerDown(BaseEventData eventData)
  543. {
  544. if (!_pressing)
  545. {
  546. _pressing = true;
  547. _requiredTime = Time.time + _validPressTime;
  548. }
  549. else
  550. {
  551. _pressing = false;
  552. }
  553. }
  554. public void PointerUp(BaseEventData eventData)
  555. {
  556. if (_pressing)
  557. {
  558. _pressing = false;
  559. }
  560. }
  561. public void PointerExit(BaseEventData eventData)
  562. {
  563. if (_pressing)
  564. {
  565. _pressing = false;
  566. }
  567. }
  568. public async void SetUpHandCardImage()
  569. {
  570. if (SkillNameText != null)
  571. {
  572. if (!IsExecuting)
  573. {
  574. SkillNameText.transform.parent.gameObject.SetActive(false);
  575. }
  576. }
  577. if (cardPositionText != null)
  578. {
  579. cardPositionText.transform.parent.gameObject.SetActive(false);
  580. }
  581. if (GManager.instance != null)
  582. {
  583. if (GManager.instance.You.HandCardObjects.Contains(this) || !GManager.instance.turnStateMachine.DoneStartGame)
  584. {
  585. ShowPlayCost();
  586. }
  587. }
  588. //カード画像
  589. CardImage.sprite = await cardSource.GetCardSprite();
  590. }
  591. void ShowPlayCost()
  592. {
  593. if (CostText != null)
  594. {
  595. List<CardColor> cardColors = cardSource.IsDualCard ? cardSource.DualCardColors : cardSource.CardColors;
  596. for (int i = CostIcons.Count - 1; i > -1; i--)
  597. {
  598. CardColor cardColor = CardColor.None;
  599. int value = CostIcons.Count - i - 1;
  600. if (i >= CostIcons.Count - cardColors.Count)
  601. {
  602. float fillAmount = (float)((CostIcons.Count - i) / (float)cardColors.Count);
  603. cardColor = cardColors[value];
  604. CostIcons[i].color = DataBase.CardColor_ColorDarkDictionary[cardColor];
  605. CostIcons[i].fillAmount = fillAmount;
  606. CostIcons[i].gameObject.SetActive(true);
  607. }
  608. else
  609. {
  610. CostIcons[i].gameObject.SetActive(false);
  611. }
  612. }
  613. CostText.color = Color.white;
  614. CostText.transform.parent.gameObject.SetActive(true);
  615. CostText.text = $"{cardSource.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false)}";
  616. }
  617. }
  618. public void ShowCostLevel()
  619. {
  620. ShowPlayCost();
  621. if (LevelIcons != null)
  622. {
  623. if (LevelText != null)
  624. {
  625. if (LevelText.transform.parent != null)
  626. {
  627. if (cardSource.IsDigimon && cardSource.HasLevel)
  628. {
  629. if (LevelIcons.Count >= 1)
  630. {
  631. for (int i = 0; i < LevelIcons.Count; i++)
  632. {
  633. CardColor cardColor = CardColor.None;
  634. if (i < cardSource.CardColors.Count)
  635. {
  636. cardColor = cardSource.CardColors[i];
  637. LevelIcons[i].color = DataBase.CardColor_ColorDarkDictionary[cardColor];
  638. LevelIcons[i].gameObject.SetActive(true);
  639. }
  640. else
  641. {
  642. LevelIcons[i].gameObject.SetActive(false);
  643. }
  644. }
  645. LevelText.color = Color.white;
  646. LevelText.transform.parent.gameObject.SetActive(true);
  647. LevelText.text = $"Lv.{cardSource.Level}";
  648. }
  649. }
  650. else
  651. {
  652. LevelText.transform.parent.gameObject.SetActive(false);
  653. }
  654. }
  655. }
  656. }
  657. if (EvoCostIcons != null)
  658. {
  659. if (cardSource.IsDigimon)
  660. {
  661. if (EvoCostIcons.Count >= 1)
  662. {
  663. for (int i = 0; i < EvoCostIcons.Count; i++)
  664. {
  665. if (i < cardSource.BaseEvoCostsFromEntity.Count)
  666. {
  667. EvoCostIcons[i].sprite = WhiteCircle;
  668. EvoCostIcons[i].transform.parent.gameObject.SetActive(true);
  669. EvoCostIcons[i].gameObject.SetActive(true);
  670. CardColor cardColor = CardColor.None;
  671. cardColor = cardSource.BaseEvoCostsFromEntity[i].CardColor;
  672. EvoCostIcons[i].color = DataBase.CardColor_ColorDarkDictionary[cardColor];
  673. EvoCostTexts_Level[i].text = $"Lv.{cardSource.BaseEvoCostsFromEntity[i].Level}";
  674. EvoCostTexts_Memory[i].text = $"{cardSource.BaseEvoCostsFromEntity[i].MemoryCost}";
  675. if (cardColor == CardColor.Yellow || cardColor == CardColor.White)
  676. {
  677. EvoCostTexts_Level[i].color = Color.black;
  678. EvoCostTexts_Memory[i].color = Color.black;
  679. }
  680. else
  681. {
  682. EvoCostTexts_Level[i].color = Color.white;
  683. EvoCostTexts_Memory[i].color = Color.white;
  684. }
  685. }
  686. else
  687. {
  688. EvoCostIcons[i].transform.parent.gameObject.SetActive(false);
  689. }
  690. }
  691. if (cardSource.BaseEvoCostsFromEntity.Count == 7)
  692. {
  693. int cost = cardSource.BaseEvoCostsFromEntity[0].MemoryCost;
  694. int level = cardSource.BaseEvoCostsFromEntity[0].Level;
  695. bool sameCost = true;
  696. for (int i = 0; i < cardSource.BaseEvoCostsFromEntity.Count; i++)
  697. {
  698. if (cardSource.BaseEvoCostsFromEntity[i].MemoryCost != cost || cardSource.BaseEvoCostsFromEntity[i].Level != level)
  699. {
  700. sameCost = false;
  701. break;
  702. }
  703. }
  704. if (sameCost)
  705. {
  706. for (int i = 0; i < EvoCostIcons.Count; i++)
  707. {
  708. EvoCostIcons[i].transform.parent.gameObject.SetActive(false);
  709. if (i == 0)
  710. {
  711. EvoCostIcons[i].sprite = RainbowCircle;
  712. EvoCostIcons[i].transform.parent.gameObject.SetActive(true);
  713. EvoCostIcons[i].color = Color.white;
  714. EvoCostTexts_Level[i].text = $"Lv.{cardSource.BaseEvoCostsFromEntity[i].Level}";
  715. EvoCostTexts_Memory[i].text = $"{cardSource.BaseEvoCostsFromEntity[i].MemoryCost}";
  716. EvoCostTexts_Level[i].color = Color.white;
  717. EvoCostTexts_Memory[i].color = Color.white;
  718. }
  719. }
  720. }
  721. }
  722. }
  723. }
  724. else
  725. {
  726. for (int i = 0; i < EvoCostIcons.Count; i++)
  727. {
  728. EvoCostIcons[i].transform.parent.gameObject.SetActive(false);
  729. }
  730. }
  731. }
  732. }
  733. public void AddClickTarget(UnityAction<HandCard> _OnClickAction)
  734. {
  735. OnClickAction = _OnClickAction;
  736. OnSelect();
  737. }
  738. public void RemoveOnClickAction()
  739. {
  740. OnClickAction = null;
  741. }
  742. public void RemoveClickTarget()
  743. {
  744. RemoveOnClickAction();
  745. RemoveSelectEffect();
  746. }
  747. public void AddDragTarget(UnityAction<HandCard> _BeginDragAction, UnityAction<List<DropArea>> _OnDropAction, UnityAction<List<DropArea>> _OnDragAction)
  748. {
  749. BeginDragAction = _BeginDragAction;
  750. EndDragAction = _OnDropAction;
  751. OnDragAction = _OnDragAction;
  752. CanDrag = true;
  753. OnSelect();
  754. }
  755. public void RemoveDragTarget()
  756. {
  757. BeginDragAction = null;
  758. EndDragAction = null;
  759. OnDragAction = null;
  760. CanDrag = false;
  761. RemoveSelectEffect();
  762. }
  763. public void PointerClick(BaseEventData eventData)
  764. {
  765. #region right click
  766. if (Input.GetMouseButtonUp(1))
  767. {
  768. OnRightClicked();
  769. }
  770. #endregion
  771. #region left click
  772. else if (Input.GetMouseButtonUp(0))
  773. {
  774. OnClickAction?.Invoke(this);
  775. }
  776. #endregion
  777. }
  778. #region 右クリック
  779. void OnRightClicked()
  780. {
  781. if (transform.parent.GetComponent<HandContoller>() != null)
  782. {
  783. if (transform.parent.GetComponent<HandContoller>().isDragging)
  784. {
  785. return;
  786. }
  787. }
  788. if (cardSource != null)
  789. {
  790. bool CanLook = false;
  791. if (!GManager.instance.Opponent.HandCardObjects.Contains(this))
  792. {
  793. if (!cardSource.IsFlipped)
  794. {
  795. CanLook = true;
  796. }
  797. else
  798. {
  799. if (cardSource.Owner.isYou)
  800. {
  801. if (cardSource.Owner.LostCards.Contains(cardSource))
  802. {
  803. CanLook = true;
  804. }
  805. }
  806. }
  807. }
  808. if (ShowOpponent)
  809. {
  810. CanLook = true;
  811. }
  812. if (CanLook)
  813. {
  814. //Debug.Log($"OnClickHandCard_{cardSource.BaseCardNameFromEntity}, parent:{transform.parent.gameObject.name}, gameObject:{this.gameObject.name}");
  815. GManager.instance.cardDetail.OpenCardDetail(cardSource, true);
  816. if (GManager.instance != null)
  817. {
  818. GManager.instance.PlayDecisionSE();
  819. }
  820. }
  821. }
  822. }
  823. #endregion
  824. [Header("selected-sequence-index text")]
  825. public Text SelectedIndexText;
  826. public void OffSelectedIndexText()
  827. {
  828. if (SelectedIndexText != null)
  829. {
  830. SelectedIndexText.transform.parent.gameObject.SetActive(false);
  831. }
  832. }
  833. public void SetSelectedIndexText(int index)
  834. {
  835. if (SelectedIndexText != null)
  836. {
  837. SelectedIndexText.transform.parent.gameObject.SetActive(true);
  838. SelectedIndexText.text = $"{index}";
  839. }
  840. }
  841. }