Player.cs 50 KB

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