Player.cs 49 KB

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