HandCard.cs 26 KB

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