Player.cs 50 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658
  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 トラッシュのカードオブジェクト
  773. public HandCard TrashHandCard;
  774. #endregion
  775. #region このプレイヤーから見た時のメモリー
  776. public int MemoryForPlayer
  777. {
  778. get
  779. {
  780. int memory = GManager.instance.turnStateMachine.gameContext.Memory;
  781. if (PlayerID == 0)
  782. {
  783. memory *= -1;
  784. }
  785. return memory;
  786. }
  787. }
  788. #endregion
  789. #region メモリーを固定の値にする
  790. public IEnumerator SetFixedMemory(int Memory, ICardEffect cardEffect)
  791. {
  792. if (MemoryForPlayer < Memory)
  793. {
  794. #region メモリーを+出来ないなら処理終了
  795. if (cardEffect != null)
  796. {
  797. if (!CanAddMemory(cardEffect))
  798. {
  799. yield break;
  800. }
  801. }
  802. #endregion
  803. }
  804. if (PlayerID == 0)
  805. {
  806. GManager.instance.turnStateMachine.gameContext.Memory = -1 * Memory;
  807. }
  808. else
  809. {
  810. GManager.instance.turnStateMachine.gameContext.Memory = Memory;
  811. }
  812. if (GManager.instance.turnStateMachine.gameContext.Memory >= 10)
  813. {
  814. GManager.instance.turnStateMachine.gameContext.Memory = 10;
  815. }
  816. else if (GManager.instance.turnStateMachine.gameContext.Memory <= -10)
  817. {
  818. GManager.instance.turnStateMachine.gameContext.Memory = -10;
  819. }
  820. yield return ContinuousController.instance.StartCoroutine(GManager.instance.memoryObject.SetMemory());
  821. }
  822. #endregion
  823. #region Can you increase memory?
  824. public bool CanAddMemory(ICardEffect cardEffect)
  825. {
  826. if (this.MemoryForPlayer >= 10)
  827. {
  828. return false;
  829. }
  830. #region Effects that impair memory
  831. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  832. {
  833. foreach (Permanent permanent in player.GetFieldPermanents())
  834. {
  835. #region Effects of permanents in play
  836. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  837. {
  838. if (cardEffect1 is ICannotAddMemoryEffect)
  839. {
  840. if (cardEffect1.CanUse(null))
  841. {
  842. if (((ICannotAddMemoryEffect)cardEffect1).cannotAddMemory(this, cardEffect))
  843. {
  844. return false;
  845. }
  846. }
  847. }
  848. }
  849. #endregion
  850. }
  851. #region player effect
  852. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  853. {
  854. if (cardEffect1 is ICannotAddMemoryEffect)
  855. {
  856. if (cardEffect1.CanUse(null))
  857. {
  858. if (((ICannotAddMemoryEffect)cardEffect1).cannotAddMemory(this, cardEffect))
  859. {
  860. return false;
  861. }
  862. }
  863. }
  864. }
  865. #endregion
  866. }
  867. #endregion
  868. return true;
  869. }
  870. #endregion
  871. #region メモリーを+する
  872. public IEnumerator AddMemory(int plusMemory, ICardEffect cardEffect)
  873. {
  874. if (plusMemory == 0)
  875. {
  876. yield break;
  877. }
  878. if (plusMemory >= 1)
  879. {
  880. #region メモリーを+出来ないなら処理終了
  881. if (cardEffect != null)
  882. {
  883. if (!CanAddMemory(cardEffect))
  884. {
  885. yield break;
  886. }
  887. }
  888. #endregion
  889. }
  890. if (PlayerID == 0)
  891. {
  892. GManager.instance.turnStateMachine.gameContext.Memory -= plusMemory;
  893. }
  894. else
  895. {
  896. GManager.instance.turnStateMachine.gameContext.Memory += plusMemory;
  897. }
  898. if (GManager.instance.turnStateMachine.gameContext.Memory >= 10)
  899. {
  900. GManager.instance.turnStateMachine.gameContext.Memory = 10;
  901. }
  902. else if (GManager.instance.turnStateMachine.gameContext.Memory <= -10)
  903. {
  904. GManager.instance.turnStateMachine.gameContext.Memory = -10;
  905. }
  906. yield return ContinuousController.instance.StartCoroutine(GManager.instance.memoryObject.SetMemory());
  907. }
  908. #endregion
  909. #region 払えるメモリーコストの上限
  910. public int MaxMemoryCost
  911. {
  912. get
  913. {
  914. int MaxMemoryCost = 0;
  915. if (PlayerID == 0)
  916. {
  917. MaxMemoryCost = Mathf.Abs(10 - GManager.instance.turnStateMachine.gameContext.Memory);
  918. }
  919. else
  920. {
  921. MaxMemoryCost = Mathf.Abs(-10 - GManager.instance.turnStateMachine.gameContext.Memory);
  922. }
  923. return MaxMemoryCost;
  924. }
  925. }
  926. #endregion
  927. #region コスト支払い後のメモリー予測値
  928. public int ExpectedMemory(int memoryCost)
  929. {
  930. int ExpectedMemory = GManager.instance.turnStateMachine.gameContext.Memory;
  931. if (PlayerID == 0)
  932. {
  933. ExpectedMemory += memoryCost;
  934. }
  935. else
  936. {
  937. ExpectedMemory -= memoryCost;
  938. }
  939. return ExpectedMemory;
  940. }
  941. #endregion
  942. #region デジタマを孵化できるか
  943. public bool CanHatch => DigitamaLibraryCards.Count >= 1 && GetBreedingAreaPermanents().Count == 0;
  944. #endregion
  945. #region デジモンを移動できるか
  946. public bool CanMove => GetBreedingAreaPermanents().Count(permanent => permanent.CanMove) >= 1 && fieldCardFrames.Count((frame) => frame.IsEmptyFrame()) >= 1;
  947. #endregion
  948. #region このターンにデジモンを進化させた回数
  949. public int DigivolveCount_ThisTurn { get; set; } = 0;
  950. #endregion
  951. #region 吸収進化でタップできるデジモンの条件(効果可否判定に使用)
  952. public bool CanTapWhenAbsorbEvolution_CheckAvailability(Permanent permanent, ICardEffect cardEffect)
  953. {
  954. if (permanent != null)
  955. {
  956. if (permanent.TopCard != null)
  957. {
  958. if (!permanent.IsSuspended && permanent.CanSuspend)
  959. {
  960. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent))
  961. {
  962. #region 吸収進化でタップできるデジモンの条件を変更させる効果
  963. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  964. {
  965. foreach (Permanent permanent1 in player.GetFieldPermanents())
  966. {
  967. #region 場のパーマネントの効果
  968. foreach (ICardEffect cardEffect1 in permanent1.EffectList(EffectTiming.None))
  969. {
  970. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  971. {
  972. if (cardEffect1.CanUse(null))
  973. {
  974. if (((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  975. {
  976. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  977. {
  978. return true;
  979. }
  980. }
  981. }
  982. }
  983. }
  984. #endregion
  985. }
  986. #region プレイヤーの効果
  987. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  988. {
  989. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  990. {
  991. if (cardEffect1.CanUse(null))
  992. {
  993. if (((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  994. {
  995. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  996. {
  997. return true;
  998. }
  999. }
  1000. }
  1001. }
  1002. }
  1003. #endregion
  1004. }
  1005. #endregion
  1006. if (permanent.TopCard.Owner == this)
  1007. {
  1008. return true;
  1009. }
  1010. }
  1011. }
  1012. }
  1013. }
  1014. return false;
  1015. }
  1016. #endregion
  1017. #region 吸収進化でタップできるデジモンの条件
  1018. public bool CanTapWhenAbsorbEvolution(Permanent permanent, ICardEffect cardEffect)
  1019. {
  1020. if (permanent != null)
  1021. {
  1022. if (permanent.TopCard != null)
  1023. {
  1024. if (!permanent.IsSuspended && permanent.CanSuspend)
  1025. {
  1026. if (permanent.TopCard.Owner.GetBattleAreaDigimons().Contains(permanent))
  1027. {
  1028. #region 吸収進化でタップできるデジモンの条件を変更させる効果
  1029. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1030. {
  1031. foreach (Permanent permanent1 in player.GetFieldPermanents())
  1032. {
  1033. #region 場のパーマネントの効果
  1034. foreach (ICardEffect cardEffect1 in permanent1.EffectList(EffectTiming.None))
  1035. {
  1036. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  1037. {
  1038. if (cardEffect1.CanUse(null))
  1039. {
  1040. if (!((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  1041. {
  1042. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  1043. {
  1044. return true;
  1045. }
  1046. else
  1047. {
  1048. return false;
  1049. }
  1050. }
  1051. }
  1052. }
  1053. }
  1054. #endregion
  1055. }
  1056. #region プレイヤーの効果
  1057. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1058. {
  1059. if (cardEffect1 is ICanSuspendByDigisorptionEffect)
  1060. {
  1061. if (cardEffect1.CanUse(null))
  1062. {
  1063. if (!((ICanSuspendByDigisorptionEffect)cardEffect1).isCheckAvailability())
  1064. {
  1065. if (((ICanSuspendByDigisorptionEffect)cardEffect1).canSuspendDigisorption(permanent, cardEffect))
  1066. {
  1067. return true;
  1068. }
  1069. else
  1070. {
  1071. return false;
  1072. }
  1073. }
  1074. }
  1075. }
  1076. }
  1077. #endregion
  1078. }
  1079. #endregion
  1080. if (permanent.TopCard.Owner == this)
  1081. {
  1082. return true;
  1083. }
  1084. }
  1085. }
  1086. }
  1087. }
  1088. return false;
  1089. }
  1090. #endregion
  1091. #region コストを減らせるか
  1092. public bool CanReduceCost(List<Permanent> targetPermanents, CardSource cardSource)
  1093. {
  1094. #region コストを減らせなくさせる効果
  1095. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1096. {
  1097. foreach (Permanent permanent in player.GetFieldPermanents())
  1098. {
  1099. #region 場のパーマネントの効果
  1100. foreach (ICardEffect cardEffect in permanent.EffectList(EffectTiming.None))
  1101. {
  1102. if (cardEffect is ICannotReduceCostEffect)
  1103. {
  1104. if (cardEffect.CanUse(null))
  1105. {
  1106. if (((ICannotReduceCostEffect)cardEffect).CannotReduceCost(this, targetPermanents, cardSource))
  1107. {
  1108. return false;
  1109. }
  1110. }
  1111. }
  1112. }
  1113. #endregion
  1114. }
  1115. #region プレイヤーの効果
  1116. foreach (ICardEffect cardEffect in player.EffectList(EffectTiming.None))
  1117. {
  1118. if (cardEffect is ICannotReduceCostEffect)
  1119. {
  1120. if (cardEffect.CanUse(null))
  1121. {
  1122. if (((ICannotReduceCostEffect)cardEffect).CannotReduceCost(this, targetPermanents, cardSource))
  1123. {
  1124. return false;
  1125. }
  1126. }
  1127. }
  1128. }
  1129. #endregion
  1130. }
  1131. #endregion
  1132. return true;
  1133. }
  1134. #endregion
  1135. #region DP消滅効果の上限
  1136. public int MaxDP_DeleteEffect(int maxDP, ICardEffect cardEffect)
  1137. {
  1138. int _maxDP = maxDP;
  1139. #region DP消滅効果の上限を変更する効果
  1140. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1141. {
  1142. foreach (Permanent permanent in player.GetFieldPermanents())
  1143. {
  1144. #region 場のパーマネントの効果
  1145. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1146. {
  1147. if (cardEffect1 is IChangeDPDeleteEffectMaxDPEffect)
  1148. {
  1149. if (cardEffect1.CanUse(null))
  1150. {
  1151. _maxDP = ((IChangeDPDeleteEffectMaxDPEffect)cardEffect1).GetMaxDP(_maxDP, cardEffect);
  1152. }
  1153. }
  1154. }
  1155. #endregion
  1156. }
  1157. #region プレイヤーの効果
  1158. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1159. {
  1160. if (cardEffect1 is IChangeDPDeleteEffectMaxDPEffect)
  1161. {
  1162. if (cardEffect1.CanUse(null))
  1163. {
  1164. _maxDP = ((IChangeDPDeleteEffectMaxDPEffect)cardEffect1).GetMaxDP(_maxDP, cardEffect);
  1165. }
  1166. }
  1167. }
  1168. #endregion
  1169. }
  1170. #endregion
  1171. return _maxDP;
  1172. }
  1173. #endregion
  1174. #region 進化条件を無視できるか
  1175. public bool CanIgnoreDigivolutionRequirement(Permanent targetPermanent, CardSource cardSource)
  1176. {
  1177. #region 進化条件を無視できなくさせる効果
  1178. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1179. {
  1180. foreach (Permanent permanent in player.GetFieldPermanents())
  1181. {
  1182. #region 場のパーマネントの効果
  1183. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1184. {
  1185. if (cardEffect1 is ICannotIgnoreDigivolutionConditionEffect)
  1186. {
  1187. if (cardEffect1.CanUse(null))
  1188. {
  1189. if (((ICannotIgnoreDigivolutionConditionEffect)cardEffect1).cannotIgnoreDigivolutionCondition(this, targetPermanent, cardSource))
  1190. {
  1191. return false;
  1192. }
  1193. }
  1194. }
  1195. }
  1196. #endregion
  1197. }
  1198. #region Player effect
  1199. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1200. {
  1201. if (cardEffect1 is ICannotIgnoreDigivolutionConditionEffect)
  1202. {
  1203. if (cardEffect1.CanUse(null))
  1204. {
  1205. if (((ICannotIgnoreDigivolutionConditionEffect)cardEffect1).cannotIgnoreDigivolutionCondition(this, targetPermanent, cardSource))
  1206. {
  1207. return false;
  1208. }
  1209. }
  1210. }
  1211. }
  1212. #endregion
  1213. }
  1214. #endregion
  1215. return true;
  1216. }
  1217. #endregion
  1218. #region セキュリティを増やせるか
  1219. public bool CanAddSecurity(ICardEffect cardEffect)
  1220. {
  1221. if (GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  1222. {
  1223. return false;
  1224. }
  1225. #region セキュリティを増やせない効果
  1226. foreach (Player player in GManager.instance.turnStateMachine.gameContext.Players_ForTurnPlayer)
  1227. {
  1228. foreach (Permanent permanent in player.GetFieldPermanents())
  1229. {
  1230. #region 場のパーマネントの効果
  1231. foreach (ICardEffect cardEffect1 in permanent.EffectList(EffectTiming.None))
  1232. {
  1233. if (cardEffect1 is ICannotAddSecurityEffect)
  1234. {
  1235. if (cardEffect1.CanUse(null))
  1236. {
  1237. if (((ICannotAddSecurityEffect)cardEffect1).cannotAddSecurity(this, cardEffect))
  1238. {
  1239. return false;
  1240. }
  1241. }
  1242. }
  1243. }
  1244. #endregion
  1245. }
  1246. #region プレイヤーの効果
  1247. foreach (ICardEffect cardEffect1 in player.EffectList(EffectTiming.None))
  1248. {
  1249. if (cardEffect1 is ICannotAddSecurityEffect)
  1250. {
  1251. if (cardEffect1.CanUse(null))
  1252. {
  1253. if (((ICannotAddSecurityEffect)cardEffect1).cannotAddSecurity(this, cardEffect))
  1254. {
  1255. return false;
  1256. }
  1257. }
  1258. }
  1259. }
  1260. #endregion
  1261. }
  1262. #endregion
  1263. return true;
  1264. }
  1265. #endregion
  1266. #region セキュリティを減らせるか
  1267. public bool CanReduceSecurity()
  1268. {
  1269. if (GManager.instance.turnStateMachine.gameContext.IsSecurityLooking)
  1270. {
  1271. return false;
  1272. }
  1273. return true;
  1274. }
  1275. #endregion
  1276. }
  1277. [Serializable]
  1278. public class ShowSupplyingEnergyIcon
  1279. {
  1280. public CardColor cardColor;
  1281. public Image SupplyingEnergyIcon;
  1282. public Text SupplyingEnergyText;
  1283. }
  1284. [Serializable]
  1285. public class FieldCardFrame
  1286. {
  1287. [Header("枠")]
  1288. public GameObject Frame;
  1289. [Header("選択状態表示枠")]
  1290. public Image Frame_Select;
  1291. [Header("枠ID")]
  1292. public int FrameID;
  1293. [Header("プレイヤー")]
  1294. public Player player;
  1295. public UnityAction<FieldCardFrame> OnClickAction { get; private set; }
  1296. public static bool isBattleAreaFrameID(int FrameID)
  1297. {
  1298. return 0 <= FrameID && FrameID <= GManager.instance.You.fieldCardFrames.Count - 2;
  1299. }
  1300. public bool IsBattleAreaFrame()
  1301. {
  1302. return isBattleAreaFrameID(this.FrameID);
  1303. }
  1304. public bool isBreedingAreaFrame()
  1305. {
  1306. return !IsBattleAreaFrame();
  1307. }
  1308. Permanent framePermanent = null;
  1309. public void SetFramePermanent(Permanent permanent)
  1310. {
  1311. framePermanent = permanent;
  1312. }
  1313. public Permanent GetFramePermanent()
  1314. {
  1315. /*
  1316. foreach (Permanent permanent in player.GetFieldPermanents())
  1317. {
  1318. if (permanent.PermanentFrame == this)
  1319. {
  1320. return permanent;
  1321. }
  1322. }
  1323. */
  1324. if (framePermanent != null)
  1325. {
  1326. return framePermanent;
  1327. }
  1328. return null;
  1329. }
  1330. public bool IsEmptyFrame()
  1331. {
  1332. return GetFramePermanent() == null;
  1333. }
  1334. public void AddClickTarget(UnityAction<FieldCardFrame> OnClickAction)
  1335. {
  1336. this.OnClickAction = OnClickAction;
  1337. if (Frame != null)
  1338. {
  1339. BoxCollider boxCollider = Frame.GetComponent<BoxCollider>();
  1340. if (boxCollider != null)
  1341. {
  1342. boxCollider.enabled = true;
  1343. }
  1344. }
  1345. }
  1346. public void RemoveClickTarget()
  1347. {
  1348. this.OnClickAction = null;
  1349. if (Frame != null)
  1350. {
  1351. BoxCollider boxCollider = Frame.GetComponent<BoxCollider>();
  1352. if (boxCollider != null)
  1353. {
  1354. boxCollider.enabled = false;
  1355. }
  1356. }
  1357. }
  1358. public void OffFrame_Select()
  1359. {
  1360. if (Frame_Select != null)
  1361. {
  1362. Frame_Select.gameObject.SetActive(false);
  1363. }
  1364. }
  1365. public void OnFrame_Select(Color color)
  1366. {
  1367. if (Frame_Select != null)
  1368. {
  1369. Frame_Select.gameObject.SetActive(true);
  1370. Frame_Select.color = color;
  1371. //Frame_Select.color = new Color(color.r, color.g, color.b, 0);
  1372. }
  1373. }
  1374. public Vector3 GetLocalCanvasPosition()
  1375. {
  1376. Vector3 vector = Frame.transform.localPosition + Frame.transform.parent.localPosition + Frame.transform.parent.parent.localPosition;
  1377. return Frame.transform.localPosition + Frame.transform.parent.localPosition + Frame.transform.parent.parent.localPosition;
  1378. }
  1379. public FieldCardFrame FacingFrame
  1380. {
  1381. get
  1382. {
  1383. if (this.IsBattleAreaFrame())
  1384. {
  1385. return player.fieldCardFrames[this.FrameID + 4];
  1386. }
  1387. else
  1388. {
  1389. return player.fieldCardFrames[this.FrameID - 4];
  1390. }
  1391. return null;
  1392. }
  1393. }
  1394. }