FieldPermanentCard.cs 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  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. }
  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. if (ThisPermanent.TopCard.IsFlipped)
  354. {
  355. DPText.transform.parent.gameObject.SetActive(false);
  356. LevelText.transform.parent.gameObject.SetActive(false);
  357. EvoRootCountText.transform.parent.gameObject.SetActive(false);
  358. LinkedObject.SetActive(false);
  359. return;
  360. }
  361. //DP
  362. if (ThisPermanent.IsDigimon)
  363. {
  364. int DP = ThisPermanent.DP;
  365. if (DP >= 0)
  366. {
  367. DPText.transform.parent.gameObject.SetActive(true);
  368. if (DPText.text != DP.ToString())
  369. DPText.text = DP.ToString();
  370. for (int i = 0; i < DPBackground_color.Count; i++)
  371. {
  372. CardColor cardColor = CardColor.None;
  373. if (i < ThisPermanent.TopCard.CardColors.Count)
  374. {
  375. cardColor = ThisPermanent.TopCard.CardColors[i];
  376. float fillAmount = (float)((i + 1) / (float)ThisPermanent.TopCard.CardColors.Count);
  377. if (DPBackground_color[i].color != DataBase.CardColor_ColorLightDictionary[cardColor])
  378. DPBackground_color[i].color = DataBase.CardColor_ColorLightDictionary[cardColor];
  379. DPBackground_color[i].fillAmount = fillAmount;
  380. DPBackground_color[i].gameObject.SetActive(true);
  381. }
  382. else
  383. {
  384. DPBackground_color[i].gameObject.SetActive(false);
  385. }
  386. }
  387. }
  388. else
  389. {
  390. DPText.transform.parent.gameObject.SetActive(false);
  391. }
  392. }
  393. else
  394. {
  395. DPText.transform.parent.gameObject.SetActive(false);
  396. }
  397. //Level
  398. if (ThisPermanent.IsDigimon && ThisPermanent.TopCard.HasLevel)
  399. {
  400. LevelText.transform.parent.gameObject.SetActive(true);
  401. if(LevelText.text != ThisPermanent.Level.ToString())
  402. LevelText.text = ThisPermanent.Level.ToString();
  403. foreach (TextCardColorMaterial textCardColorMaterial in textCardColorMaterials)
  404. {
  405. if (textCardColorMaterial.cardColor == ThisPermanent.TopCard.CardColors[0])
  406. {
  407. LevelText.fontSharedMaterial = new Material(textCardColorMaterial.material);
  408. break;
  409. }
  410. }
  411. }
  412. else
  413. {
  414. LevelText.transform.parent.gameObject.SetActive(false);
  415. }
  416. //Digivolution Count
  417. if (EvoRootCountText != null)
  418. {
  419. if (ThisPermanent.DigivolutionCards.Count >= 1)
  420. {
  421. EvoRootCountText.transform.parent.gameObject.SetActive(true);
  422. if(EvoRootCountText.text != $"×{ThisPermanent.DigivolutionCards.Count}")
  423. EvoRootCountText.text = $"×{ThisPermanent.DigivolutionCards.Count}";
  424. if(EvoRootCountBackground.color != DataBase.CardColor_ColorLightDictionary[ThisPermanent.TopCard.CardColors[0]])
  425. EvoRootCountBackground.color = DataBase.CardColor_ColorLightDictionary[ThisPermanent.TopCard.CardColors[0]];
  426. }
  427. else
  428. {
  429. EvoRootCountText.transform.parent.gameObject.SetActive(false);
  430. }
  431. }
  432. //Links
  433. if (LinkedObject != null)
  434. {
  435. if (ThisPermanent.LinkedCards.Count > 0)
  436. {
  437. LinkedObject.SetActive(true);
  438. //if (LinkedDPText.text != $"+{ThisPermanent.LinkedDP}")
  439. // LinkedDPText.text = $"+{ThisPermanent.LinkedDP}";
  440. if (LinkIcon.color != DataBase.CardColor_ColorLightDictionary[ThisPermanent.TopCard.CardColors[0]])
  441. LinkIcon.color = DataBase.CardColor_ColorLightDictionary[ThisPermanent.TopCard.CardColors[0]];
  442. }
  443. else
  444. {
  445. LinkedObject.SetActive(false);
  446. }
  447. }
  448. //Summoning Sickness
  449. if (SummonSicknessObject != null)
  450. {
  451. bool isActive = false;
  452. if (ThisPermanent.EnterFieldTurnCount == GManager.instance.turnStateMachine.TurnCount)
  453. {
  454. if (GManager.instance.turnStateMachine.gameContext.TurnPlayer == ThisPermanent.TopCard.Owner)
  455. {
  456. if (!ThisPermanent.HasRush)
  457. {
  458. if (ThisPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(ThisPermanent))
  459. {
  460. isActive = true;
  461. }
  462. }
  463. }
  464. }
  465. SummonSicknessObject.SetActive(isActive);
  466. }
  467. //Blocker
  468. if (BlockerEffect != null)
  469. {
  470. bool isActive = false;
  471. if (ThisPermanent.IsDigimon)
  472. {
  473. if (ThisPermanent.HasBlocker)
  474. {
  475. //if (thisPermanent.TopCard.Owner.GetBattleAreaPermanents().Contains(thisPermanent))
  476. {
  477. isActive = true;
  478. }
  479. }
  480. }
  481. BlockerEffect.SetActive(isActive);
  482. }
  483. }
  484. }
  485. #endregion
  486. #region Automatically reflect card data
  487. int _frameCount = 0;
  488. int _updateFrame = 75;
  489. public bool destroyed { get; set; } = false;
  490. public bool skipDestroy { get; set; } = false;
  491. public bool skipUpdate { get; set; } = false;
  492. //TODO: Pretty poor gargage collection, need to optimize - MB
  493. private void LateUpdate()
  494. {
  495. if (skipUpdate)
  496. {
  497. return;
  498. }
  499. #region exception check
  500. if (destroyed)
  501. {
  502. return;
  503. }
  504. if (ThisPermanent == null)
  505. {
  506. return;
  507. }
  508. if (ThisPermanent.TopCard == null)
  509. {
  510. if (!destroyed && !skipDestroy)
  511. {
  512. StartCoroutine(DestroyCoroutine());
  513. return;
  514. }
  515. }
  516. #endregion
  517. //Skill name
  518. if (SkillNameText.transform.parent.gameObject.activeSelf)
  519. {
  520. RotateSkillNameText();
  521. }
  522. if (DirectStrikeText != null)
  523. {
  524. if (ThisPermanent.IsSuspended)
  525. {
  526. DirectStrikeText.transform.parent.parent.transform.localPosition = new Vector2(DirectStrikeText.transform.parent.parent.transform.localPosition.x, 24);
  527. }
  528. else
  529. {
  530. DirectStrikeText.transform.parent.parent.transform.localPosition = new Vector2(DirectStrikeText.transform.parent.parent.transform.localPosition.x, 78);
  531. }
  532. DirectStrikeText.transform.parent.parent.localRotation = Quaternion.Euler(0, 0, -1 * this.transform.localRotation.eulerAngles.z);
  533. }
  534. if (ThisPermanent.TopCard.Owner.GetFieldPermanents().Count >= ThisPermanent.TopCard.Owner.fieldCardFrames.Count * 0.7f)
  535. {
  536. _updateFrame = 115;
  537. }
  538. else
  539. {
  540. _updateFrame = 75;
  541. }
  542. #region Get long press
  543. #if !UNITY_EDITOR && UNITY_ANDROID
  544. if (pressing)
  545. {
  546. if(requiredTime < Time.time)
  547. {
  548. OnRightClicked();
  549. pressing = false;
  550. }
  551. }
  552. #endif
  553. #endregion
  554. #region Reflected only once every few frames
  555. _frameCount++;
  556. if (_frameCount < _updateFrame)
  557. {
  558. return;
  559. }
  560. else
  561. {
  562. _frameCount = 0;
  563. }
  564. #endregion
  565. ShowPermanentData(true);
  566. }
  567. #endregion
  568. public void PointerDown(BaseEventData eventData)
  569. {
  570. if (!_pressing)
  571. {
  572. _pressing = true;
  573. _requiredTime = Time.time + _validPressTime;
  574. }
  575. else
  576. {
  577. _pressing = false;
  578. }
  579. }
  580. public void PointerUp(BaseEventData eventData)
  581. {
  582. if (_pressing)
  583. {
  584. _pressing = false;
  585. }
  586. }
  587. public void PointerExit(BaseEventData eventData)
  588. {
  589. if (_pressing)
  590. {
  591. _pressing = false;
  592. }
  593. }
  594. #region このオブジェクトを削除
  595. IEnumerator DestroyCoroutine()
  596. {
  597. yield return null;
  598. destroyed = true;
  599. Destroy(this.gameObject);
  600. }
  601. #endregion
  602. #region 選択状態
  603. public bool isExpand { get; set; }
  604. #region 選択状態
  605. public void OnSelectEffect(float expand)
  606. {
  607. if (isExpand)
  608. {
  609. return;
  610. }
  611. Outline_Select.gameObject.SetActive(true);
  612. if (this.gameObject.activeSelf)
  613. {
  614. StartCoroutine(ExpandCoroutine(expand));
  615. }
  616. isExpand = true;
  617. SetOrangeOutline();
  618. }
  619. #endregion
  620. #region オレンジアウトライン
  621. public void SetOrangeOutline()
  622. {
  623. Outline_Select.color = DataBase.SelectColor_Orange;
  624. }
  625. #endregion
  626. #region ブルーアウトライン
  627. public void SetBlueOutline()
  628. {
  629. Outline_Select.color = DataBase.SelectColor_Blue;
  630. }
  631. #endregion
  632. #region 大きくする
  633. IEnumerator ExpandCoroutine(float expand)
  634. {
  635. float ExpandTime = 0.06f;
  636. float targetScale = StartScale.x * expand;
  637. float expandSpeed = (targetScale - transform.localScale.x) / ExpandTime;
  638. while (transform.localScale.x < targetScale)
  639. {
  640. transform.localScale += new Vector3(expandSpeed * Time.deltaTime, expandSpeed * Time.deltaTime, 0);
  641. yield return new WaitForSeconds(Time.deltaTime);
  642. if (!isExpand)
  643. {
  644. transform.localScale = StartScale;
  645. yield break;
  646. }
  647. }
  648. transform.localScale = new Vector3(targetScale, targetScale, 1);
  649. if (!isExpand)
  650. {
  651. transform.localScale = StartScale;
  652. yield break;
  653. }
  654. }
  655. #endregion
  656. #region 選択状態リセット
  657. public void RemoveSelectEffect()
  658. {
  659. Outline_Select.gameObject.SetActive(false);
  660. if (!isExpand)
  661. {
  662. return;
  663. }
  664. transform.localScale = StartScale;
  665. isExpand = false;
  666. }
  667. #endregion
  668. #endregion
  669. #region キャンバス座標への変換
  670. public Vector3 GetLocalCanvasPosition()
  671. {
  672. return this.transform.localPosition + this.transform.parent.localPosition;
  673. }
  674. #endregion
  675. #region コマンドパネルを閉じる
  676. public void CloseCommandPanel()
  677. {
  678. if (fieldUnitCommandPanel != null)
  679. {
  680. fieldUnitCommandPanel.CloseCommandPanel();
  681. }
  682. }
  683. #endregion
  684. #region ドラッグ
  685. public UnityAction<FieldPermanentCard> OnBeginDragAction { get; set; }
  686. public UnityAction<FieldPermanentCard, List<DropArea>> OnDragAction { get; set; }
  687. public UnityAction<FieldPermanentCard, List<DropArea>> OnEndDragAction { get; set; }
  688. public void RemoveDragTarget()
  689. {
  690. this.OnBeginDragAction = null;
  691. this.OnDragAction = null;
  692. this.OnEndDragAction = null;
  693. }
  694. public void AddDragTarget(UnityAction<FieldPermanentCard> OnBeginDragAction, UnityAction<FieldPermanentCard, List<DropArea>> OnDragAction, UnityAction<FieldPermanentCard, List<DropArea>> OnEndDragAction)
  695. {
  696. this.OnBeginDragAction = OnBeginDragAction;
  697. this.OnDragAction = OnDragAction;
  698. this.OnEndDragAction = OnEndDragAction;
  699. }
  700. public void OnBeginDrag()
  701. {
  702. OnBeginDragAction?.Invoke(this);
  703. }
  704. public void OnDrag()
  705. {
  706. OnDragAction?.Invoke(this, Draggable.GetRaycastArea());
  707. }
  708. public void OnEndDrag()
  709. {
  710. OnEndDragAction?.Invoke(this, Draggable.GetRaycastArea());
  711. }
  712. #endregion
  713. }
  714. [System.Serializable]
  715. public class TextCardColorMaterial
  716. {
  717. public CardColor cardColor;
  718. public Material material;
  719. }