Player.cs 50 KB

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