Player.cs 48 KB

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