Player.cs 48 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595
  1. using DG.Tweening;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using UnityEngine;
  7. using UnityEngine.Events;
  8. using UnityEngine.UI;
  9. using UnityEngine.EventSystems;
  10. using System.Threading.Tasks;
  11. using TMPro;
  12. public class Player : MonoBehaviour
  13. {
  14. #region 初期化
  15. private async void Start()
  16. {
  17. fieldCardFrames = new List<FieldCardFrame>();
  18. if (BattleAreaFrameParent != null && BreedingAreaFrameParent != null)
  19. {
  20. int count = 0;
  21. for (int i = 0; i < BattleAreaFrameParent.childCount; i++)
  22. {
  23. if (BattleAreaFrameParent.GetChild(i).childCount >= 2)
  24. {
  25. FieldCardFrame fieldCardFrame = new FieldCardFrame();
  26. fieldCardFrame.Frame = BattleAreaFrameParent.GetChild(i).GetChild(0).gameObject;
  27. fieldCardFrame.Frame_Select = BattleAreaFrameParent.GetChild(i).GetChild(1).GetComponent<Image>();
  28. fieldCardFrame.FrameID = count;
  29. fieldCardFrame.player = this;
  30. fieldCardFrame.Frame.GetComponent<Image>().color = new Color(0, 0, 0, 0);
  31. fieldCardFrame.Frame_Select.color = new Color(0, 0, 0, 0);
  32. fieldCardFrames.Add(fieldCardFrame);
  33. count++;
  34. }
  35. }
  36. if (BreedingAreaFrameParent.childCount >= 2)
  37. {
  38. FieldCardFrame fieldCardFrame = new FieldCardFrame();
  39. fieldCardFrame.Frame = BreedingAreaFrameParent.GetChild(0).gameObject;
  40. fieldCardFrame.Frame_Select = BreedingAreaFrameParent.GetChild(1).GetComponent<Image>();
  41. fieldCardFrame.FrameID = count;
  42. fieldCardFrame.player = this;
  43. fieldCardFrame.Frame.GetComponent<Image>().color = new Color(0, 0, 0, 0);
  44. fieldCardFrame.Frame_Select.color = new Color(0, 0, 0, 0);
  45. fieldCardFrames.Add(fieldCardFrame);
  46. count++;
  47. }
  48. BattleAreaFrameParent.gameObject.SetActive(true);
  49. BreedingAreaFrameParent.gameObject.SetActive(true);
  50. }
  51. for (int i = 0; i < HandTransform.childCount; i++)
  52. {
  53. Destroy(HandTransform.GetChild(i).gameObject);
  54. }
  55. for (int i = 0; i < PermanentTransform.childCount; i++)
  56. {
  57. Destroy(PermanentTransform.GetChild(i).gameObject);
  58. }
  59. for (int i = 0; i < fieldCardFrames.Count; i++)
  60. {
  61. fieldCardFrames[i].OffFrame_Select();
  62. fieldCardFrames[i].Frame.GetComponent<Image>().color = new Color(0, 0, 0, 0);
  63. fieldCardFrames[i].Frame_Select.color = new Color(0, 0, 0, 0);
  64. }
  65. TrashHandCard.gameObject.SetActive(false);
  66. FieldPermanents = new Permanent[fieldCardFrames.Count];
  67. SetPlayerUI();
  68. await SetOriginalPlayMat();
  69. FirstObject.SetActive(false);
  70. playMatCardFrame.OffFrame_Select();
  71. if (PlayerNameText != null)
  72. {
  73. PlayerNameText.transform.parent.gameObject.SetActive(false);
  74. }
  75. OffHatchObject();
  76. if (HatchObject != null)
  77. {
  78. Image hatchImage = HatchObject.GetComponent<Image>();
  79. if (hatchImage != null)
  80. {
  81. if (ContinuousController.instance != null)
  82. {
  83. hatchImage.sprite = ContinuousController.instance.ReverseCard_Digitama;
  84. }
  85. }
  86. }
  87. if (_handCountText != null)
  88. {
  89. _handCountText.text = "";
  90. }
  91. }
  92. #endregion
  93. public GameObject FirstObject;
  94. public bool IsLose { get; set; } = false;
  95. public Transform playerUIObjectParent;
  96. public void SetLose()
  97. {
  98. IsLose = true;
  99. }
  100. public void OnClickFrame(int FrameID)
  101. {
  102. FieldCardFrame fieldCardFrame = fieldCardFrames[FrameID];
  103. fieldCardFrame.OnClickAction?.Invoke(fieldCardFrame);
  104. }
  105. int _timerCount = 0;
  106. int _updateFrame = 20;
  107. private void Update()
  108. {
  109. #region Update only once every few frames
  110. _timerCount++;
  111. if (_timerCount < _updateFrame)
  112. {
  113. return;
  114. }
  115. else
  116. {
  117. _timerCount = 0;
  118. }
  119. #endregion
  120. SetPlayerUI();
  121. }
  122. public void SetPlayerUI()
  123. {
  124. AlignHand();
  125. SetLibraryCountText();
  126. SetDigitamaLibraryCountText();
  127. securityObject.SetSecurity(this);
  128. ShowTrash();
  129. SetHandCountText();
  130. }
  131. #region セキュリティアタックの座標
  132. public Vector3 SecurityAttackLocalCanvasPosition;
  133. #endregion
  134. #region 処理領域の座標
  135. public Vector3 ExecutingAreaLocalCanvasPosition;
  136. #endregion
  137. #region そのプレイヤーの何ターン目か
  138. public int TurnCount { get; set; } = 0;
  139. #endregion
  140. #region 処理領域表示オブジェクト
  141. public BrainStormObject brainStormObject;
  142. #endregion
  143. #region 山札の枚数表示テキスト
  144. public Text LibraryCountText;
  145. public List<Image> DeckCardImages;
  146. public Text DigitamaLibraryCountText;
  147. public List<Image> DigitamaDeckCardImages;
  148. public EventTrigger HatchObject;
  149. public UnityAction OnClickHatchObjectAction;
  150. [SerializeField] TextMeshProUGUI _handCountText;
  151. public void OnClickHatchObject()
  152. {
  153. OnClickHatchObjectAction?.Invoke();
  154. }
  155. public void OffHatchObject()
  156. {
  157. this.OnClickHatchObjectAction = null;
  158. if (HatchObject != null)
  159. {
  160. HatchObject.gameObject.SetActive(false);
  161. }
  162. }
  163. public void SetUpHatchObject(UnityAction OnClickHatchObjectAction)
  164. {
  165. this.OnClickHatchObjectAction = OnClickHatchObjectAction;
  166. if (HatchObject != null)
  167. {
  168. HatchObject.gameObject.SetActive(true);
  169. Image targetImage = null;
  170. for (int i = 0; i < DigitamaDeckCardImages.Count; i++)
  171. {
  172. if (DigitamaDeckCardImages[i].gameObject.activeSelf)
  173. {
  174. targetImage = DigitamaDeckCardImages[i];
  175. }
  176. }
  177. if (targetImage != null)
  178. {
  179. HatchObject.transform.localPosition = targetImage.transform.localPosition;
  180. }
  181. }
  182. }
  183. void SetHandCountText()
  184. {
  185. if (_handCountText != null)
  186. {
  187. _handCountText.text = $"Hand\n{HandCards.Count}";
  188. }
  189. }
  190. void SetLibraryCountText()
  191. {
  192. LibraryCountText.text = $"{LibraryCards.Count}";
  193. if (LibraryCards.Count == 0)
  194. {
  195. for (int i = 0; i < DeckCardImages.Count; i++)
  196. {
  197. DeckCardImages[i].gameObject.SetActive(false);
  198. }
  199. }
  200. else
  201. {
  202. int count = LibraryCards.Count / 8;
  203. for (int i = 0; i < DeckCardImages.Count; i++)
  204. {
  205. if (i <= count)
  206. {
  207. DeckCardImages[i].gameObject.SetActive(true);
  208. DeckCardImages[i].sprite = ContinuousController.instance.ReverseCard;
  209. }
  210. else
  211. {
  212. DeckCardImages[i].gameObject.SetActive(false);
  213. }
  214. }
  215. }
  216. }
  217. public void SetDigitamaLibraryCountText()
  218. {
  219. DigitamaLibraryCountText.text = $"{DigitamaLibraryCards.Count}";
  220. if (DigitamaLibraryCards.Count == 0)
  221. {
  222. for (int i = 0; i < DigitamaDeckCardImages.Count; i++)
  223. {
  224. DigitamaDeckCardImages[i].gameObject.SetActive(false);
  225. }
  226. }
  227. else
  228. {
  229. int count = DigitamaLibraryCards.Count;
  230. for (int i = 0; i < DigitamaDeckCardImages.Count; i++)
  231. {
  232. if (i < count)
  233. {
  234. DigitamaDeckCardImages[i].gameObject.SetActive(true);
  235. DigitamaDeckCardImages[i].sprite = ContinuousController.instance.ReverseCard_Digitama;
  236. }
  237. else
  238. {
  239. DigitamaDeckCardImages[i].gameObject.SetActive(false);
  240. }
  241. }
  242. }
  243. }
  244. #endregion
  245. #region トラッシュ
  246. [Header("トラッシュ画像")]
  247. public Image TrashCardImage;
  248. [Header("トラッシュ枚数テキスト")]
  249. public Text TrashCountText;
  250. async void ShowTrash()
  251. {
  252. if (TrashCardImage != null)
  253. {
  254. if (TrashCards.Count == 0)
  255. {
  256. TrashCardImage.gameObject.SetActive(false);
  257. }
  258. else
  259. {
  260. TrashCardImage.gameObject.SetActive(true);
  261. TrashCardImage.sprite = await TrashCards[0].GetCardSprite();
  262. if (!isYou)
  263. {
  264. if (ContinuousController.instance != null)
  265. {
  266. Quaternion localRotation = Quaternion.Euler(0, 0, 0);
  267. if (ContinuousController.instance.reverseOpponentsCards)
  268. {
  269. localRotation = Quaternion.Euler(0, 0, 180);
  270. }
  271. TrashCardImage.transform.localRotation = localRotation;
  272. }
  273. }
  274. }
  275. }
  276. if (TrashCountText != null)
  277. {
  278. TrashCountText.text = $"{TrashCards.Count}";
  279. }
  280. }
  281. #endregion
  282. #region シャッフルアニメーション
  283. public IEnumerator ShuffleAnimation()
  284. {
  285. float animTime = 0.03f;
  286. yield return null;
  287. for (int k = 0; k < 3; k++)
  288. {
  289. for (int j = 0; j < 2; j++)
  290. {
  291. for (int i = 0; i < DeckCardImages.Count; i++)
  292. {
  293. float targetY = 0;
  294. if (j % 2 == 0)
  295. {
  296. targetY = 0;
  297. }
  298. else
  299. {
  300. targetY = 30;
  301. }
  302. if (k % 2 == 0)
  303. {
  304. if (i % 2 == 0)
  305. {
  306. targetY *= -1;
  307. }
  308. }
  309. else
  310. {
  311. if (i % 2 == 1)
  312. {
  313. targetY *= -1;
  314. }
  315. }
  316. DeckCardImages[i].transform.DOLocalMoveY(targetY, animTime);
  317. }
  318. yield return new WaitForSeconds(animTime);
  319. }
  320. }
  321. for (int i = 0; i < DeckCardImages.Count; i++)
  322. {
  323. DeckCardImages[i].transform.localPosition = new Vector2(DeckCardImages[i].transform.localPosition.x, DeckCardImages[i].transform.localPosition.x);
  324. }
  325. }
  326. #endregion
  327. #region セキュリティ表示
  328. public SecurityObject securityObject;
  329. #endregion
  330. #region 手札を整列
  331. public void AlignHand()
  332. {
  333. if (isYou)
  334. {
  335. if (GManager.instance != null)
  336. {
  337. if (GManager.instance.turnStateMachine != null)
  338. {
  339. if (GManager.instance.turnStateMachine.DoneStartGame)
  340. {
  341. if (!HandTransform.GetComponent<HandContoller>().isDragging)
  342. {
  343. foreach (CardSource cardSource in HandCards)
  344. {
  345. if (cardSource.ShowingHandCard != null)
  346. {
  347. cardSource.ShowingHandCard.transform.SetParent(HandTransform);
  348. }
  349. }
  350. CardObjectController.AlignHand(this);
  351. }
  352. }
  353. }
  354. }
  355. }
  356. }
  357. #endregion
  358. #region キーカード
  359. public CEntity_Base KeyCard { get; set; }
  360. #endregion
  361. #region カード情報
  362. #region デッキのカード
  363. public List<CardSource> LibraryCards = new List<CardSource>();
  364. #endregion
  365. #region デジタマデッキのカード
  366. public List<CardSource> DigitamaLibraryCards = new List<CardSource>();
  367. #endregion
  368. #region 手札のカード
  369. public List<CardSource> HandCards = new List<CardSource>();
  370. #endregion
  371. #region 場外のカード
  372. public List<CardSource> TrashCards = new List<CardSource>();
  373. #endregion
  374. #region ロストのカード
  375. public List<CardSource> LostCards = new List<CardSource>();
  376. #endregion
  377. #region ライフのカード
  378. public List<CardSource> SecurityCards = new List<CardSource>();
  379. #endregion
  380. #region 処理領域のカード
  381. public List<CardSource> ExecutingCards = new List<CardSource>();
  382. #endregion
  383. #endregion
  384. #region このプレイヤーがあなたかどうか
  385. [Header("このプレイヤーがあなたかどうか")]
  386. public bool isYou;
  387. #endregion
  388. #region CardSource置き場
  389. [Header("CardSource置き場")]
  390. public Transform CardSorcesParent;
  391. #endregion
  392. #region カード配置場所
  393. [Header("パーマネントの配置場所")]
  394. public Transform PermanentTransform;
  395. [Header("手札の配置場所")]
  396. public Transform HandTransform;
  397. #endregion
  398. #region プレイマットSpriteRenderer
  399. public SpriteRenderer PlayMatSpriteRenderer;
  400. public SpriteRenderer PlayMatSpriteRenderer_Original;
  401. public async Task SetOriginalPlayMat()
  402. {
  403. if (PlayMatSpriteRenderer_Original != null)
  404. {
  405. string filiName = "";
  406. if (isYou)
  407. {
  408. filiName = "PlayMat_You";
  409. }
  410. else
  411. {
  412. filiName = "PlayMat_Opponent";
  413. }
  414. Sprite playMatSprite = await StreamingAssetsUtility.GetSprite(filiName);
  415. if (playMatSprite != null)
  416. {
  417. Sprite sprite = playMatSprite;
  418. PlayMatSpriteRenderer_Original.sprite = sprite;
  419. PlayMatSpriteRenderer_Original.gameObject.SetActive(true);
  420. float width = 3045f;
  421. float spriteWidth = sprite.rect.width;
  422. float spriteHeight = sprite.rect.height;
  423. if (spriteWidth == 0)
  424. {
  425. spriteWidth = 0.01f;
  426. }
  427. float scale = width / spriteWidth;
  428. PlayMatSpriteRenderer_Original.transform.localScale = new Vector3(scale, scale, 1);
  429. PlayMatSpriteRenderer_Original.transform.localPosition = new Vector3(-15.2f, -6f, 0);
  430. }
  431. else
  432. {
  433. PlayMatSpriteRenderer_Original.gameObject.SetActive(false);
  434. }
  435. }
  436. }
  437. #endregion
  438. #region 枠
  439. [Header("パーマネント枠")]
  440. public List<FieldCardFrame> fieldCardFrames = new List<FieldCardFrame>();
  441. [Header("バトルエリア枠親")]
  442. [SerializeField] Transform BattleAreaFrameParent;
  443. [Header("育成エリア枠親")]
  444. [SerializeField] Transform BreedingAreaFrameParent;
  445. #endregion
  446. #region 手札領域の幅
  447. [Header("手札領域の幅")]
  448. public float HandWidth;
  449. #endregion
  450. #region バトルエリアのパーマネント
  451. public List<Permanent> GetBattleAreaPermanents()
  452. {
  453. List<Permanent> GetBattleAreaPermanents = new List<Permanent>();
  454. for (int i = 0; i < FieldPermanents.Length; i++)
  455. {
  456. if (FieldCardFrame.isBattleAreaFrameID(i))
  457. {
  458. if (FieldPermanents[i] != null)
  459. {
  460. if (FieldPermanents[i].TopCard != null)
  461. {
  462. GetBattleAreaPermanents.Add(FieldPermanents[i]);
  463. }
  464. }
  465. }
  466. }
  467. return GetBattleAreaPermanents;
  468. }
  469. #endregion
  470. #region 育成エリアのパーマネント
  471. public List<Permanent> GetBreedingAreaPermanents()
  472. {
  473. List<Permanent> GetBreedingAreaPermanents = new List<Permanent>();
  474. for (int i = 0; i < FieldPermanents.Length; i++)
  475. {
  476. if (!FieldCardFrame.isBattleAreaFrameID(i))
  477. {
  478. if (FieldPermanents[i] != null)
  479. {
  480. if (FieldPermanents[i].TopCard != null)
  481. {
  482. GetBreedingAreaPermanents.Add(FieldPermanents[i]);
  483. }
  484. }
  485. }
  486. }
  487. return GetBreedingAreaPermanents;
  488. }
  489. #endregion
  490. #region 場のパーマネント
  491. public Permanent[] FieldPermanents = new Permanent[16];
  492. public List<Permanent> GetFieldPermanents()
  493. {
  494. List<Permanent> GetFieldPermanents = new List<Permanent>();
  495. for (int i = 0; i < FieldPermanents.Length; i++)
  496. {
  497. if (FieldPermanents[i] != null)
  498. {
  499. if (FieldPermanents[i].TopCard != null)
  500. {
  501. GetFieldPermanents.Add(FieldPermanents[i]);
  502. }
  503. }
  504. }
  505. return GetFieldPermanents;
  506. }
  507. public List<Permanent> GetBattleAreaDigimons()
  508. {
  509. List<Permanent> GetBattleAreaDigimons = new List<Permanent>();
  510. for (int i = 0; i < GetBattleAreaPermanents().Count; i++)
  511. {
  512. if (GetBattleAreaPermanents()[i] != null)
  513. {
  514. if (GetBattleAreaPermanents()[i].TopCard != null)
  515. {
  516. if (GetBattleAreaPermanents()[i].IsDigimon)
  517. {
  518. GetBattleAreaDigimons.Add(GetBattleAreaPermanents()[i]);
  519. }
  520. }
  521. }
  522. }
  523. return GetBattleAreaDigimons;
  524. }
  525. #endregion
  526. #region プレイヤー名
  527. public string PlayerName { get; set; }
  528. [Header("プレイヤー名")]
  529. public TextMeshProUGUI PlayerNameText;
  530. #endregion
  531. #region 勝利数
  532. public int WinCount { get; set; }
  533. public void ShowWinCount()
  534. {
  535. //WinCountText.transform.parent.gameObject.SetActive(true);
  536. }
  537. public void HideWinCount()
  538. {
  539. //WinCountText.transform.parent.gameObject.SetActive(false);
  540. }
  541. #endregion
  542. #region PlayerID
  543. public int PlayerID { get; set; }
  544. #endregion
  545. #region Enemy
  546. public Player Enemy
  547. {
  548. get
  549. {
  550. if (GManager.instance != null)
  551. {
  552. if (GManager.instance.turnStateMachine != null)
  553. {
  554. if (GManager.instance.turnStateMachine.gameContext != null)
  555. {
  556. if (GManager.instance.turnStateMachine.gameContext.Players.Contains(this))
  557. {
  558. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  559. {
  560. if (player != this)
  561. {
  562. return player;
  563. }
  564. }
  565. }
  566. }
  567. }
  568. }
  569. return null;
  570. }
  571. }
  572. #endregion
  573. #region プレイマット
  574. [Header("PlayMat")]
  575. public GameObject PlayMat;
  576. #endregion
  577. #region プレイマットの枠
  578. public FieldCardFrame playMatCardFrame;
  579. #endregion
  580. #region 手札のドロップエリア
  581. [Header("手札のドロップエリア")]
  582. public DropArea HandDropArea;
  583. #endregion
  584. #region 場のパーマネントカードオブジェクト
  585. public List<FieldPermanentCard> FieldPermanentObjects
  586. {
  587. get
  588. {
  589. List<FieldPermanentCard> _FieldPermanentObjects = new List<FieldPermanentCard>();
  590. for (int i = 0; i < PermanentTransform.childCount; i++)
  591. {
  592. FieldPermanentCard fieldPermanentCard = PermanentTransform.GetChild(i).GetComponent<FieldPermanentCard>();
  593. if (fieldPermanentCard != null)
  594. {
  595. _FieldPermanentObjects.Add(fieldPermanentCard);
  596. }
  597. }
  598. return _FieldPermanentObjects;
  599. }
  600. }
  601. #endregion
  602. #region 手札のカードオブジェクト
  603. public List<HandCard> HandCardObjects
  604. {
  605. get
  606. {
  607. List<HandCard> _HandCards = new List<HandCard>();
  608. foreach (CardSource cardSource in HandCards)
  609. {
  610. if (cardSource.ShowingHandCard != null)
  611. {
  612. _HandCards.Add(cardSource.ShowingHandCard);
  613. }
  614. }
  615. return _HandCards;
  616. }
  617. }
  618. #endregion
  619. #region プレイヤーに掛かっている効果
  620. #region プレイヤーに掛かっている全ての効果
  621. public List<ICardEffect> EffectList(EffectTiming timing)
  622. {
  623. List<ICardEffect> PlayerEffects = new List<ICardEffect>();
  624. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  625. {
  626. if (GetCardEffect(timing) != null)
  627. {
  628. PlayerEffects.Add(GetCardEffect(timing));
  629. }
  630. }
  631. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  632. {
  633. if (GetCardEffect(timing) != null)
  634. {
  635. PlayerEffects.Add(GetCardEffect(timing));
  636. }
  637. }
  638. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  639. {
  640. if (GetCardEffect(timing) != null)
  641. {
  642. PlayerEffects.Add(GetCardEffect(timing));
  643. }
  644. }
  645. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  646. {
  647. if (GetCardEffect(timing) != null)
  648. {
  649. PlayerEffects.Add(GetCardEffect(timing));
  650. }
  651. }
  652. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerActivePhaseEffects)
  653. {
  654. if (GetCardEffect(timing) != null)
  655. {
  656. PlayerEffects.Add(GetCardEffect(timing));
  657. }
  658. }
  659. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilSecurityCheckEndEffects)
  660. {
  661. if (GetCardEffect(timing) != null)
  662. {
  663. PlayerEffects.Add(GetCardEffect(timing));
  664. }
  665. }
  666. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  667. {
  668. if (GetCardEffect(timing) != null)
  669. {
  670. PlayerEffects.Add(GetCardEffect(timing));
  671. }
  672. }
  673. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilCalculateFixedCostEffect)
  674. {
  675. if (GetCardEffect(timing) != null)
  676. {
  677. PlayerEffects.Add(GetCardEffect(timing));
  678. }
  679. }
  680. foreach (ICardEffect cardEffect in PlayerEffects)
  681. {
  682. if (cardEffect.EffectSourceCard == null)
  683. {
  684. foreach (CardSource cardSource in GManager.instance.turnStateMachine.gameContext.ActiveCardList)
  685. {
  686. if (cardSource.Owner == this && !cardSource.IsToken)
  687. {
  688. cardEffect.SetEffectSourceCard(cardSource);
  689. break;
  690. }
  691. }
  692. }
  693. }
  694. return PlayerEffects;
  695. }
  696. #endregion
  697. #region 消えないプレイヤーに掛かっている効果
  698. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  699. #endregion
  700. #region バトル終了時に消えるプレイヤーに掛かっている効果
  701. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  702. #endregion
  703. #region お互いのターン終了時に消えるプレイヤーに掛かっている効果
  704. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  705. #endregion
  706. #region 自分のターン終了時に消えるプレイヤーに掛かっている効果
  707. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  708. #endregion
  709. #region 自分のアクティブフェイズ終了時に消えるプレイヤーに掛かっている効果
  710. public List<Func<EffectTiming, ICardEffect>> UntilOwnerActivePhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  711. #endregion
  712. #region 相手のターン終了時に消えるプレイヤーに掛かっている効果
  713. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  714. #endregion
  715. #region カード使用後に消えるプレイヤーに掛かっている効果
  716. public List<Func<EffectTiming, ICardEffect>> UntilCalculateFixedCostEffect = new List<Func<EffectTiming, ICardEffect>>();
  717. #endregion
  718. #region セキュリティチェック後に消えるプレイヤーに掛かっている効果
  719. public List<Func<EffectTiming, ICardEffect>> UntilSecurityCheckEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  720. #endregion
  721. #endregion
  722. #region トラッシュのカードオブジェクト
  723. public HandCard TrashHandCard;
  724. #endregion
  725. #region このプレイヤーから見た時のメモリー
  726. public int MemoryForPlayer
  727. {
  728. get
  729. {
  730. int memory = GManager.instance.turnStateMachine.gameContext.Memory;
  731. if (PlayerID == 0)
  732. {
  733. memory *= -1;
  734. }
  735. return memory;
  736. }
  737. }
  738. #endregion
  739. #region メモリーを固定の値にする
  740. public IEnumerator SetFixedMemory(int Memory, ICardEffect cardEffect)
  741. {
  742. if (MemoryForPlayer < Memory)
  743. {
  744. #region メモリーを+出来ないなら処理終了
  745. if (cardEffect != null)
  746. {
  747. if (!CanAddMemory(cardEffect))
  748. {
  749. yield break;
  750. }
  751. }
  752. #endregion
  753. }
  754. if (PlayerID == 0)
  755. {
  756. GManager.instance.turnStateMachine.gameContext.Memory = -1 * Memory;
  757. }
  758. else
  759. {
  760. GManager.instance.turnStateMachine.gameContext.Memory = Memory;
  761. }
  762. if (GManager.instance.turnStateMachine.gameContext.Memory >= 10)
  763. {
  764. GManager.instance.turnStateMachine.gameContext.Memory = 10;
  765. }
  766. else if (GManager.instance.turnStateMachine.gameContext.Memory <= -10)
  767. {
  768. GManager.instance.turnStateMachine.gameContext.Memory = -10;
  769. }
  770. yield return ContinuousController.instance.StartCoroutine(GManager.instance.memoryObject.SetMemory());
  771. }
  772. #endregion
  773. #region メモリーを+出来るか
  774. public bool CanAddMemory(ICardEffect cardEffect)
  775. {
  776. if (this.MemoryForPlayer >= 10)
  777. {
  778. return false;
  779. }
  780. #region メモリーを+出来なくさせるする効果
  781. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  782. {
  783. foreach (Permanent permanent in player.GetFieldPermanents())
  784. {
  785. #region 場のパーマネントの効果
  786. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  787. {
  788. if (cardEffect1 is ICannotAddMemoryEffect)
  789. {
  790. if (cardEffect1.CanUse(null))
  791. {
  792. if (((ICannotAddMemoryEffect)cardEffect1).cannotAddMemory(this, cardEffect))
  793. {
  794. return false;
  795. }
  796. }
  797. }
  798. }
  799. #endregion
  800. }
  801. #region プレイヤーの効果
  802. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  803. {
  804. if (cardEffect1 is ICannotAddMemoryEffect)
  805. {
  806. if (cardEffect1.CanUse(null))
  807. {
  808. if (((ICannotAddMemoryEffect)cardEffect1).cannotAddMemory(this, cardEffect))
  809. {
  810. return false;
  811. }
  812. }
  813. }
  814. }
  815. #endregion
  816. }
  817. #endregion
  818. return true;
  819. }
  820. #endregion
  821. #region メモリーを+する
  822. public IEnumerator AddMemory(int plusMemory, ICardEffect cardEffect)
  823. {
  824. if (plusMemory == 0)
  825. {
  826. yield break;
  827. }
  828. if (plusMemory >= 1)
  829. {
  830. #region メモリーを+出来ないなら処理終了
  831. if (cardEffect != null)
  832. {
  833. if (!CanAddMemory(cardEffect))
  834. {
  835. yield break;
  836. }
  837. }
  838. #endregion
  839. }
  840. if (PlayerID == 0)
  841. {
  842. GManager.instance.turnStateMachine.gameContext.Memory -= plusMemory;
  843. }
  844. else
  845. {
  846. GManager.instance.turnStateMachine.gameContext.Memory += plusMemory;
  847. }
  848. if (GManager.instance.turnStateMachine.gameContext.Memory >= 10)
  849. {
  850. GManager.instance.turnStateMachine.gameContext.Memory = 10;
  851. }
  852. else if (GManager.instance.turnStateMachine.gameContext.Memory <= -10)
  853. {
  854. GManager.instance.turnStateMachine.gameContext.Memory = -10;
  855. }
  856. yield return ContinuousController.instance.StartCoroutine(GManager.instance.memoryObject.SetMemory());
  857. }
  858. #endregion
  859. #region 払えるメモリーコストの上限
  860. public int MaxMemoryCost
  861. {
  862. get
  863. {
  864. int MaxMemoryCost = 0;
  865. if (PlayerID == 0)
  866. {
  867. MaxMemoryCost = Mathf.Abs(10 - GManager.instance.turnStateMachine.gameContext.Memory);
  868. }
  869. else
  870. {
  871. MaxMemoryCost = Mathf.Abs(-10 - GManager.instance.turnStateMachine.gameContext.Memory);
  872. }
  873. return MaxMemoryCost;
  874. }
  875. }
  876. #endregion
  877. #region コスト支払い後のメモリー予測値
  878. public int ExpectedMemory(int memoryCost)
  879. {
  880. int ExpectedMemory = GManager.instance.turnStateMachine.gameContext.Memory;
  881. if (PlayerID == 0)
  882. {
  883. ExpectedMemory += memoryCost;
  884. }
  885. else
  886. {
  887. ExpectedMemory -= memoryCost;
  888. }
  889. return ExpectedMemory;
  890. }
  891. #endregion
  892. #region デジタマを孵化できるか
  893. public bool CanHatch => DigitamaLibraryCards.Count >= 1 && GetBreedingAreaPermanents().Count == 0;
  894. #endregion
  895. #region デジモンを移動できるか
  896. public bool CanMove => GetBreedingAreaPermanents().Count(permanent => permanent.CanMove) >= 1 && fieldCardFrames.Count((frame) => frame.IsEmptyFrame()) >= 1;
  897. #endregion
  898. #region このターンにデジモンを進化させた回数
  899. public int DigivolveCount_ThisTurn { get; set; } = 0;
  900. #endregion
  901. #region 吸収進化でタップできるデジモンの条件(効果可否判定に使用)
  902. public bool CanTapWhenAbsorbEvolution_CheckAvailability(Permanent permanent, ICardEffect cardEffect)
  903. {
  904. if (permanent != null)
  905. {
  906. if (permanent.TopCard != null)
  907. {
  908. if (!permanent.IsSuspended && permanent.CanSuspend)
  909. {
  910. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent))
  911. {
  912. #region 吸収進化でタップできるデジモンの条件を変更させる効果
  913. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  914. {
  915. foreach (Permanent permanent1 in player.GetFieldPermanents())
  916. {
  917. #region 場のパーマネントの効果
  918. foreach (ICardEffect cardEffect1 in permanent1.EffectList(EffectTiming.None))
  919. {
  920. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  921. {
  922. if (cardEffect1.CanUse(null))
  923. {
  924. if (((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  925. {
  926. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  927. {
  928. return true;
  929. }
  930. }
  931. }
  932. }
  933. }
  934. #endregion
  935. }
  936. #region プレイヤーの効果
  937. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  938. {
  939. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  940. {
  941. if (cardEffect1.CanUse(null))
  942. {
  943. if (((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  944. {
  945. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  946. {
  947. return true;
  948. }
  949. }
  950. }
  951. }
  952. }
  953. #endregion
  954. }
  955. #endregion
  956. if (permanent.TopCard.Owner == this)
  957. {
  958. return true;
  959. }
  960. }
  961. }
  962. }
  963. }
  964. return false;
  965. }
  966. #endregion
  967. #region 吸収進化でタップできるデジモンの条件
  968. public bool CanTapWhenAbsorbEvolution(Permanent permanent, ICardEffect cardEffect)
  969. {
  970. if (permanent != null)
  971. {
  972. if (permanent.TopCard != null)
  973. {
  974. if (!permanent.IsSuspended && permanent.CanSuspend)
  975. {
  976. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent))
  977. {
  978. #region 吸収進化でタップできるデジモンの条件を変更させる効果
  979. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  980. {
  981. foreach (Permanent permanent1 in player.GetFieldPermanents())
  982. {
  983. #region 場のパーマネントの効果
  984. foreach (ICardEffect cardEffect1 in permanent1.EffectList(EffectTiming.None))
  985. {
  986. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  987. {
  988. if (cardEffect1.CanUse(null))
  989. {
  990. if (!((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  991. {
  992. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  993. {
  994. return true;
  995. }
  996. else
  997. {
  998. return false;
  999. }
  1000. }
  1001. }
  1002. }
  1003. }
  1004. #endregion
  1005. }
  1006. #region プレイヤーの効果
  1007. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1008. {
  1009. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  1010. {
  1011. if (cardEffect1.CanUse(null))
  1012. {
  1013. if (!((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  1014. {
  1015. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  1016. {
  1017. return true;
  1018. }
  1019. else
  1020. {
  1021. return false;
  1022. }
  1023. }
  1024. }
  1025. }
  1026. }
  1027. #endregion
  1028. }
  1029. #endregion
  1030. if (permanent.TopCard.Owner == this)
  1031. {
  1032. return true;
  1033. }
  1034. }
  1035. }
  1036. }
  1037. }
  1038. return false;
  1039. }
  1040. #endregion
  1041. #region コストを減らせるか
  1042. public bool CanReduceCost(List<Permanent> targetPermanents, CardSource cardSource)
  1043. {
  1044. #region コストを減らせなくさせる効果
  1045. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1046. {
  1047. foreach (Permanent permanent in player.GetFieldPermanents())
  1048. {
  1049. #region 場のパーマネントの効果
  1050. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1051. {
  1052. if (cardEffect is ICannotReduceCostEffect)
  1053. {
  1054. if (cardEffect.CanUse(null))
  1055. {
  1056. if (((ICannotReduceCostEffect)cardEffect).CannotReduceCost(this, targetPermanents, cardSource))
  1057. {
  1058. return false;
  1059. }
  1060. }
  1061. }
  1062. }
  1063. #endregion
  1064. }
  1065. #region プレイヤーの効果
  1066. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1067. {
  1068. if (cardEffect is ICannotReduceCostEffect)
  1069. {
  1070. if (cardEffect.CanUse(null))
  1071. {
  1072. if (((ICannotReduceCostEffect)cardEffect).CannotReduceCost(this, targetPermanents, cardSource))
  1073. {
  1074. return false;
  1075. }
  1076. }
  1077. }
  1078. }
  1079. #endregion
  1080. }
  1081. #endregion
  1082. return true;
  1083. }
  1084. #endregion
  1085. #region DP消滅効果の上限
  1086. public int MaxDP_DeleteEffect(int maxDP, ICardEffect cardEffect)
  1087. {
  1088. int _maxDP = maxDP;
  1089. #region DP消滅効果の上限を変更する効果
  1090. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1091. {
  1092. foreach (Permanent permanent in player.GetFieldPermanents())
  1093. {
  1094. #region 場のパーマネントの効果
  1095. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1096. {
  1097. if (cardEffect1 is IChangeDPDeleteEffectMaxDPEffect)
  1098. {
  1099. if (cardEffect1.CanUse(null))
  1100. {
  1101. _maxDP = ((IChangeDPDeleteEffectMaxDPEffect)cardEffect1).GetMaxDP(_maxDP, cardEffect);
  1102. }
  1103. }
  1104. }
  1105. #endregion
  1106. }
  1107. #region プレイヤーの効果
  1108. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1109. {
  1110. if (cardEffect1 is IChangeDPDeleteEffectMaxDPEffect)
  1111. {
  1112. if (cardEffect1.CanUse(null))
  1113. {
  1114. _maxDP = ((IChangeDPDeleteEffectMaxDPEffect)cardEffect1).GetMaxDP(_maxDP, cardEffect);
  1115. }
  1116. }
  1117. }
  1118. #endregion
  1119. }
  1120. #endregion
  1121. return _maxDP;
  1122. }
  1123. #endregion
  1124. #region 進化条件を無視できるか
  1125. public bool CanIgnoreDigivolutionRequirement(Permanent targetPermanent, CardSource cardSource)
  1126. {
  1127. #region 進化条件を無視できなくさせる効果
  1128. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1129. {
  1130. foreach (Permanent permanent in player.GetFieldPermanents())
  1131. {
  1132. #region 場のパーマネントの効果
  1133. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1134. {
  1135. if (cardEffect1 is ICannotIgnoreDigivolutionConditionEffect)
  1136. {
  1137. if (cardEffect1.CanUse(null))
  1138. {
  1139. if (((ICannotIgnoreDigivolutionConditionEffect)cardEffect1).cannotIgnoreDigivolutionCondition(this, targetPermanent, cardSource))
  1140. {
  1141. return false;
  1142. }
  1143. }
  1144. }
  1145. }
  1146. #endregion
  1147. }
  1148. #region プレイヤーの効果
  1149. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1150. {
  1151. if (cardEffect1 is ICannotIgnoreDigivolutionConditionEffect)
  1152. {
  1153. if (cardEffect1.CanUse(null))
  1154. {
  1155. if (((ICannotIgnoreDigivolutionConditionEffect)cardEffect1).cannotIgnoreDigivolutionCondition(this, targetPermanent, cardSource))
  1156. {
  1157. return false;
  1158. }
  1159. }
  1160. }
  1161. }
  1162. #endregion
  1163. }
  1164. #endregion
  1165. return true;
  1166. }
  1167. #endregion
  1168. #region セキュリティを増やせるか
  1169. public bool CanAddSecurity(ICardEffect cardEffect)
  1170. {
  1171. if (GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  1172. {
  1173. return false;
  1174. }
  1175. #region セキュリティを増やせない効果
  1176. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1177. {
  1178. foreach (Permanent permanent in player.GetFieldPermanents())
  1179. {
  1180. #region 場のパーマネントの効果
  1181. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1182. {
  1183. if (cardEffect1 is ICannotAddSecurityEffect)
  1184. {
  1185. if (cardEffect1.CanUse(null))
  1186. {
  1187. if (((ICannotAddSecurityEffect)cardEffect1).cannotAddSecurity(this, cardEffect))
  1188. {
  1189. return false;
  1190. }
  1191. }
  1192. }
  1193. }
  1194. #endregion
  1195. }
  1196. #region プレイヤーの効果
  1197. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1198. {
  1199. if (cardEffect1 is ICannotAddSecurityEffect)
  1200. {
  1201. if (cardEffect1.CanUse(null))
  1202. {
  1203. if (((ICannotAddSecurityEffect)cardEffect1).cannotAddSecurity(this, cardEffect))
  1204. {
  1205. return false;
  1206. }
  1207. }
  1208. }
  1209. }
  1210. #endregion
  1211. }
  1212. #endregion
  1213. return true;
  1214. }
  1215. #endregion
  1216. #region セキュリティを減らせるか
  1217. public bool CanReduceSecurity()
  1218. {
  1219. if (GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  1220. {
  1221. return false;
  1222. }
  1223. return true;
  1224. }
  1225. #endregion
  1226. }
  1227. [Serializable]
  1228. public class ShowSupplyingEnergyIcon
  1229. {
  1230. public CardColor cardColor;
  1231. public Image SupplyingEnergyIcon;
  1232. public Text SupplyingEnergyText;
  1233. }
  1234. [Serializable]
  1235. public class FieldCardFrame
  1236. {
  1237. [Header("枠")]
  1238. public GameObject Frame;
  1239. [Header("選択状態表示枠")]
  1240. public Image Frame_Select;
  1241. [Header("枠ID")]
  1242. public int FrameID;
  1243. [Header("プレイヤー")]
  1244. public Player player;
  1245. public UnityAction<FieldCardFrame> OnClickAction { get; private set; }
  1246. public static bool isBattleAreaFrameID(int FrameID)
  1247. {
  1248. return 0 <= FrameID && FrameID <= GManager.instance.You.fieldCardFrames.Count - 2;
  1249. }
  1250. public bool IsBattleAreaFrame()
  1251. {
  1252. return isBattleAreaFrameID(this.FrameID);
  1253. }
  1254. public bool isBreedingAreaFrame()
  1255. {
  1256. return !IsBattleAreaFrame();
  1257. }
  1258. Permanent framePermanent = null;
  1259. public void SetFramePermanent(Permanent permanent)
  1260. {
  1261. framePermanent = permanent;
  1262. }
  1263. public Permanent GetFramePermanent()
  1264. {
  1265. /*
  1266. foreach (Permanent permanent in player.GetFieldPermanents())
  1267. {
  1268. if (permanent.PermanentFrame == this)
  1269. {
  1270. return permanent;
  1271. }
  1272. }
  1273. */
  1274. if (framePermanent != null)
  1275. {
  1276. return framePermanent;
  1277. }
  1278. return null;
  1279. }
  1280. public bool IsEmptyFrame()
  1281. {
  1282. return GetFramePermanent() == null;
  1283. }
  1284. public void AddClickTarget(UnityAction<FieldCardFrame> OnClickAction)
  1285. {
  1286. this.OnClickAction = OnClickAction;
  1287. if (Frame != null)
  1288. {
  1289. BoxCollider boxCollider = Frame.GetComponent<BoxCollider>();
  1290. if (boxCollider != null)
  1291. {
  1292. boxCollider.enabled = true;
  1293. }
  1294. }
  1295. }
  1296. public void RemoveClickTarget()
  1297. {
  1298. this.OnClickAction = null;
  1299. if (Frame != null)
  1300. {
  1301. BoxCollider boxCollider = Frame.GetComponent<BoxCollider>();
  1302. if (boxCollider != null)
  1303. {
  1304. boxCollider.enabled = false;
  1305. }
  1306. }
  1307. }
  1308. public void OffFrame_Select()
  1309. {
  1310. if (Frame_Select != null)
  1311. {
  1312. Frame_Select.gameObject.SetActive(false);
  1313. }
  1314. }
  1315. public void OnFrame_Select(Color color)
  1316. {
  1317. if (Frame_Select != null)
  1318. {
  1319. Frame_Select.gameObject.SetActive(true);
  1320. Frame_Select.color = color;
  1321. //Frame_Select.color = new Color(color.r, color.g, color.b, 0);
  1322. }
  1323. }
  1324. public Vector3 GetLocalCanvasPosition()
  1325. {
  1326. Vector3 vector = Frame.transform.localPosition + Frame.transform.parent.localPosition + Frame.transform.parent.parent.localPosition;
  1327. return Frame.transform.localPosition + Frame.transform.parent.localPosition + Frame.transform.parent.parent.localPosition;
  1328. }
  1329. public FieldCardFrame FacingFrame
  1330. {
  1331. get
  1332. {
  1333. if (this.IsBattleAreaFrame())
  1334. {
  1335. return player.fieldCardFrames[this.FrameID + 4];
  1336. }
  1337. else
  1338. {
  1339. return player.fieldCardFrames[this.FrameID - 4];
  1340. }
  1341. return null;
  1342. }
  1343. }
  1344. }