Player.cs 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607
  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> battleAreaPermanents = GetBattleAreaPermanents();
  510. List<Permanent> GetBattleAreaDigimons = new List<Permanent>();
  511. for (int i = 0; i < battleAreaPermanents.Count; i++)
  512. {
  513. if (battleAreaPermanents[i] != null)
  514. {
  515. if (battleAreaPermanents[i].TopCard != null)
  516. {
  517. if (battleAreaPermanents[i].IsDigimon)
  518. {
  519. GetBattleAreaDigimons.Add(battleAreaPermanents[i]);
  520. }
  521. }
  522. }
  523. }
  524. return GetBattleAreaDigimons;
  525. }
  526. #endregion
  527. #region Player Name
  528. private string _playerName = "Opponent";
  529. public string PlayerName {
  530. get {
  531. if (isYou || GManager.instance.IsAI)
  532. return _playerName;
  533. else
  534. return "Opponent";
  535. }
  536. set { _playerName = value; }
  537. }
  538. [Header("プレイヤー名")]
  539. public TextMeshProUGUI PlayerNameText;
  540. #endregion
  541. #region 勝利数
  542. public int WinCount { get; set; }
  543. public void ShowWinCount()
  544. {
  545. //WinCountText.transform.parent.gameObject.SetActive(true);
  546. }
  547. public void HideWinCount()
  548. {
  549. //WinCountText.transform.parent.gameObject.SetActive(false);
  550. }
  551. #endregion
  552. #region PlayerID
  553. public int PlayerID { get; set; }
  554. #endregion
  555. #region Enemy
  556. public Player Enemy
  557. {
  558. get
  559. {
  560. if (GManager.instance != null)
  561. {
  562. if (GManager.instance.turnStateMachine != null)
  563. {
  564. if (GManager.instance.turnStateMachine.gameContext != null)
  565. {
  566. if (GManager.instance.turnStateMachine.gameContext.Players.Contains(this))
  567. {
  568. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players)
  569. {
  570. if (player != this)
  571. {
  572. return player;
  573. }
  574. }
  575. }
  576. }
  577. }
  578. }
  579. return null;
  580. }
  581. }
  582. #endregion
  583. #region プレイマット
  584. [Header("PlayMat")]
  585. public GameObject PlayMat;
  586. #endregion
  587. #region プレイマットの枠
  588. public FieldCardFrame playMatCardFrame;
  589. #endregion
  590. #region 手札のドロップエリア
  591. [Header("手札のドロップエリア")]
  592. public DropArea HandDropArea;
  593. #endregion
  594. #region 場のパーマネントカードオブジェクト
  595. public List<FieldPermanentCard> FieldPermanentObjects
  596. {
  597. get
  598. {
  599. List<FieldPermanentCard> _FieldPermanentObjects = new List<FieldPermanentCard>();
  600. for (int i = 0; i < PermanentTransform.childCount; i++)
  601. {
  602. FieldPermanentCard fieldPermanentCard = PermanentTransform.GetChild(i).GetComponent<FieldPermanentCard>();
  603. if (fieldPermanentCard != null)
  604. {
  605. _FieldPermanentObjects.Add(fieldPermanentCard);
  606. }
  607. }
  608. return _FieldPermanentObjects;
  609. }
  610. }
  611. #endregion
  612. #region 手札のカードオブジェクト
  613. public List<HandCard> HandCardObjects
  614. {
  615. get
  616. {
  617. List<HandCard> _HandCards = new List<HandCard>();
  618. foreach (CardSource cardSource in HandCards)
  619. {
  620. if (cardSource.ShowingHandCard != null)
  621. {
  622. _HandCards.Add(cardSource.ShowingHandCard);
  623. }
  624. }
  625. return _HandCards;
  626. }
  627. }
  628. #endregion
  629. #region プレイヤーに掛かっている効果
  630. #region All effects on the player
  631. public List<ICardEffect> EffectList(EffectTiming timing)
  632. {
  633. List<ICardEffect> PlayerEffects = new List<ICardEffect>();
  634. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in PermanentEffects)
  635. {
  636. if (GetCardEffect(timing) != null)
  637. {
  638. PlayerEffects.Add(GetCardEffect(timing));
  639. }
  640. }
  641. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEndBattleEffects)
  642. {
  643. if (GetCardEffect(timing) != null)
  644. {
  645. PlayerEffects.Add(GetCardEffect(timing));
  646. }
  647. }
  648. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilEachTurnEndEffects)
  649. {
  650. if (GetCardEffect(timing) != null)
  651. {
  652. PlayerEffects.Add(GetCardEffect(timing));
  653. }
  654. }
  655. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerTurnEndEffects)
  656. {
  657. if (GetCardEffect(timing) != null)
  658. {
  659. PlayerEffects.Add(GetCardEffect(timing));
  660. }
  661. }
  662. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOwnerActivePhaseEffects)
  663. {
  664. if (GetCardEffect(timing) != null)
  665. {
  666. PlayerEffects.Add(GetCardEffect(timing));
  667. }
  668. }
  669. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilSecurityCheckEndEffects)
  670. {
  671. if (GetCardEffect(timing) != null)
  672. {
  673. PlayerEffects.Add(GetCardEffect(timing));
  674. }
  675. }
  676. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilOpponentTurnEndEffects)
  677. {
  678. if (GetCardEffect(timing) != null)
  679. {
  680. PlayerEffects.Add(GetCardEffect(timing));
  681. }
  682. }
  683. foreach (Func<EffectTiming, ICardEffect> GetCardEffect in UntilCalculateFixedCostEffect)
  684. {
  685. if (GetCardEffect(timing) != null)
  686. {
  687. PlayerEffects.Add(GetCardEffect(timing));
  688. }
  689. }
  690. foreach (ICardEffect cardEffect in PlayerEffects)
  691. {
  692. if (cardEffect.EffectSourceCard == null)
  693. {
  694. foreach (CardSource cardSource in GManager.instance.turnStateMachine.gameContext.ActiveCardList)
  695. {
  696. if (cardSource.Owner == this && !cardSource.IsToken)
  697. {
  698. cardEffect.SetEffectSourceCard(cardSource);
  699. break;
  700. }
  701. }
  702. }
  703. }
  704. return PlayerEffects;
  705. }
  706. #endregion
  707. #region 消えないプレイヤーに掛かっている効果
  708. public List<Func<EffectTiming, ICardEffect>> PermanentEffects = new List<Func<EffectTiming, ICardEffect>>();
  709. #endregion
  710. #region バトル終了時に消えるプレイヤーに掛かっている効果
  711. public List<Func<EffectTiming, ICardEffect>> UntilEndBattleEffects = new List<Func<EffectTiming, ICardEffect>>();
  712. #endregion
  713. #region お互いのターン終了時に消えるプレイヤーに掛かっている効果
  714. public List<Func<EffectTiming, ICardEffect>> UntilEachTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  715. #endregion
  716. #region 自分のターン終了時に消えるプレイヤーに掛かっている効果
  717. public List<Func<EffectTiming, ICardEffect>> UntilOwnerTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  718. #endregion
  719. #region 自分のアクティブフェイズ終了時に消えるプレイヤーに掛かっている効果
  720. public List<Func<EffectTiming, ICardEffect>> UntilOwnerActivePhaseEffects = new List<Func<EffectTiming, ICardEffect>>();
  721. #endregion
  722. #region 相手のターン終了時に消えるプレイヤーに掛かっている効果
  723. public List<Func<EffectTiming, ICardEffect>> UntilOpponentTurnEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  724. #endregion
  725. #region カード使用後に消えるプレイヤーに掛かっている効果
  726. public List<Func<EffectTiming, ICardEffect>> UntilCalculateFixedCostEffect = new List<Func<EffectTiming, ICardEffect>>();
  727. #endregion
  728. #region セキュリティチェック後に消えるプレイヤーに掛かっている効果
  729. public List<Func<EffectTiming, ICardEffect>> UntilSecurityCheckEndEffects = new List<Func<EffectTiming, ICardEffect>>();
  730. #endregion
  731. #endregion
  732. #region トラッシュのカードオブジェクト
  733. public HandCard TrashHandCard;
  734. #endregion
  735. #region このプレイヤーから見た時のメモリー
  736. public int MemoryForPlayer
  737. {
  738. get
  739. {
  740. int memory = GManager.instance.turnStateMachine.gameContext.Memory;
  741. if (PlayerID == 0)
  742. {
  743. memory *= -1;
  744. }
  745. return memory;
  746. }
  747. }
  748. #endregion
  749. #region メモリーを固定の値にする
  750. public IEnumerator SetFixedMemory(int Memory, ICardEffect cardEffect)
  751. {
  752. if (MemoryForPlayer < Memory)
  753. {
  754. #region メモリーを+出来ないなら処理終了
  755. if (cardEffect != null)
  756. {
  757. if (!CanAddMemory(cardEffect))
  758. {
  759. yield break;
  760. }
  761. }
  762. #endregion
  763. }
  764. if (PlayerID == 0)
  765. {
  766. GManager.instance.turnStateMachine.gameContext.Memory = -1 * Memory;
  767. }
  768. else
  769. {
  770. GManager.instance.turnStateMachine.gameContext.Memory = Memory;
  771. }
  772. if (GManager.instance.turnStateMachine.gameContext.Memory >= 10)
  773. {
  774. GManager.instance.turnStateMachine.gameContext.Memory = 10;
  775. }
  776. else if (GManager.instance.turnStateMachine.gameContext.Memory <= -10)
  777. {
  778. GManager.instance.turnStateMachine.gameContext.Memory = -10;
  779. }
  780. yield return ContinuousController.instance.StartCoroutine(GManager.instance.memoryObject.SetMemory());
  781. }
  782. #endregion
  783. #region Can you increase memory?
  784. public bool CanAddMemory(ICardEffect cardEffect)
  785. {
  786. if (this.MemoryForPlayer >= 10)
  787. {
  788. return false;
  789. }
  790. #region Effects that impair memory
  791. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  792. {
  793. foreach (Permanent permanent in player.GetFieldPermanents())
  794. {
  795. #region Effects of permanents in play
  796. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  797. {
  798. if (cardEffect1 is ICannotAddMemoryEffect)
  799. {
  800. if (cardEffect1.CanUse(null))
  801. {
  802. if (((ICannotAddMemoryEffect)cardEffect1).cannotAddMemory(this, cardEffect))
  803. {
  804. return false;
  805. }
  806. }
  807. }
  808. }
  809. #endregion
  810. }
  811. #region player effect
  812. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  813. {
  814. if (cardEffect1 is ICannotAddMemoryEffect)
  815. {
  816. if (cardEffect1.CanUse(null))
  817. {
  818. if (((ICannotAddMemoryEffect)cardEffect1).cannotAddMemory(this, cardEffect))
  819. {
  820. return false;
  821. }
  822. }
  823. }
  824. }
  825. #endregion
  826. }
  827. #endregion
  828. return true;
  829. }
  830. #endregion
  831. #region メモリーを+する
  832. public IEnumerator AddMemory(int plusMemory, ICardEffect cardEffect)
  833. {
  834. if (plusMemory == 0)
  835. {
  836. yield break;
  837. }
  838. if (plusMemory >= 1)
  839. {
  840. #region メモリーを+出来ないなら処理終了
  841. if (cardEffect != null)
  842. {
  843. if (!CanAddMemory(cardEffect))
  844. {
  845. yield break;
  846. }
  847. }
  848. #endregion
  849. }
  850. if (PlayerID == 0)
  851. {
  852. GManager.instance.turnStateMachine.gameContext.Memory -= plusMemory;
  853. }
  854. else
  855. {
  856. GManager.instance.turnStateMachine.gameContext.Memory += plusMemory;
  857. }
  858. if (GManager.instance.turnStateMachine.gameContext.Memory >= 10)
  859. {
  860. GManager.instance.turnStateMachine.gameContext.Memory = 10;
  861. }
  862. else if (GManager.instance.turnStateMachine.gameContext.Memory <= -10)
  863. {
  864. GManager.instance.turnStateMachine.gameContext.Memory = -10;
  865. }
  866. yield return ContinuousController.instance.StartCoroutine(GManager.instance.memoryObject.SetMemory());
  867. }
  868. #endregion
  869. #region 払えるメモリーコストの上限
  870. public int MaxMemoryCost
  871. {
  872. get
  873. {
  874. int MaxMemoryCost = 0;
  875. if (PlayerID == 0)
  876. {
  877. MaxMemoryCost = Mathf.Abs(10 - GManager.instance.turnStateMachine.gameContext.Memory);
  878. }
  879. else
  880. {
  881. MaxMemoryCost = Mathf.Abs(-10 - GManager.instance.turnStateMachine.gameContext.Memory);
  882. }
  883. return MaxMemoryCost;
  884. }
  885. }
  886. #endregion
  887. #region コスト支払い後のメモリー予測値
  888. public int ExpectedMemory(int memoryCost)
  889. {
  890. int ExpectedMemory = GManager.instance.turnStateMachine.gameContext.Memory;
  891. if (PlayerID == 0)
  892. {
  893. ExpectedMemory += memoryCost;
  894. }
  895. else
  896. {
  897. ExpectedMemory -= memoryCost;
  898. }
  899. return ExpectedMemory;
  900. }
  901. #endregion
  902. #region デジタマを孵化できるか
  903. public bool CanHatch => DigitamaLibraryCards.Count >= 1 && GetBreedingAreaPermanents().Count == 0;
  904. #endregion
  905. #region デジモンを移動できるか
  906. public bool CanMove => GetBreedingAreaPermanents().Count(permanent => permanent.CanMove) >= 1 && fieldCardFrames.Count((frame) => frame.IsEmptyFrame()) >= 1;
  907. #endregion
  908. #region このターンにデジモンを進化させた回数
  909. public int DigivolveCount_ThisTurn { get; set; } = 0;
  910. #endregion
  911. #region 吸収進化でタップできるデジモンの条件(効果可否判定に使用)
  912. public bool CanTapWhenAbsorbEvolution_CheckAvailability(Permanent permanent, ICardEffect cardEffect)
  913. {
  914. if (permanent != null)
  915. {
  916. if (permanent.TopCard != null)
  917. {
  918. if (!permanent.IsSuspended && permanent.CanSuspend)
  919. {
  920. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent))
  921. {
  922. #region 吸収進化でタップできるデジモンの条件を変更させる効果
  923. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  924. {
  925. foreach (Permanent permanent1 in player.GetFieldPermanents())
  926. {
  927. #region 場のパーマネントの効果
  928. foreach (ICardEffect cardEffect1 in permanent1.EffectList(EffectTiming.None))
  929. {
  930. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  931. {
  932. if (cardEffect1.CanUse(null))
  933. {
  934. if (((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  935. {
  936. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  937. {
  938. return true;
  939. }
  940. }
  941. }
  942. }
  943. }
  944. #endregion
  945. }
  946. #region プレイヤーの効果
  947. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  948. {
  949. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  950. {
  951. if (cardEffect1.CanUse(null))
  952. {
  953. if (((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  954. {
  955. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  956. {
  957. return true;
  958. }
  959. }
  960. }
  961. }
  962. }
  963. #endregion
  964. }
  965. #endregion
  966. if (permanent.TopCard.Owner == this)
  967. {
  968. return true;
  969. }
  970. }
  971. }
  972. }
  973. }
  974. return false;
  975. }
  976. #endregion
  977. #region 吸収進化でタップできるデジモンの条件
  978. public bool CanTapWhenAbsorbEvolution(Permanent permanent, ICardEffect cardEffect)
  979. {
  980. if (permanent != null)
  981. {
  982. if (permanent.TopCard != null)
  983. {
  984. if (!permanent.IsSuspended && permanent.CanSuspend)
  985. {
  986. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent))
  987. {
  988. #region 吸収進化でタップできるデジモンの条件を変更させる効果
  989. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  990. {
  991. foreach (Permanent permanent1 in player.GetFieldPermanents())
  992. {
  993. #region 場のパーマネントの効果
  994. foreach (ICardEffect cardEffect1 in permanent1.EffectList(EffectTiming.None))
  995. {
  996. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  997. {
  998. if (cardEffect1.CanUse(null))
  999. {
  1000. if (!((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  1001. {
  1002. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  1003. {
  1004. return true;
  1005. }
  1006. else
  1007. {
  1008. return false;
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. #endregion
  1015. }
  1016. #region プレイヤーの効果
  1017. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1018. {
  1019. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  1020. {
  1021. if (cardEffect1.CanUse(null))
  1022. {
  1023. if (!((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  1024. {
  1025. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  1026. {
  1027. return true;
  1028. }
  1029. else
  1030. {
  1031. return false;
  1032. }
  1033. }
  1034. }
  1035. }
  1036. }
  1037. #endregion
  1038. }
  1039. #endregion
  1040. if (permanent.TopCard.Owner == this)
  1041. {
  1042. return true;
  1043. }
  1044. }
  1045. }
  1046. }
  1047. }
  1048. return false;
  1049. }
  1050. #endregion
  1051. #region コストを減らせるか
  1052. public bool CanReduceCost(List<Permanent> targetPermanents, CardSource cardSource)
  1053. {
  1054. #region コストを減らせなくさせる効果
  1055. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1056. {
  1057. foreach (Permanent permanent in player.GetFieldPermanents())
  1058. {
  1059. #region 場のパーマネントの効果
  1060. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1061. {
  1062. if (cardEffect is ICannotReduceCostEffect)
  1063. {
  1064. if (cardEffect.CanUse(null))
  1065. {
  1066. if (((ICannotReduceCostEffect)cardEffect).CannotReduceCost(this, targetPermanents, cardSource))
  1067. {
  1068. return false;
  1069. }
  1070. }
  1071. }
  1072. }
  1073. #endregion
  1074. }
  1075. #region プレイヤーの効果
  1076. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1077. {
  1078. if (cardEffect is ICannotReduceCostEffect)
  1079. {
  1080. if (cardEffect.CanUse(null))
  1081. {
  1082. if (((ICannotReduceCostEffect)cardEffect).CannotReduceCost(this, targetPermanents, cardSource))
  1083. {
  1084. return false;
  1085. }
  1086. }
  1087. }
  1088. }
  1089. #endregion
  1090. }
  1091. #endregion
  1092. return true;
  1093. }
  1094. #endregion
  1095. #region DP消滅効果の上限
  1096. public int MaxDP_DeleteEffect(int maxDP, ICardEffect cardEffect)
  1097. {
  1098. int _maxDP = maxDP;
  1099. #region DP消滅効果の上限を変更する効果
  1100. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1101. {
  1102. foreach (Permanent permanent in player.GetFieldPermanents())
  1103. {
  1104. #region 場のパーマネントの効果
  1105. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1106. {
  1107. if (cardEffect1 is IChangeDPDeleteEffectMaxDPEffect)
  1108. {
  1109. if (cardEffect1.CanUse(null))
  1110. {
  1111. _maxDP = ((IChangeDPDeleteEffectMaxDPEffect)cardEffect1).GetMaxDP(_maxDP, cardEffect);
  1112. }
  1113. }
  1114. }
  1115. #endregion
  1116. }
  1117. #region プレイヤーの効果
  1118. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1119. {
  1120. if (cardEffect1 is IChangeDPDeleteEffectMaxDPEffect)
  1121. {
  1122. if (cardEffect1.CanUse(null))
  1123. {
  1124. _maxDP = ((IChangeDPDeleteEffectMaxDPEffect)cardEffect1).GetMaxDP(_maxDP, cardEffect);
  1125. }
  1126. }
  1127. }
  1128. #endregion
  1129. }
  1130. #endregion
  1131. return _maxDP;
  1132. }
  1133. #endregion
  1134. #region 進化条件を無視できるか
  1135. public bool CanIgnoreDigivolutionRequirement(Permanent targetPermanent, CardSource cardSource)
  1136. {
  1137. #region 進化条件を無視できなくさせる効果
  1138. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1139. {
  1140. foreach (Permanent permanent in player.GetFieldPermanents())
  1141. {
  1142. #region 場のパーマネントの効果
  1143. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1144. {
  1145. if (cardEffect1 is ICannotIgnoreDigivolutionConditionEffect)
  1146. {
  1147. if (cardEffect1.CanUse(null))
  1148. {
  1149. if (((ICannotIgnoreDigivolutionConditionEffect)cardEffect1).cannotIgnoreDigivolutionCondition(this, targetPermanent, cardSource))
  1150. {
  1151. return false;
  1152. }
  1153. }
  1154. }
  1155. }
  1156. #endregion
  1157. }
  1158. #region Player effect
  1159. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1160. {
  1161. if (cardEffect1 is ICannotIgnoreDigivolutionConditionEffect)
  1162. {
  1163. if (cardEffect1.CanUse(null))
  1164. {
  1165. if (((ICannotIgnoreDigivolutionConditionEffect)cardEffect1).cannotIgnoreDigivolutionCondition(this, targetPermanent, cardSource))
  1166. {
  1167. return false;
  1168. }
  1169. }
  1170. }
  1171. }
  1172. #endregion
  1173. }
  1174. #endregion
  1175. return true;
  1176. }
  1177. #endregion
  1178. #region セキュリティを増やせるか
  1179. public bool CanAddSecurity(ICardEffect cardEffect)
  1180. {
  1181. if (GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  1182. {
  1183. return false;
  1184. }
  1185. #region セキュリティを増やせない効果
  1186. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1187. {
  1188. foreach (Permanent permanent in player.GetFieldPermanents())
  1189. {
  1190. #region 場のパーマネントの効果
  1191. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1192. {
  1193. if (cardEffect1 is ICannotAddSecurityEffect)
  1194. {
  1195. if (cardEffect1.CanUse(null))
  1196. {
  1197. if (((ICannotAddSecurityEffect)cardEffect1).cannotAddSecurity(this, cardEffect))
  1198. {
  1199. return false;
  1200. }
  1201. }
  1202. }
  1203. }
  1204. #endregion
  1205. }
  1206. #region プレイヤーの効果
  1207. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1208. {
  1209. if (cardEffect1 is ICannotAddSecurityEffect)
  1210. {
  1211. if (cardEffect1.CanUse(null))
  1212. {
  1213. if (((ICannotAddSecurityEffect)cardEffect1).cannotAddSecurity(this, cardEffect))
  1214. {
  1215. return false;
  1216. }
  1217. }
  1218. }
  1219. }
  1220. #endregion
  1221. }
  1222. #endregion
  1223. return true;
  1224. }
  1225. #endregion
  1226. #region セキュリティを減らせるか
  1227. public bool CanReduceSecurity()
  1228. {
  1229. if (GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  1230. {
  1231. return false;
  1232. }
  1233. return true;
  1234. }
  1235. #endregion
  1236. }
  1237. [Serializable]
  1238. public class ShowSupplyingEnergyIcon
  1239. {
  1240. public CardColor cardColor;
  1241. public Image SupplyingEnergyIcon;
  1242. public Text SupplyingEnergyText;
  1243. }
  1244. [Serializable]
  1245. public class FieldCardFrame
  1246. {
  1247. [Header("枠")]
  1248. public GameObject Frame;
  1249. [Header("選択状態表示枠")]
  1250. public Image Frame_Select;
  1251. [Header("枠ID")]
  1252. public int FrameID;
  1253. [Header("プレイヤー")]
  1254. public Player player;
  1255. public UnityAction<FieldCardFrame> OnClickAction { get; private set; }
  1256. public static bool isBattleAreaFrameID(int FrameID)
  1257. {
  1258. return 0 <= FrameID && FrameID <= GManager.instance.You.fieldCardFrames.Count - 2;
  1259. }
  1260. public bool IsBattleAreaFrame()
  1261. {
  1262. return isBattleAreaFrameID(this.FrameID);
  1263. }
  1264. public bool isBreedingAreaFrame()
  1265. {
  1266. return !IsBattleAreaFrame();
  1267. }
  1268. Permanent framePermanent = null;
  1269. public void SetFramePermanent(Permanent permanent)
  1270. {
  1271. framePermanent = permanent;
  1272. }
  1273. public Permanent GetFramePermanent()
  1274. {
  1275. /*
  1276. foreach (Permanent permanent in player.GetFieldPermanents())
  1277. {
  1278. if (permanent.PermanentFrame == this)
  1279. {
  1280. return permanent;
  1281. }
  1282. }
  1283. */
  1284. if (framePermanent != null)
  1285. {
  1286. return framePermanent;
  1287. }
  1288. return null;
  1289. }
  1290. public bool IsEmptyFrame()
  1291. {
  1292. return GetFramePermanent() == null;
  1293. }
  1294. public void AddClickTarget(UnityAction<FieldCardFrame> OnClickAction)
  1295. {
  1296. this.OnClickAction = OnClickAction;
  1297. if (Frame != null)
  1298. {
  1299. BoxCollider boxCollider = Frame.GetComponent<BoxCollider>();
  1300. if (boxCollider != null)
  1301. {
  1302. boxCollider.enabled = true;
  1303. }
  1304. }
  1305. }
  1306. public void RemoveClickTarget()
  1307. {
  1308. this.OnClickAction = null;
  1309. if (Frame != null)
  1310. {
  1311. BoxCollider boxCollider = Frame.GetComponent<BoxCollider>();
  1312. if (boxCollider != null)
  1313. {
  1314. boxCollider.enabled = false;
  1315. }
  1316. }
  1317. }
  1318. public void OffFrame_Select()
  1319. {
  1320. if (Frame_Select != null)
  1321. {
  1322. Frame_Select.gameObject.SetActive(false);
  1323. }
  1324. }
  1325. public void OnFrame_Select(Color color)
  1326. {
  1327. if (Frame_Select != null)
  1328. {
  1329. Frame_Select.gameObject.SetActive(true);
  1330. Frame_Select.color = color;
  1331. //Frame_Select.color = new Color(color.r, color.g, color.b, 0);
  1332. }
  1333. }
  1334. public Vector3 GetLocalCanvasPosition()
  1335. {
  1336. Vector3 vector = Frame.transform.localPosition + Frame.transform.parent.localPosition + Frame.transform.parent.parent.localPosition;
  1337. return Frame.transform.localPosition + Frame.transform.parent.localPosition + Frame.transform.parent.parent.localPosition;
  1338. }
  1339. public FieldCardFrame FacingFrame
  1340. {
  1341. get
  1342. {
  1343. if (this.IsBattleAreaFrame())
  1344. {
  1345. return player.fieldCardFrames[this.FrameID + 4];
  1346. }
  1347. else
  1348. {
  1349. return player.fieldCardFrames[this.FrameID - 4];
  1350. }
  1351. return null;
  1352. }
  1353. }
  1354. }