FieldPermanentCard.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using UnityEngine.UI;
  6. using DG.Tweening;
  7. using UnityEngine.EventSystems;
  8. using TMPro;
  9. using System;
  10. using System.Diagnostics;
  11. public class FieldPermanentCard : MonoBehaviour
  12. {
  13. [Header("選択状態アウトライン")]
  14. public Image Outline_Select;
  15. [Header("カード画像")]
  16. public Image CardImage;
  17. [Header("ブロッカーエフェクト")]
  18. public GameObject BlockerEffect;
  19. [Header("エナジー個数Text")]
  20. public Text EnergyCountText;
  21. [Header("コライダー")]
  22. public GameObject Collider;
  23. [Header("アニメーター")]
  24. public Animator anim;
  25. [Header("コマンドパネル")]
  26. public CommandPanel fieldUnitCommandPanel;
  27. [Header("スキル名Text")]
  28. public Text SkillNameText;
  29. [Header("DPテキスト")]
  30. public Text DPText;
  31. [Header("DP枠")]
  32. public List<Image> DPBackground_color = new List<Image>();
  33. [Header("進化元枚テキスト")]
  34. public Text EvoRootCountText;
  35. [Header("進化元枚枠")]
  36. public Image EvoRootCountBackground;
  37. [Header("レベルテキスト")]
  38. public TextMeshProUGUI LevelText;
  39. [Header("Linked Text")]
  40. public Text LinkedDPText;
  41. [Header("表示親")]
  42. public GameObject Parent;
  43. [Header("スキル使用エフェクト")]
  44. public GameObject UsingSkillEffect;
  45. [Header("進化元追加エフェクト")]
  46. public ParticleSystem addDigivolutionCardsEffect;
  47. //初期スケール
  48. public Vector3 StartScale { get; set; }
  49. [Header("パーマネント番号テキスト")]
  50. public TextMeshProUGUI permanentIndexText;
  51. [Header("タップオブジェクト")]
  52. public GameObject TapObject;
  53. [Header("ダメージテキスト")]
  54. public Text DirectStrikeText;
  55. [Header("召喚酔い")]
  56. public GameObject SummonSicknessObject;
  57. [Header("進化予定オブジェクト")]
  58. public GameObject WillEvolutionObject;
  59. [Header("消滅予定オブジェクト")]
  60. public GameObject WillBeDeletedObject;
  61. [Header("デッキバウンス予定オブジェクト")]
  62. public GameObject WillBeDeckBounceObject;
  63. [Header("手札バウンス予定オブジェクト")]
  64. public GameObject WillBeHandBounceObject;
  65. [Header("場を離れる予定オブジェクト")]
  66. public GameObject WillRemoveFieldObject;
  67. [Header("アンタップ予定オブジェクト")]
  68. public GameObject WillUntapObject;
  69. public List<TextCardColorMaterial> textCardColorMaterials = new List<TextCardColorMaterial>();
  70. public UnityAction<FieldPermanentCard> OnClickAction;
  71. public Permanent ThisPermanent { get; set; }
  72. public bool IsEffectPlaying { get; set; }
  73. private void Awake()
  74. {
  75. RemoveSelectEffect();
  76. CloseCommandPanel();
  77. Outline_Select.gameObject.SetActive(false);
  78. OffUsingSkillEffect();
  79. OffSkillName();
  80. if (BlockerEffect != null)
  81. {
  82. BlockerEffect.gameObject.SetActive(false);
  83. }
  84. if (EvoRootCountText != null)
  85. {
  86. EvoRootCountText.transform.parent.gameObject.SetActive(false);
  87. }
  88. if (LinkedDPText != null)
  89. {
  90. LinkedDPText.transform.parent.gameObject.SetActive(false);
  91. }
  92. if (DirectStrikeText != null)
  93. {
  94. DirectStrikeText.transform.parent.parent.gameObject.SetActive(true);
  95. DirectStrikeText.transform.parent.gameObject.SetActive(false);
  96. }
  97. if (SummonSicknessObject != null)
  98. {
  99. SummonSicknessObject.gameObject.SetActive(false);
  100. }
  101. if (WillEvolutionObject != null)
  102. {
  103. WillEvolutionObject.SetActive(false);
  104. }
  105. if (WillBeDeletedObject != null)
  106. {
  107. WillBeDeletedObject.SetActive(false);
  108. }
  109. if (WillBeDeckBounceObject != null)
  110. {
  111. WillBeDeckBounceObject.SetActive(false);
  112. }
  113. if (WillBeHandBounceObject != null)
  114. {
  115. WillBeHandBounceObject.SetActive(false);
  116. }
  117. if (WillRemoveFieldObject != null)
  118. {
  119. WillRemoveFieldObject.SetActive(false);
  120. }
  121. if (WillUntapObject != null)
  122. {
  123. WillUntapObject.SetActive(false);
  124. }
  125. OffPermanentIndexText();
  126. //Events
  127. GManager.OnReverseOpponentsCardsChanged += SetTransformRotation;
  128. GManager.OnCardFlippedChanged += SetCardIsFlipped;
  129. //GManager.OnCardSuspendedChanged += SetCardSuspended;
  130. }
  131. public IEnumerator ShowAddDigivolutionCardEffect()
  132. {
  133. if (addDigivolutionCardsEffect != null)
  134. {
  135. addDigivolutionCardsEffect.gameObject.SetActive(true);
  136. addDigivolutionCardsEffect.Play();
  137. }
  138. yield return new WaitForSeconds(0.1f);
  139. }
  140. public void OffPermanentIndexText()
  141. {
  142. if (permanentIndexText != null)
  143. {
  144. permanentIndexText.transform.parent.gameObject.SetActive(false);
  145. }
  146. }
  147. public void SetPermanentIndexText(List<Permanent> permanents)
  148. {
  149. if (permanentIndexText != null)
  150. {
  151. if (ThisPermanent != null)
  152. {
  153. if (ThisPermanent.TopCard != null)
  154. {
  155. int index = permanents.IndexOf(ThisPermanent) + 1;
  156. permanentIndexText.transform.parent.parent.gameObject.SetActive(true);
  157. permanentIndexText.transform.parent.gameObject.SetActive(true);
  158. permanentIndexText.text = $"{index}";
  159. }
  160. }
  161. }
  162. }
  163. void RotateSkillNameText()
  164. {
  165. SkillNameText.transform.parent.localRotation = Quaternion.Euler(0, 0, -1 * this.transform.localRotation.eulerAngles.z);
  166. }
  167. public void OnSkillName(ICardEffect cardEffect)
  168. {
  169. if (SkillNameText != null && ThisPermanent != null)
  170. {
  171. RotateSkillNameText();
  172. SkillNameText.transform.parent.gameObject.SetActive(true);
  173. SkillNameText.text = cardEffect.EffectName;
  174. }
  175. }
  176. public void OffSkillName()
  177. {
  178. if (SkillNameText != null)
  179. {
  180. SkillNameText.transform.parent.gameObject.SetActive(false);
  181. }
  182. }
  183. public void OffUsingSkillEffect()
  184. {
  185. if (UsingSkillEffect != null)
  186. {
  187. UsingSkillEffect.SetActive(false);
  188. }
  189. }
  190. public void OnUsingSkillEffect()
  191. {
  192. if (UsingSkillEffect != null)
  193. {
  194. UsingSkillEffect.SetActive(true);
  195. }
  196. }
  197. float _validPressTime = 0.5f;
  198. float _requiredTime = 0.0f;
  199. bool _pressing = false;
  200. #region Processing on click
  201. #region Processing when clicked
  202. public void OnClick()
  203. {
  204. if (ThisPermanent != null)
  205. {
  206. if (ThisPermanent.TopCard != null)
  207. {
  208. if (Input.GetMouseButtonUp(0))
  209. {
  210. OnClickAction?.Invoke(this);
  211. }
  212. else if (Input.GetMouseButtonUp(1))
  213. {
  214. OnRightClicked();
  215. }
  216. }
  217. }
  218. }
  219. void OnRightClicked()
  220. {
  221. if (!ThisPermanent.TopCard.IsFlipped || ThisPermanent.TopCard.Owner.isYou)
  222. {
  223. GManager.instance.pokemonDetail.OpenUnitDetail(ThisPermanent);
  224. }
  225. }
  226. #endregion
  227. #region Added processing when clicked
  228. public void AddClickTarget(UnityAction<FieldPermanentCard> _OnClickAction)
  229. {
  230. OnClickAction = _OnClickAction;
  231. }
  232. #endregion
  233. #region Delete the process when clicked
  234. public void RemoveClickTarget()
  235. {
  236. OnClickAction = null;
  237. }
  238. #endregion
  239. #endregion
  240. #region Set permanent data
  241. public void SetPermanentData(Permanent permanent, bool updateIsTapped)
  242. {
  243. ThisPermanent = permanent;
  244. SetTransformRotation();
  245. SetCardIsFlipped();
  246. ShowPermanentData(updateIsTapped);
  247. }
  248. #endregion
  249. #region Reflect permanent data on UI
  250. bool _oldTurnSuspendedCards = false;
  251. void SetTransformRotation()
  252. {
  253. if (ThisPermanent == null)
  254. return;
  255. if (ThisPermanent.TopCard == null)
  256. return;
  257. if (ThisPermanent.TopCard.Owner.isYou)
  258. return;
  259. if (ContinuousController.instance == null)
  260. return;
  261. if (ContinuousController.instance.reverseOpponentsCards)
  262. Parent.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 180));
  263. else
  264. Parent.transform.localRotation = Quaternion.Euler(new Vector3(0, 0, 0));
  265. }
  266. async void SetCardIsFlipped()
  267. {
  268. if (ThisPermanent == null)
  269. return;
  270. if (ThisPermanent.TopCard == null)
  271. return;
  272. if (ContinuousController.instance == null)
  273. return;
  274. if (CardImage == null)
  275. return;
  276. // card image
  277. if (ThisPermanent.TopCard.IsFlipped)
  278. {
  279. if (CardImage.sprite != ContinuousController.instance.ReverseCard)
  280. CardImage.sprite = ContinuousController.instance.ReverseCard;
  281. }
  282. else
  283. {
  284. CardImage.sprite = await ThisPermanent.TopCard.GetCardSprite();
  285. }
  286. CardImage.gameObject.SetActive(true);
  287. }
  288. void SetCardSuspended(bool updateIsTapped)
  289. {
  290. if (ThisPermanent == null)
  291. return;
  292. if (ThisPermanent.TopCard == null)
  293. return;
  294. if (ContinuousController.instance == null)
  295. return;
  296. if (ThisPermanent.IsSuspended)
  297. {
  298. if (TapObject != null)
  299. TapObject.SetActive(true);
  300. if (updateIsTapped)
  301. {
  302. bool turnSuspendedCards = ContinuousController.instance != null && ContinuousController.instance.turnSuspendedCards;
  303. if (anim != null)
  304. {
  305. if (ThisPermanent.OldIsSuspended != ThisPermanent.IsSuspended || _oldTurnSuspendedCards != turnSuspendedCards)
  306. {
  307. ThisPermanent.OldIsSuspended = ThisPermanent.IsSuspended;
  308. _oldTurnSuspendedCards = turnSuspendedCards;
  309. if (turnSuspendedCards)
  310. {
  311. if (anim.GetInteger("Tap") != 1)
  312. anim.SetInteger("Tap", 1);
  313. }
  314. else
  315. {
  316. if (anim.GetInteger("Tap") != -1)
  317. anim.SetInteger("Tap", -1);
  318. }
  319. }
  320. }
  321. }
  322. }
  323. else
  324. {
  325. if (TapObject != null)
  326. TapObject.SetActive(false);
  327. if (ContinuousController.instance != null)
  328. {
  329. if (ContinuousController.instance.turnSuspendedCards)
  330. {
  331. if (ThisPermanent.OldIsSuspended != ThisPermanent.IsSuspended)
  332. {
  333. ThisPermanent.OldIsSuspended = ThisPermanent.IsSuspended;
  334. if (anim != null)
  335. {
  336. if (anim.GetInteger("Tap") != -1)
  337. anim.SetInteger("Tap", -1);
  338. }
  339. }
  340. }
  341. }
  342. }
  343. }
  344. public void ShowPermanentData(bool updateIsTapped)
  345. {
  346. if (ThisPermanent == null)
  347. {
  348. return;
  349. }
  350. if (ThisPermanent.TopCard != null)
  351. {
  352. SetCardSuspended(updateIsTapped);
  353. //DP
  354. if (ThisPermanent.IsDigimon && ThisPermanent.DP >= 0)
  355. {
  356. DPText.transform.parent.gameObject.SetActive(true);
  357. if(DPText.text != ThisPermanent.DP.ToString())
  358. DPText.text = ThisPermanent.DP.ToString();
  359. for (int i = 0; i < DPBackground_color.Count; i++)
  360. {
  361. CardColor cardColor = CardColor.None;
  362. if (i < ThisPermanent.TopCard.CardColors.Count)
  363. {
  364. cardColor = ThisPermanent.TopCard.CardColors[i];
  365. float fillAmount = (float)((i + 1) / (float)ThisPermanent.TopCard.CardColors.Count);
  366. if (DPBackground_color[i].color != DataBase.CardColor_ColorLightDictionary[cardColor])
  367. DPBackground_color[i].color = DataBase.CardColor_ColorLightDictionary[cardColor];
  368. DPBackground_color[i].fillAmount = fillAmount;
  369. DPBackground_color[i].gameObject.SetActive(true);
  370. }
  371. else
  372. {
  373. DPBackground_color[i].gameObject.SetActive(false);
  374. }
  375. }
  376. }
  377. else
  378. {
  379. DPText.transform.parent.gameObject.SetActive(false);
  380. }
  381. //Level
  382. if (ThisPermanent.IsDigimon && ThisPermanent.TopCard.HasLevel)
  383. {
  384. LevelText.transform.parent.gameObject.SetActive(true);
  385. if(LevelText.text != ThisPermanent.Level.ToString())
  386. LevelText.text = ThisPermanent.Level.ToString();
  387. foreach (TextCardColorMaterial textCardColorMaterial in textCardColorMaterials)
  388. {
  389. if (textCardColorMaterial.cardColor == ThisPermanent.TopCard.CardColors[0])
  390. {
  391. LevelText.fontSharedMaterial = new Material(textCardColorMaterial.material);
  392. break;
  393. }
  394. }
  395. }
  396. else
  397. {
  398. LevelText.transform.parent.gameObject.SetActive(false);
  399. }
  400. if (EvoRootCountText != null)
  401. {
  402. if (ThisPermanent.DigivolutionCards.Count >= 1)
  403. {
  404. EvoRootCountText.transform.parent.gameObject.SetActive(true);
  405. if(EvoRootCountText.text != $"×{ThisPermanent.DigivolutionCards.Count}")
  406. EvoRootCountText.text = $"×{ThisPermanent.DigivolutionCards.Count}";
  407. if(EvoRootCountBackground.color != DataBase.CardColor_ColorLightDictionary[ThisPermanent.TopCard.CardColors[0]])
  408. EvoRootCountBackground.color = DataBase.CardColor_ColorLightDictionary[ThisPermanent.TopCard.CardColors[0]];
  409. }
  410. else
  411. {
  412. EvoRootCountText.transform.parent.gameObject.SetActive(false);
  413. }
  414. }
  415. if (LinkedDPText != null)
  416. {
  417. if (ThisPermanent.LinkedCards.Count > 0)
  418. {
  419. LinkedDPText.transform.parent.gameObject.SetActive(true);
  420. if (LinkedDPText.text != $"+{ThisPermanent.LinkedDP}")
  421. LinkedDPText.text = $"+{ThisPermanent.LinkedDP}";
  422. }
  423. else
  424. {
  425. LinkedDPText.transform.parent.gameObject.SetActive(false);
  426. }
  427. }
  428. if (SummonSicknessObject != null)
  429. {
  430. bool isActive = false;
  431. if (ThisPermanent.EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  432. {
  433. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == ThisPermanent.TopCard.Owner)
  434. {
  435. if (!ThisPermanent.HasRush)
  436. {
  437. if (ThisPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(ThisPermanent))
  438. {
  439. isActive = true;
  440. }
  441. }
  442. }
  443. }
  444. SummonSicknessObject.SetActive(isActive);
  445. }
  446. if (BlockerEffect != null)
  447. {
  448. bool isActive = false;
  449. if (ThisPermanent.IsDigimon)
  450. {
  451. if (ThisPermanent.HasBlocker)
  452. {
  453. //if (thisPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(thisPermanent))
  454. {
  455. isActive = true;
  456. }
  457. }
  458. }
  459. BlockerEffect.SetActive(isActive);
  460. }
  461. }
  462. }
  463. #endregion
  464. #region Automatically reflect card data
  465. int _frameCount = 0;
  466. int _updateFrame = 75;
  467. public bool destroyed { get; set; } = false;
  468. public bool skipDestroy { get; set; } = false;
  469. public bool skipUpdate { get; set; } = false;
  470. //TODO: Pretty poor gargage collection, need to optimize - MB
  471. private void LateUpdate()
  472. {
  473. if (skipUpdate)
  474. {
  475. return;
  476. }
  477. #region exception check
  478. if (destroyed)
  479. {
  480. return;
  481. }
  482. if (ThisPermanent == null)
  483. {
  484. return;
  485. }
  486. if (ThisPermanent.TopCard == null)
  487. {
  488. if (!destroyed && !skipDestroy)
  489. {
  490. StartCoroutine(DestroyCoroutine());
  491. return;
  492. }
  493. }
  494. #endregion
  495. //Skill name
  496. if (SkillNameText.transform.parent.gameObject.activeSelf)
  497. {
  498. RotateSkillNameText();
  499. }
  500. if (DirectStrikeText != null)
  501. {
  502. if (ThisPermanent.IsSuspended)
  503. {
  504. DirectStrikeText.transform.parent.parent.transform.localPosition = new Vector2(DirectStrikeText.transform.parent.parent.transform.localPosition.x, 24);
  505. }
  506. else
  507. {
  508. DirectStrikeText.transform.parent.parent.transform.localPosition = new Vector2(DirectStrikeText.transform.parent.parent.transform.localPosition.x, 78);
  509. }
  510. DirectStrikeText.transform.parent.parent.localRotation = Quaternion.Euler(0, 0, -1 * this.transform.localRotation.eulerAngles.z);
  511. }
  512. if (ThisPermanent.TopCard.Owner.GetFieldPermanents().Count >= ThisPermanent.TopCard.Owner.fieldCardFrames.Count * 0.7f)
  513. {
  514. _updateFrame = 115;
  515. }
  516. else
  517. {
  518. _updateFrame = 75;
  519. }
  520. #region Get long press
  521. #if !UNITY_EDITOR && UNITY_ANDROID
  522. if (pressing)
  523. {
  524. if(requiredTime < Time.time)
  525. {
  526. OnRightClicked();
  527. pressing = false;
  528. }
  529. }
  530. #endif
  531. #endregion
  532. #region Reflected only once every few frames
  533. _frameCount++;
  534. if (_frameCount < _updateFrame)
  535. {
  536. return;
  537. }
  538. else
  539. {
  540. _frameCount = 0;
  541. }
  542. #endregion
  543. ShowPermanentData(true);
  544. }
  545. #endregion
  546. public void PointerDown(BaseEventData eventData)
  547. {
  548. if (!_pressing)
  549. {
  550. _pressing = true;
  551. _requiredTime = Time.time + _validPressTime;
  552. }
  553. else
  554. {
  555. _pressing = false;
  556. }
  557. }
  558. public void PointerUp(BaseEventData eventData)
  559. {
  560. if (_pressing)
  561. {
  562. _pressing = false;
  563. }
  564. }
  565. public void PointerExit(BaseEventData eventData)
  566. {
  567. if (_pressing)
  568. {
  569. _pressing = false;
  570. }
  571. }
  572. #region このオブジェクトを削除
  573. IEnumerator DestroyCoroutine()
  574. {
  575. yield return null;
  576. destroyed = true;
  577. Destroy(this.gameObject);
  578. }
  579. #endregion
  580. #region 選択状態
  581. public bool isExpand { get; set; }
  582. #region 選択状態
  583. public void OnSelectEffect(float expand)
  584. {
  585. if (isExpand)
  586. {
  587. return;
  588. }
  589. Outline_Select.gameObject.SetActive(true);
  590. if (this.gameObject.activeSelf)
  591. {
  592. StartCoroutine(ExpandCoroutine(expand));
  593. }
  594. isExpand = true;
  595. SetOrangeOutline();
  596. }
  597. #endregion
  598. #region オレンジアウトライン
  599. public void SetOrangeOutline()
  600. {
  601. Outline_Select.color = DataBase.SelectColor_Orange;
  602. }
  603. #endregion
  604. #region ブルーアウトライン
  605. public void SetBlueOutline()
  606. {
  607. Outline_Select.color = DataBase.SelectColor_Blue;
  608. }
  609. #endregion
  610. #region 大きくする
  611. IEnumerator ExpandCoroutine(float expand)
  612. {
  613. float ExpandTime = 0.06f;
  614. float targetScale = StartScale.x * expand;
  615. float expandSpeed = (targetScale - transform.localScale.x) / ExpandTime;
  616. while (transform.localScale.x < targetScale)
  617. {
  618. transform.localScale += new Vector3(expandSpeed * Time.deltaTime, expandSpeed * Time.deltaTime, 0);
  619. yield return new WaitForSeconds(Time.deltaTime);
  620. if (!isExpand)
  621. {
  622. transform.localScale = StartScale;
  623. yield break;
  624. }
  625. }
  626. transform.localScale = new Vector3(targetScale, targetScale, 1);
  627. if (!isExpand)
  628. {
  629. transform.localScale = StartScale;
  630. yield break;
  631. }
  632. }
  633. #endregion
  634. #region 選択状態リセット
  635. public void RemoveSelectEffect()
  636. {
  637. Outline_Select.gameObject.SetActive(false);
  638. if (!isExpand)
  639. {
  640. return;
  641. }
  642. transform.localScale = StartScale;
  643. isExpand = false;
  644. }
  645. #endregion
  646. #endregion
  647. #region キャンバス座標への変換
  648. public Vector3 GetLocalCanvasPosition()
  649. {
  650. return this.transform.localPosition + this.transform.parent.localPosition;
  651. }
  652. #endregion
  653. #region コマンドパネルを閉じる
  654. public void CloseCommandPanel()
  655. {
  656. if (fieldUnitCommandPanel != null)
  657. {
  658. fieldUnitCommandPanel.CloseCommandPanel();
  659. }
  660. }
  661. #endregion
  662. #region ドラッグ
  663. public UnityAction<FieldPermanentCard> OnBeginDragAction { get; set; }
  664. public UnityAction<FieldPermanentCard, List<DropArea>> OnDragAction { get; set; }
  665. public UnityAction<FieldPermanentCard, List<DropArea>> OnEndDragAction { get; set; }
  666. public void RemoveDragTarget()
  667. {
  668. this.OnBeginDragAction = null;
  669. this.OnDragAction = null;
  670. this.OnEndDragAction = null;
  671. }
  672. public void AddDragTarget(UnityAction<FieldPermanentCard> OnBeginDragAction, UnityAction<FieldPermanentCard, List<DropArea>> OnDragAction, UnityAction<FieldPermanentCard, List<DropArea>> OnEndDragAction)
  673. {
  674. this.OnBeginDragAction = OnBeginDragAction;
  675. this.OnDragAction = OnDragAction;
  676. this.OnEndDragAction = OnEndDragAction;
  677. }
  678. public void OnBeginDrag()
  679. {
  680. OnBeginDragAction?.Invoke(this);
  681. }
  682. public void OnDrag()
  683. {
  684. OnDragAction?.Invoke(this, Draggable.GetRaycastArea());
  685. }
  686. public void OnEndDrag()
  687. {
  688. OnEndDragAction?.Invoke(this, Draggable.GetRaycastArea());
  689. }
  690. #endregion
  691. }
  692. [System.Serializable]
  693. public class TextCardColorMaterial
  694. {
  695. public CardColor cardColor;
  696. public Material material;
  697. }