FieldPermanentCard.cs 24 KB

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