Player.cs 50 KB

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