HandCard.cs 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022
  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. Outline_Select.SetActive(true);
  308. }
  309. public void OnSelect()
  310. {
  311. OnOutline();
  312. SetBlueOutline();
  313. }
  314. public void RemoveSelectEffect()
  315. {
  316. Outline_Select.SetActive(false);
  317. OffClickText();
  318. }
  319. public void SetUpHandCard(CardSource _cardSource, bool showCardImage = true)
  320. {
  321. cardSource = _cardSource;
  322. if (CardImage != null)
  323. {
  324. CardImage.gameObject.SetActive(true);
  325. }
  326. if (_cardSource.Owner.isYou && showCardImage)
  327. {
  328. SetUpHandCardImage();
  329. }
  330. else
  331. {
  332. SetUpReverseCard();
  333. }
  334. }
  335. public void SetUpCardPositionText(List<Permanent> permanents)
  336. {
  337. if (cardPositionText != null)
  338. {
  339. if (cardSource != null)
  340. {
  341. string cardPositionString = "";
  342. if (cardSource.PermanentOfThisCard() != null)
  343. {
  344. if (cardSource.Owner.GetFieldPermanents().Contains(cardSource.PermanentOfThisCard()))
  345. {
  346. int index = permanents.IndexOf(cardSource.PermanentOfThisCard()) + 1;
  347. cardPositionString = $"Field:{index}";
  348. }
  349. }
  350. else if (cardSource.Owner.HandCards.Contains(cardSource))
  351. {
  352. cardPositionString = "Hand";
  353. }
  354. else if (CardEffectCommons.IsExistOnTrash(cardSource))
  355. {
  356. cardPositionString = "Trash";
  357. }
  358. else if (cardSource.Owner.LibraryCards.Contains(cardSource))
  359. {
  360. cardPositionString = "Deck";
  361. }
  362. else if (cardSource.Owner.DigitamaLibraryCards.Contains(cardSource))
  363. {
  364. cardPositionString = "Digi - Egg Deck";
  365. }
  366. cardPositionText.transform.parent.gameObject.SetActive(true);
  367. cardPositionText.text = cardPositionString;
  368. }
  369. }
  370. }
  371. public void SetUpReverseCard()
  372. {
  373. CardImage.sprite = ContinuousController.instance.ReverseCard;
  374. OffShowFaceCard();
  375. if (SkillNameText != null)
  376. {
  377. SkillNameText.transform.parent.gameObject.SetActive(false);
  378. }
  379. if (cardPositionText != null)
  380. {
  381. cardPositionText.transform.parent.gameObject.SetActive(false);
  382. }
  383. }
  384. public bool ShowOpponent { get; set; } = false;
  385. bool onYourHand()
  386. {
  387. if (GManager.instance != null)
  388. {
  389. if (GManager.instance.You.HandCardObjects.Contains(this))
  390. {
  391. return true;
  392. }
  393. if (ShowOpponent)
  394. {
  395. return true;
  396. }
  397. if (!GManager.instance.turnStateMachine.DoneStartGame && cardSource.Owner.isYou)
  398. {
  399. return true;
  400. }
  401. }
  402. return false;
  403. }
  404. int _frameCount = 145;
  405. int _updateFrame = 150;
  406. float _validPressTime = 0.5f;
  407. float _requiredTime = 0.0f;
  408. bool _pressing = false;
  409. public bool IsExecuting { get; set; } = false;
  410. bool _firstRaycastTarget = true;
  411. private void Awake()
  412. {
  413. _firstRaycastTarget = CardImage.raycastTarget;
  414. }
  415. private void Update()
  416. {
  417. if (CardImage.color.a <= 0.1f)
  418. {
  419. CardImage.raycastTarget = false;
  420. }
  421. else
  422. {
  423. CardImage.raycastTarget = _firstRaycastTarget;
  424. }
  425. #region exception check
  426. if (cardSource == null)
  427. {
  428. return;
  429. }
  430. #endregion
  431. #region 長押しの取得
  432. #if !UNITY_EDITOR && UNITY_ANDROID
  433. if (pressing)
  434. {
  435. if(requiredTime < Time.time)
  436. {
  437. OnRightClicked();
  438. pressing = false;
  439. }
  440. }
  441. #endif
  442. #endregion
  443. #region Update only once every few frames
  444. _frameCount++;
  445. if (_frameCount < _updateFrame)
  446. {
  447. return;
  448. }
  449. else
  450. {
  451. _frameCount = 0;
  452. }
  453. #endregion
  454. if (onYourHand())
  455. {
  456. SetUpHandCardImage();
  457. }
  458. }
  459. public void SetPlayText(string message, Color color)
  460. {
  461. if (PlayText != null)
  462. {
  463. PlayText.transform.parent.gameObject.SetActive(true);
  464. PlayText.transform.parent.parent.gameObject.SetActive(true);
  465. PlayText.text = message;
  466. PlayText.color = color;
  467. }
  468. }
  469. public void OffPlayText()
  470. {
  471. if (PlayText != null)
  472. {
  473. PlayText.transform.parent.gameObject.SetActive(false);
  474. PlayText.transform.parent.parent.gameObject.SetActive(true);
  475. }
  476. }
  477. public void SetJogressPlayText()
  478. {
  479. if (JogressPlayText != null)
  480. {
  481. JogressPlayText.transform.parent.gameObject.SetActive(true);
  482. JogressPlayText.transform.parent.parent.gameObject.SetActive(true);
  483. }
  484. }
  485. public void OffJogressPlayText()
  486. {
  487. if (BurstPlayText != null)
  488. {
  489. BurstPlayText.transform.parent.gameObject.SetActive(false);
  490. BurstPlayText.transform.parent.parent.gameObject.SetActive(true);
  491. }
  492. if (AppFusionPlayText != null)
  493. {
  494. AppFusionPlayText.transform.parent.gameObject.SetActive(false);
  495. AppFusionPlayText.transform.parent.parent.gameObject.SetActive(true);
  496. }
  497. }
  498. public void SetBurstPlayText()
  499. {
  500. if (BurstPlayText != null)
  501. {
  502. BurstPlayText.transform.parent.gameObject.SetActive(true);
  503. BurstPlayText.transform.parent.parent.gameObject.SetActive(true);
  504. }
  505. }
  506. public void OffBurstPlayText()
  507. {
  508. if (JogressPlayText != null)
  509. {
  510. JogressPlayText.transform.parent.gameObject.SetActive(false);
  511. JogressPlayText.transform.parent.parent.gameObject.SetActive(true);
  512. }
  513. if (AppFusionPlayText != null)
  514. {
  515. AppFusionPlayText.transform.parent.gameObject.SetActive(false);
  516. AppFusionPlayText.transform.parent.parent.gameObject.SetActive(true);
  517. }
  518. }
  519. public void SetAppFusionPlayText()
  520. {
  521. if (AppFusionPlayText != null)
  522. {
  523. AppFusionPlayText.transform.parent.gameObject.SetActive(true);
  524. AppFusionPlayText.transform.parent.parent.gameObject.SetActive(true);
  525. }
  526. }
  527. public void OffAppFusionPlayText()
  528. {
  529. if (JogressPlayText != null)
  530. {
  531. JogressPlayText.transform.parent.gameObject.SetActive(false);
  532. JogressPlayText.transform.parent.parent.gameObject.SetActive(true);
  533. }
  534. if (BurstPlayText != null)
  535. {
  536. BurstPlayText.transform.parent.gameObject.SetActive(false);
  537. BurstPlayText.transform.parent.parent.gameObject.SetActive(true);
  538. }
  539. }
  540. public void PointerDown(BaseEventData eventData)
  541. {
  542. if (!_pressing)
  543. {
  544. _pressing = true;
  545. _requiredTime = Time.time + _validPressTime;
  546. }
  547. else
  548. {
  549. _pressing = false;
  550. }
  551. }
  552. public void PointerUp(BaseEventData eventData)
  553. {
  554. if (_pressing)
  555. {
  556. _pressing = false;
  557. }
  558. }
  559. public void PointerExit(BaseEventData eventData)
  560. {
  561. if (_pressing)
  562. {
  563. _pressing = false;
  564. }
  565. }
  566. public async void SetUpHandCardImage()
  567. {
  568. if (SkillNameText != null)
  569. {
  570. if (!IsExecuting)
  571. {
  572. SkillNameText.transform.parent.gameObject.SetActive(false);
  573. }
  574. }
  575. if (cardPositionText != null)
  576. {
  577. cardPositionText.transform.parent.gameObject.SetActive(false);
  578. }
  579. if (GManager.instance != null)
  580. {
  581. if (GManager.instance.You.HandCardObjects.Contains(this) || !GManager.instance.turnStateMachine.DoneStartGame)
  582. {
  583. ShowPlayCost();
  584. }
  585. }
  586. //カード画像
  587. CardImage.sprite = await cardSource.GetCardSprite();
  588. }
  589. void ShowPlayCost()
  590. {
  591. if (CostText != null)
  592. {
  593. for (int i = CostIcons.Count - 1; i > -1; i--)
  594. {
  595. CardColor cardColor = CardColor.None;
  596. int value = CostIcons.Count - i - 1;
  597. if (i >= CostIcons.Count - cardSource.CardColors.Count)
  598. {
  599. float fillAmount = (float)((CostIcons.Count - i) / (float)cardSource.CardColors.Count);
  600. cardColor = cardSource.CardColors[value];
  601. CostIcons[i].color = DataBase.CardColor_ColorDarkDictionary[cardColor];
  602. CostIcons[i].fillAmount = fillAmount;
  603. CostIcons[i].gameObject.SetActive(true);
  604. }
  605. else
  606. {
  607. CostIcons[i].gameObject.SetActive(false);
  608. }
  609. }
  610. CostText.color = Color.white;
  611. CostText.transform.parent.gameObject.SetActive(true);
  612. CostText.text = $"{cardSource.PayingCost(SelectCardEffect.Root.Hand, null, checkAvailability: false)}";
  613. }
  614. }
  615. public void ShowCostLevel()
  616. {
  617. ShowPlayCost();
  618. if (LevelIcons != null)
  619. {
  620. if (LevelText != null)
  621. {
  622. if (LevelText.transform.parent != null)
  623. {
  624. if (cardSource.IsDigimon && cardSource.HasLevel)
  625. {
  626. if (LevelIcons.Count >= 1)
  627. {
  628. for (int i = 0; i < LevelIcons.Count; i++)
  629. {
  630. CardColor cardColor = CardColor.None;
  631. if (i < cardSource.CardColors.Count)
  632. {
  633. cardColor = cardSource.CardColors[i];
  634. LevelIcons[i].color = DataBase.CardColor_ColorDarkDictionary[cardColor];
  635. LevelIcons[i].gameObject.SetActive(true);
  636. }
  637. else
  638. {
  639. LevelIcons[i].gameObject.SetActive(false);
  640. }
  641. }
  642. LevelText.color = Color.white;
  643. LevelText.transform.parent.gameObject.SetActive(true);
  644. LevelText.text = $"Lv.{cardSource.Level}";
  645. }
  646. }
  647. else
  648. {
  649. LevelText.transform.parent.gameObject.SetActive(false);
  650. }
  651. }
  652. }
  653. }
  654. if (EvoCostIcons != null)
  655. {
  656. if (cardSource.IsDigimon)
  657. {
  658. if (EvoCostIcons.Count >= 1)
  659. {
  660. for (int i = 0; i < EvoCostIcons.Count; i++)
  661. {
  662. if (i < cardSource.BaseEvoCostsFromEntity.Count)
  663. {
  664. EvoCostIcons[i].sprite = WhiteCircle;
  665. EvoCostIcons[i].transform.parent.gameObject.SetActive(true);
  666. EvoCostIcons[i].gameObject.SetActive(true);
  667. CardColor cardColor = CardColor.None;
  668. cardColor = cardSource.BaseEvoCostsFromEntity[i].CardColor;
  669. EvoCostIcons[i].color = DataBase.CardColor_ColorDarkDictionary[cardColor];
  670. EvoCostTexts_Level[i].text = $"Lv.{cardSource.BaseEvoCostsFromEntity[i].Level}";
  671. EvoCostTexts_Memory[i].text = $"{cardSource.BaseEvoCostsFromEntity[i].MemoryCost}";
  672. if (cardColor == CardColor.Yellow || cardColor == CardColor.White)
  673. {
  674. EvoCostTexts_Level[i].color = Color.black;
  675. EvoCostTexts_Memory[i].color = Color.black;
  676. }
  677. else
  678. {
  679. EvoCostTexts_Level[i].color = Color.white;
  680. EvoCostTexts_Memory[i].color = Color.white;
  681. }
  682. }
  683. else
  684. {
  685. EvoCostIcons[i].transform.parent.gameObject.SetActive(false);
  686. }
  687. }
  688. if (cardSource.BaseEvoCostsFromEntity.Count == 7)
  689. {
  690. int cost = cardSource.BaseEvoCostsFromEntity[0].MemoryCost;
  691. int level = cardSource.BaseEvoCostsFromEntity[0].Level;
  692. bool sameCost = true;
  693. for (int i = 0; i < cardSource.BaseEvoCostsFromEntity.Count; i++)
  694. {
  695. if (cardSource.BaseEvoCostsFromEntity[i].MemoryCost != cost || cardSource.BaseEvoCostsFromEntity[i].Level != level)
  696. {
  697. sameCost = false;
  698. break;
  699. }
  700. }
  701. if (sameCost)
  702. {
  703. for (int i = 0; i < EvoCostIcons.Count; i++)
  704. {
  705. EvoCostIcons[i].transform.parent.gameObject.SetActive(false);
  706. if (i == 0)
  707. {
  708. EvoCostIcons[i].sprite = RainbowCircle;
  709. EvoCostIcons[i].transform.parent.gameObject.SetActive(true);
  710. EvoCostIcons[i].color = Color.white;
  711. EvoCostTexts_Level[i].text = $"Lv.{cardSource.BaseEvoCostsFromEntity[i].Level}";
  712. EvoCostTexts_Memory[i].text = $"{cardSource.BaseEvoCostsFromEntity[i].MemoryCost}";
  713. EvoCostTexts_Level[i].color = Color.white;
  714. EvoCostTexts_Memory[i].color = Color.white;
  715. }
  716. }
  717. }
  718. }
  719. }
  720. }
  721. else
  722. {
  723. for (int i = 0; i < EvoCostIcons.Count; i++)
  724. {
  725. EvoCostIcons[i].transform.parent.gameObject.SetActive(false);
  726. }
  727. }
  728. }
  729. }
  730. public void AddClickTarget(UnityAction<HandCard> _OnClickAction)
  731. {
  732. OnClickAction = _OnClickAction;
  733. OnSelect();
  734. }
  735. public void RemoveOnClickAction()
  736. {
  737. OnClickAction = null;
  738. }
  739. public void RemoveClickTarget()
  740. {
  741. RemoveOnClickAction();
  742. RemoveSelectEffect();
  743. }
  744. public void AddDragTarget(UnityAction<HandCard> _BeginDragAction, UnityAction<List<DropArea>> _OnDropAction, UnityAction<List<DropArea>> _OnDragAction)
  745. {
  746. BeginDragAction = _BeginDragAction;
  747. EndDragAction = _OnDropAction;
  748. OnDragAction = _OnDragAction;
  749. CanDrag = true;
  750. OnSelect();
  751. }
  752. public void RemoveDragTarget()
  753. {
  754. BeginDragAction = null;
  755. EndDragAction = null;
  756. OnDragAction = null;
  757. CanDrag = false;
  758. RemoveSelectEffect();
  759. }
  760. public void PointerClick(BaseEventData eventData)
  761. {
  762. #region right click
  763. if (Input.GetMouseButtonUp(1))
  764. {
  765. OnRightClicked();
  766. }
  767. #endregion
  768. #region left click
  769. else if (Input.GetMouseButtonUp(0))
  770. {
  771. OnClickAction?.Invoke(this);
  772. }
  773. #endregion
  774. }
  775. #region 右クリック
  776. void OnRightClicked()
  777. {
  778. if (transform.parent.GetComponent<HandContoller>() != null)
  779. {
  780. if (transform.parent.GetComponent<HandContoller>().isDragging)
  781. {
  782. return;
  783. }
  784. }
  785. if (cardSource != null)
  786. {
  787. bool CanLook = false;
  788. if (!GManager.instance.Opponent.HandCardObjects.Contains(this))
  789. {
  790. if (!cardSource.IsFlipped)
  791. {
  792. CanLook = true;
  793. }
  794. else
  795. {
  796. if (cardSource.Owner.isYou)
  797. {
  798. if (cardSource.Owner.LostCards.Contains(cardSource))
  799. {
  800. CanLook = true;
  801. }
  802. }
  803. }
  804. }
  805. if (ShowOpponent)
  806. {
  807. CanLook = true;
  808. }
  809. if (CanLook)
  810. {
  811. //Debug.Log($"OnClickHandCard_{cardSource.BaseCardNameFromEntity}, parent:{transform.parent.gameObject.name}, gameObject:{this.gameObject.name}");
  812. GManager.instance.cardDetail.OpenCardDetail(cardSource, true);
  813. if (GManager.instance != null)
  814. {
  815. GManager.instance.PlayDecisionSE();
  816. }
  817. }
  818. }
  819. }
  820. #endregion
  821. [Header("selected-sequence-index text")]
  822. public Text SelectedIndexText;
  823. public void OffSelectedIndexText()
  824. {
  825. if (SelectedIndexText != null)
  826. {
  827. SelectedIndexText.transform.parent.gameObject.SetActive(false);
  828. }
  829. }
  830. public void SetSelectedIndexText(int index)
  831. {
  832. if (SelectedIndexText != null)
  833. {
  834. SelectedIndexText.transform.parent.gameObject.SetActive(true);
  835. SelectedIndexText.text = $"{index}";
  836. }
  837. }
  838. }